基于letsencrypt 的免费证书自动续期

安装certbot

以 ubuntu apt 为例 ,如果是 centos 改成 yum,其他参数基本相同。

sudo apt install certbot

测试安装成功:

# certbot --version
certbot 2.9.0

配置 http 80 端口可用的 web server 路径

certbot 在生成证书时,要验证域名归属,所以需要先保证基本的域名可访问,假如想申请 BBB 域名的证书,先保证 BBB 的 http 的网址可访问,并且 web 根目录可正常读写。
对于 nginx 来说就是配置简单的 80 端口,域名和 root path等基本信息就可以,手动测试能访问到根目录下的文件。

生成证书

certbot certonly --webroot -w AAA -d BBB

BBB代表你要支持的域名,一般是子域名,比如 b.bbb.com,AAA是BBB当前已经可以访问的根目录,需要使用绝对路径。

生成成功后,域名路径一般在:

/etc/letsencrypt/live/BBB/fullchain.pem;
/etc/letsencrypt/live/BBB/privkey.pem;

注意:建议不要移动路径,全局使用这个生成的默认路径,因为这个免费证书只有 3 个月的有效期,我们后面还要通过 certbot 续期,默认续期的路径就是这个生成路径。

续期

certbot renew

自动续期

Linux 下,推荐用 cron服务

crontab -e

如果单独更新证书:

30 2 * * * sleep $(($RANDOM \% 600)) && certbot renew --quiet

如果配合 nginx使用,更新证书后,一定要重启 nginx 才能生效,所以需要额外参数:

30 2 * * * sleep $(($RANDOM \% 600)) && certbot renew --quiet --deploy-hook "nginx -s reload"

编译nanomq

编译nanomq

https://github.com/nanomq/nanomq

准备工作

gcc

sudo apt update
sudo apt install build-essential
gcc --version                 

cmake

# 安装依赖工具
sudo apt install ca-certificates curl gnupg

# 下载并添加 Kitware 的 GPG 密钥
curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo gpg --dearmor -o /usr/share/keyrings/kitware-archive-keyring.gpg

# 添加仓库到源列表
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/kitware.list

# 更新包列表
sudo apt update
sudo apt install cmake
cmake --version

下载编译

git clone https://github.com/emqx/nanomq.git 
cd nanomq
git submodule update --init --recursive
mkdir build && cd build
cmake -DNNG_ENABLE_QUIC=ON \
-DNANOMQ_TESTS=ON \
-DNNG_ENABLE_TLS=ON \
-DBUILD_ZMQ_GATEWAY=OFF \
-DBUILD_NFTP=OFF \
-DBUILD_DDS_PROXY=OFF \
-DENABLE_JWT=ON \
-DNNG_ENABLE_SQLITE=ON \
-DDEBUG=ON \
-DASAN=ON \
-DDEBUG_TRACE=ON \
..

编译
make
make install

nng依赖

安装依赖

sudo apt update
sudo apt install -y cmake gcc git make

从源码编译安装 NNG

git clone https://github.com/nanomsg/nng.git
cd nng
mkdir build && cd build
cmake ..
make -j$(nproc)
sudo make install
sudo ldconfig # 更新动态链接库缓存

开机启动

vi /etc/systemd/system/nanomq.service

[Unit]
Description=NanoMQ MQTT Broker
After=network.target

[Service]
Type=simple
ExecStart=/data/nanomq/build/nanomq/nanomq start --conf /data/nanomq/etc/nanomq.conf
Restart=on-failure
User=root
Group=root
WorkingDirectory=/data/nanomq/build/nanomq

[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload
sudo systemctl enable nanomq
sudo systemctl start nanomq
sudo systemctl status nanomq
journalctl -u nanomq.service -b

配置

  1. 3个端口 tpc ws http
  2. http的账号密码
  3. mqtt的账号和主题设置

    auth {
    allow_anonymous = false
    no_match = allow
    deny_action = ignore
    
    cache = {
        max_size = 32
        ttl = 1m
    }
    
    password = {include "/etc/nanomq_pwd.conf"}
    acl = {include "/etc/nanomq_acl.conf"}
    }

        {"permit": "allow", "username": "#", "action": "pubsub", "topics": ["up"]}
        {"permit": "allow", "username": "#", "action": "pubsub", "topics": ["down"]}
        {"permit": "deny"}
]

gd32f407开发纪要

boot pin

BOOT1=x BOOT0=0 从用户闪存启动,这是正常的工作模式。
BOOT1=0 BOOT0=1 从系统存储器启动,这种模式启动的程序功能由厂家设置。
BOOT1=1 BOOT0=1 从内置SRAM启动,这种模式可以用于调试

pve配置ipv6

vi /etc/network/interfaces

iface vmbr0 inet6 dhcp
        accept_ra 2
        request_prefix 1

vi /etc/sysctl.conf

net.ipv6.conf.all.accept_ra=2
net.ipv6.conf.default.accept_ra=2
net.ipv6.conf.vmbr0.accept_ra=2
net.ipv6.conf.all.autoconf=1
net.ipv6.conf.default.autoconf=1
net.ipv6.conf.vmbr0.autoconf=1

hp t610 bios 密码跳线端子及上电开机

默认bios是有密码的,解除密码的方式就是通过主板跳线端子,把对应的端子拿下。

对应主板上的丝印是PSWD

t610是在开机按键后面的的大概位置,有个3排的跳线端子,中间那个是pswd。

如果你要开开机启动 :
advance-》after power loss-》on 就表示上电自动开机

openwrt防火墙开关配置

验证时,好奇,在ui上把wan lan防火墙去掉了,改成未指定,结果设备连不上了,ssh也无法链接:
file

没办法,只能上串口,通过串口修改 /etc/config/firewall
红色部分时注意要恢复的内容
file

配置完成后,记得重启 /etc/init.d/network restart

pve有线无线网络配置

插卡网卡

ip a

enp开头的是有线网卡
wlpk开头的是无线网卡

静态改dhcp动态

将static更改为dhcp,并删除或注释掉address,netmask和gateway行

auto lo
iface lo inet loopback

iface enp1s0 inet manual

auto vmbr0
iface vmbr0 inet dhcp
        #address 192.168.1.105
        #netmask 255.255.255.0
        #gateway 192.168.1.1
        bridge-ports enp1s0
        bridge-stp off
        bridge-fd 0

iface wlp2s0 inet manual

source /etc/network/interfaces.d/*

反之就是动态改静态

开启 无限网络

先要安装网卡驱动,因为我们wlp2s0已经识别出来了,说明驱动已经ok了
先要安装 wpa工具apt install wpasupplicant

然后将 iface wlp2s0 inet manual改为:

auto wlp2s0
iface wlp2s0 inet dhcp
    wpa-ssid xxx
    wpa-psk xxx

重启网卡

systemctl restart networking

QUIC proxy Series 1-QUIC Overview

前言

目前对quic只是很浅很周边的了解,仅局限于材料和ppt,并未动手做过代码级别的实践。

最近想尝试下quic proxy的性能,是否能优于现有的技术方案,遂准备开始基本从零开始学习,记录下点滴,希望能帮到需要的人。

chrome quic

因为chrome quic 是一个已经可以体验实用的实现,打算先从chrome quic 学习。

quic 的实现进展

https://github.com/quicwg/base-drafts/wiki/Implementations

quic proxy

两篇文章待细看:

https://blog.cloudflare.com/unlocking-quic-proxying-potential
https://blog.apnic.net/2023/03/23/hiding-behind-masques/

开源代码项目

  1. chromium中的quic
  2. quiche,地址?

windows下删除本地adb的emulator device

tcpip的很简单,disconnect就可以。

本地的比较麻烦。

  1. 查询pid

    netstat -ano|findstr 5555
    TCP    127.0.0.1:5555         0.0.0.0:0              LISTENING       3496
    TCP    127.0.0.1:5555         127.0.0.1:58569        ESTABLISHED     3496
    TCP    127.0.0.1:58569        127.0.0.1:5555         ESTABLISHED     2356

    我们看到adb server的进程ID 3496

  2. 删除进程
    taskkill /pid 3496 -f
    成功: 已终止 PID 为 3496 的进程。

如何将安卓手机变成linux服务器,实现远程控制

github: https://github.com/hiproz/aosp-server-toolkit

背景

之前是用orange pi做家庭远程伺服跳板机的,平时开vnc或者ssh之类。发现老是死机,于是萌生了用二手手机做服务器的想法。
网上小黄鱼有很多二手手机,价格比开发板还便宜,而且配置更高,硬件的一致性也更好。

pixel3 手机 & aosp

因为google的pixel手机对应的代码基线都是开源的,所以选择便宜的pixel手机。代码直接从aosp的官网获取。
目前pixel3的价格在100-200 比开发板是很高性价比了,所以我们选择pixel3手机作为入门。
aosp系统固件构建,一般主要是做跟服务器相关的特性修改,比如充电自动开机,集成各种工具,比如vnc,busybox等等。具体的编译和集成方法根据不同版本各有差异,需要自己从网上获取验证。

简介

为了将pixel手机变成一台通用linux服务器,用来实现远程控制监控家庭和公司网络的目的。我们基于aosp源码,添加必要的工具集,并给出相关的软件配置操作流程等。

这里的固件和工具,当前通过pixel3验证,但理论上只要适合aosp对应版本的手机,就都能使用,只是我们不一定都一一验证,需要用户自行验证,有问题欢迎反馈。

系统架构

我们方案的一些基本核心功能:

  1. 上电自动开机
  2. 实现vnc远程效果,采用frp+scrcpy
  3. 远程shell操作,我们使用的基于tcpip的 adb shell

file

使用步骤

  1. 下载对应编译好的aosp固件
  2. 烧录固件到手机,并手动配置手机wifi网络,确保手机能联网
  3. 首次配置:通过adb进行必要的frpc配置
  4. 远程登录手机,进行操作
  5. 恭喜你,你已经拥有了一台 arm64的带有屏幕的低功耗linux服务器了

烧录

使用安卓adb,fastboot工具链来进行烧录。

windows

windows adb tools

adb version:Version 31.0.3-7562133
fastboot verison:fastboot version 31.0.3-7562133

烧录步骤

  1. 解锁你的安卓手机,保证你能正常使用fastboot,解锁方法请根据你的手机型号和版本自行google
  2. 下载合适的固件压缩包,解压
  3. 启动cmd,cd到解压的目录内
  4. 设置环境变量 set ANDROID_PRODUCT_OUT=your 解压目录
  5. adb reboot bootloader
  6. fastboot flashall -w
  7. 烧录完成提示如下

file

mac

mac adb tools

【待补充】

烧录步骤

和windows的基本一致,不一致的是设置环境变量的命令不同。

*不同之处待更新**【待补充】*

首次使用

我们的系统是debug版本,所以支持root和remount。首次使用时,我们需要配置frpc相关的服务,保证我们以后可以远程操作手机。

1. 首次remount

为了对手机进行各种文件操作,我们建议默认remount。

adb root
adb remount
# 这里可能提示重启,请进行必要的重启 
adb reboot

2. frpc 配置

我们主要是通过frpc 来实现远程scrcpy和adb shell,所以你需要部署一台frp服务器。可以从网上买一个最小配置的vps。

frps 服务器

你需要一台有公网ip的服务器,部署frp服务器,具体可以去frpc官网下载,因为我们手机端集成的是v0.58.0。所以我们建议服务器端和电脑客户端,也下载对应的版本。我们假设服务器开启token安全机制,参考配置如下:

bindPort = 7000
auth.method = "token"
auth.token = "123"

usb adb连接手机,修改frpc配置

adb root
adb remount
adb shell
busybox vi /data/frpc.toml

frpc.toml 参考内容如下:

serverAddr = "1.1.1.1" # only support ip, do not use domain
serverPort = 7000
auth.method = "token"
auth.token = "000000"

[[proxies]]
name = "secret_proxy"
type = "stcp"
secretKey = "key"
localIP = "127.0.0.1"
localPort = 5555

请根据你自己服务器的实际参数,修改以上参数,修改后adb reboot手机,重新进去adb shell 确认frpc是否正确取运行,如果能正确看到frpc进程信息,就初步确认frp运行起来了:

blueline:/ # ps -ef|grep frpc
root     4185  2739 1 19:31:01 ?     00:00:00 frpc -c /data/frpc.toml
root     4194  3639 22 19:31:04 pts/0 00:00:00 grep frpc

远程连接手机

参看我们前面技术架构,在我们通过自己的电脑远程访问时,我们先要在本地把电脑上的frpc跑起来。

1. 配置本地frpc

serverAddr = "1.1.1.1"
serverPort = 7000
auth.method = "token"
auth.token = "123"

[[visitors]]
name = "secret_visitor"
type = "stcp"
serverName = "secret_proxy"
secretKey = "key"
bindAddr = "127.0.0.1"
bindPort = 5555

在配置完frpc后,我们基本就可以拔掉usb,完全像远程服务器一样来访问手机了。这里我们假设你的frps 和frpc都配置正确。如果你有这方面的错误,请检查网络以及端口防火墙等基本网络参数。

2. 设置tcpip adb,建立远程adb链路

adb connect localhost:5555
connected to localhost:5555

3. 像在本地通过usb连接手机一样,启动scrcpy

file

4. 如果想使用shell, 你可以使用adb shell,感觉就跟usb 连接一样

adb shell

ssh

我们的固件集成了ssh客户端,当我们需要将手机作为跳板服务器或者堡垒机服务器通过ssh访问别的ssh服务器器时,我们就可以使用手机中的ssh来完成

vi

你可以使用 busybox vi

其他工具?

待补充

本地下载

  1. https://cdn.itranscloud.com/aosp/aosp_blueline-userdebug_12_SP1A.210812.016.A1.7z
  2. https://cdn.itranscloud.com/aosp/aosp_blueline-userdebug_12_SP1A.210812.016.A1_v101.7z

pixel3 aosp编译

以下内容主要参考网络内容,按照实际验证的顺序和细节补充而成,使流程更清晰,可以傻瓜式照抄。

  1. 根据自己手机刷机前的版本信息,在 https://source.android.com/docs/setup/about/build-numbers?hl=zh-cn#source-code-tags-and-builds 获取版本SP1A.210812.016.A1
    file
    后面repo init时,我们将要用这个版本号,获取准确的版本。

    repo init -u https://android.googlesource.com/platform/manifest -b android-12.0.0_r3
  2. 获取vendor驱动,从 https://developers.google.com/android/drivers?hl=zh-cn 中找到对应版本 https://link.zhihu.com/?target=https%3A//developers.google.com/android/drivers/%23crosshatchsp1a.210812.016.a1, 这个待会编译时,要解压到vendor下

  3. 安装git, repo:https://mirrors.tuna.tsinghua.edu.cn/help/git-repo/

  4. 运行 repo init,这里考虑到网速的问题,我们使用清华的镜像地址。如果你没有网络困扰,也可以使用上面提到的google android官方地址:

    mkdir ~/work/aosp/
    cd ~/work/aosp/
    repo init -u
    https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-12.0.0_r3
  5. repo sync -jxx , xx为你的虚拟软核数

  6. 更新vendor和驱动:

    cd ~/Downloads
    tar xvf qcom-crosshatch-*.tgz
    tar xvf google_devices-crosshatch-*.tgz
    cd ~/work/aosp/
    ~/Downloads/extract-qcom-crosshatch.sh
    ~/Downloads/extract-google_devices-crosshatch.sh
  7. 编译

    source build/envsetup.sh
    lunch 4(aosp_blueline-userdebug)
    m

    m 是构建代码的简单命令

  8. 安装adb kit,安装adb 和fastboot工具集,作者用的是Version 31.0.3-7562133 版本。

  9. 烧录下载

    adb reboot bootloader
    fastboot flashall -w

    flashall 会提示设置ANDROID_PRODUCT_OUT环境变量,设置成实际的out编译目录就好(如果是在windows烧录,就把整个目录下载到windows,然后设置成windows实际的out路径)。
    linux: export ANDROID_PRODUCT_OUT=/xxx/out/target/product/blueline
    windows: set ANDROID_PRODUCT_OUT=/xxx/out/target/product/blueline

  10. 构建内核(可选),可以参考https://zhuanlan.zhihu.com/p/448289040 的后半部分内容。

最后,如果你不想麻烦,也可以取用我们编译好的原生版本:
https://cdn.itranscloud.com/aosp/aosp_blueline-userdebug_12_SP1A.210812.016.A1.7z

ref:https://zhuanlan.zhihu.com/p/448289040

letsencrypt renew的认证路径

在某些重定向的配置场景中,所有请求都被proxy到了远端服务器,这时候certbot rewew的时候就因为无法远程操控well-known路径导致认证失败。
解决就是在proxy的本地创建认证目录:

# letsencrypt认证目录
location /.well-known/ {
    root  /data/wwwroot/xxx;
}

location /{
    # 其他目录的操作在这里
}

openwrt刷机固件基本知识

squashfs-factory.bin -- uboot 裸机第一次刷openwrt时用
squashfs-sysupgrade.bin -- 由openwrt升级到openwrt时用

官方固件的说明
xxx-preloader.bin -》 BL2
xxx-bl31-uboot.fip -》FIP
xxx-initramfs-recovery.itb -》包含rootfs image的运行在ram中的系统,用于flash还不完备时,加载在内存中做调试用,一般刷机不用
xxx-sysupgrade.bin -》 在系统升级页面中升级系统

QEMU 机器类型和兼容性【翻译】

如果您想要将最初在较旧的 QEMU 版本上启动的来宾迁移到较新版本的 QEMU,您需要确保两台机器实际上彼此兼容。一旦排除了根本无法迁移的设备之类的东西,并确保两个 QEMU 调用实际上创建了相同的虚拟硬件,这基本上可以归结为使用兼容的机器。

版本化机器类型

如果你只是想创建一台机器而不考虑迁移兼容性,你通常会这样做

qemu-system-ppc64 -machine pseries (...)

这将创建一个这种pseries类型的机器。但在本例中,pseries
实际上是该机器类型的最新版本的别名;
对于 6.2,这将是
pseries-6.2. 您可以通过以下方式找出哪些机器类型已版本化(以及给定二进制文件实际存在哪些机器类型)-machine ?

$ qemu-system-ppc64 -machine ?
Supported machines are:
40p                  IBM RS/6000 7020 (40p)
bamboo               bamboo
g3beige              Heathrow based PowerMAC
mac99                Mac99 based PowerMAC
mpc8544ds            mpc8544ds
none                 empty machine
pegasos2             Genesi/bPlan Pegasos II
powernv10            IBM PowerNV (Non-Virtualized) POWER10
powernv8             IBM PowerNV (Non-Virtualized) POWER8
powernv              IBM PowerNV (Non-Virtualized) POWER9 (alias of powernv9)
powernv9             IBM PowerNV (Non-Virtualized) POWER9
ppce500              generic paravirt e500 platform
pseries-2.1          pSeries Logical Partition (PAPR compliant)
pseries-2.10         pSeries Logical Partition (PAPR compliant)
pseries-2.11         pSeries Logical Partition (PAPR compliant)
pseries-2.12         pSeries Logical Partition (PAPR compliant)
pseries-2.12-sxxm    pSeries Logical Partition (PAPR compliant)
pseries-2.2          pSeries Logical Partition (PAPR compliant)
pseries-2.3          pSeries Logical Partition (PAPR compliant)
pseries-2.4          pSeries Logical Partition (PAPR compliant)
pseries-2.5          pSeries Logical Partition (PAPR compliant)
pseries-2.6          pSeries Logical Partition (PAPR compliant)
pseries-2.7          pSeries Logical Partition (PAPR compliant)
pseries-2.8          pSeries Logical Partition (PAPR compliant)
pseries-2.9          pSeries Logical Partition (PAPR compliant)
pseries-3.0          pSeries Logical Partition (PAPR compliant)
pseries-3.1          pSeries Logical Partition (PAPR compliant)
pseries-4.0          pSeries Logical Partition (PAPR compliant)
pseries-4.1          pSeries Logical Partition (PAPR compliant)
pseries-4.2          pSeries Logical Partition (PAPR compliant)
pseries-5.0          pSeries Logical Partition (PAPR compliant)
pseries-5.1          pSeries Logical Partition (PAPR compliant)
pseries-5.2          pSeries Logical Partition (PAPR compliant)
pseries-6.0          pSeries Logical Partition (PAPR compliant)
pseries-6.1          pSeries Logical Partition (PAPR compliant)
pseries              pSeries Logical Partition (PAPR compliant) (alias of pseries-6.2)
pseries-6.2          pSeries Logical Partition (PAPR compliant) (default)
ref405ep             ref405ep
sam460ex             aCube Sam460ex
taihu                taihu
virtex-ml507         Xilinx Virtex ML507 reference design

pseries-x.y如您所见,旧版本有多种机器类型;这些旨在提供与使用较旧的 QEMU 版本创建的默认机器兼容的配置。例如,如果您想要迁移在pseries使用 QEMU 5.1 创建的计算机上运行的来宾,则接收 QEMU 需要启动

qemu-system-ppc64 -machine pseries-5.1 (...)

支持的机器类型

注意:以下内容适用于上游 QEMU。发行版可能在其构建中支持不同版本的机器类型。

此列表自 QEMU 6.2 起;将来可能会添加新版本的机器类型,有时旧版本的机器类型会被弃用和删除。下一个 QEMU 版本的机器类型通常在发布周期的早期引入(至少,这是目标......)

arm,aarch64

virt机器类型支持 2.6 以后的版本。

m68k

virt机器类型支持 6.0 以后的版本。

ppc64

pseries机器类型支持 2.1 之后的版本。

s390x

s390-ccw-virtio机器类型支持 2.4 以后的版本。

i386、x86_64

机器pc-i440fx类型支持1.4以后的版本(以前还有更老的版本,但是已经被删除了),而pc-q35机器类型支持2.4以后的版本。

这里还需要考虑另一件事:pc机器类型别名(从 QEMU 6.2 开始)指向最新的pc-i440fx机器类型;如果您想要最新的
pc-q35机器类型,则必须使用q35.

如何使用这个

如果您只想启动 QEMU 实例并再次关闭它,而不希望将其迁移到任何地方,则可以坚持使用默认机器类型。但是,如果您以后可能想要迁移机器,那么明确指定版本化机器类型可能是个好主意,这样您就不必记住启动时使用的 QEMU 版本。

或者直接使用libvirt之类的管理软件,它会自动帮你把机器类型扩展到最新版本,以后就不用担心了。

兼容机种的使用部分就到此结束;后续文章将介绍如何实际实施。

ref:https://people.redhat.com/~cohuck/2022/01/05/qemu-machine-types.html

服务器sata-raid混用模式下热插拔磁盘扩容

用的是惠普dl360服务器,增加了几块磁盘后,发现ubuntu中看不到。

新增6块:
2块保留sata模式
4块组成raid6

查看物理磁盘信息

lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0     4K  1 loop /snap/bare/5
loop1    7:1    0  63.4M  1 loop /snap/core20/1974
loop2    7:2    0  63.9M  1 loop /snap/core20/2182
loop3    7:3    0  73.9M  1 loop /snap/core22/858
loop4    7:4    0 237.2M  1 loop /snap/firefox/2987
loop5    7:5    0 349.7M  1 loop /snap/gnome-3-38-2004/143
loop6    7:6    0 485.5M  1 loop /snap/gnome-42-2204/120
loop7    7:7    0   497M  1 loop /snap/gnome-42-2204/141
loop8    7:8    0  91.7M  1 loop /snap/gtk-common-themes/1535
loop9    7:9    0  12.3M  1 loop /snap/snap-store/959
loop10   7:10   0  53.3M  1 loop /snap/snapd/19457
loop11   7:11   0  40.4M  1 loop /snap/snapd/20671
loop12   7:12   0   452K  1 loop /snap/snapd-desktop-integration/83
sda      8:0    0   2.2T  0 disk 
sdb      8:16   0 238.5G  0 disk 
├─sdb1   8:17   0   512M  0 part /boot/efi
└─sdb2   8:18   0   238G  0 part /var/snap/firefox/common/host-hunspell
                                 /
sdc      8:32   0 745.2G  0 disk 
sdd      8:48   0 745.2G  0 disk 
sde      8:64   0   512M  1 disk 
└─sde1   8:65   0 509.8M  1 part /media/zcj/VID

格式化

# 格式化成 Ext4
mkfs.ext4 /dev/vdb1
​
# 格式化为 XFS
apt install xfsprogs
mkfs.xfs /dev/vdb2
​
# 格式化为 Btrfs
apt install btrfs-progs
mkfs.btrfs /dev/vdb3

这里我们选择xfs

sudo mkfs.xfs /dev/sdc
meta-data=/dev/sdc               isize=512    agcount=4, agsize=48838262 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=0 inobtcount=0
data     =                       bsize=4096   blocks=195353046, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=95387, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Discarding blocks...Done.

临时挂载

普通单xfs 磁盘

mount -t xfs /dev/sdc /disk2

raid磁盘

sudo mkfs.xfs /dev/sda
mkfs.xfs: /dev/sda appears to contain a partition table (gpt).
mkfs.xfs: Use the -f option to force overwrite.

这里提示无法挂载,有gpt分区表,因为确认是新raid,我们选择强制格式化,加-f参数:
sudo mkfs.xfs -f /dev/sda

df -h 查看挂载结果

永久挂载

vim /etc/fstab

/swapfile                                 none            swap    sw              0       0
/dev/sdc        /disk2          xfs     defaults         0       0
/dev/sdd        /disk3           xfs    defaults          0        0

生效查看:
mount -a

brew git错误

fatal: not in a git directory
Error: Command failed with exit 128: git

首先 网上说的那个git config 是没用的,我是在brew -v 正常的情况下,出现这个错误的,

所以,继续搜索...

解决:
执行 brew doctor,然后按照提示,把所有的warnning消除掉,然后就正常了

brew doctor
Your system is ready to brew.

brew update --verbose
Checking if we need to fetch /opt/homebrew/Homebrew...
Fetching /opt/homebrew/Homebrew...
Checking if we need to fetch formula.jws.json...
Checking if we need to fetch cask.jws.json...
Checking if we need to fetch formula_tap_migrations.jws.json...
Checking if we need to fetch cask_tap_migrations.jws.json...
Already up-to-date.

m1 macbook(arm版通用)安装brew

安装:
cd /opt/homebrew/

/bin/zsh -c "$(curl -fsSL https://gitee.com/huwei1024/HomebrewCN/raw/master/Homebrew.sh)"

消除告警:
git config --global --add safe.directory /opt/homebrew/Homebrew/Library/Taps/homebrew/homebrew-core git config --global --add safe.directory /opt/homebrew/Homebrew/Library/Taps/homebrew/homebrew-cask

最后将brew路径写入shell配置 .zshrc
export PATH=$PATH:/opt/homebrew/bin

linux(ubuntu)下运行shadowsocks客户端

最终一键脚本:ssc-1key-linux

系统: Ubuntu 22.04

shadowsocks相关

  1. 将系统更新到最新版
  2. 安装shadowsocks及必要组件
    pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U
    sudo apt-get install -y libsodium*
  3. 配置shadowsocks client
    sudo vi /etc/shadowsocks.json
{
  "server": "您服务器地址",
  "server_port": 9999,
  "local_address": "127.0.0.1",
  "local_port": 1080,
  "password": "密码",
  "timeout": 600,
  "method": "aes-256-cfb"
}
  1. 解决sodium库问题
    sudo ln -s /usr/lib/x86_64-linux-gnu/libsodium.a /usr/lib/x86_64-linux-gnu/liblibsodium.a

  2. 设置路径权限
    sudo chmod 777 /var/log
    sudo chmod 777 /var/run

  3. shadowsocks 开机自启动
    sudo vim /etc/systemd/system/shadowsocks.service:

    Description=Shadowsocks Client Service
    After=network.target
    [Service]
    Type=simple
    User=root
    ExecStart=/usr/local/bin/sslocal -c /etc/shadowsocks.json restart
    [Install]
    WantedBy=multi-user.target

    systemctl enable shadowsocks.service

HTTP全局代理

实现全局代理,我们可以使用polipo

  1. polipo 安装
    wget http://archive.ubuntu.com/ubuntu/pool/universe/p/polipo/polipo_1.1.1-8_amd64.deb
    安装 sudo dpkg -i polipo_1.1.1-8_amd64.deb
    配置 vi /etc/polipo/config

    logSyslog = true
    logFile = /var/log/polipo/polipo.log
    proxyAddress = "0.0.0.0"
    socksParentProxy = "127.0.0.1:1080"
    socksProxyType = socks5
    chunkHighMark = 50331648
    objectHighMark = 16384
    serverMaxSlots = 64
    serverSlots = 16
    serverSlots1 = 32

    polipo安装后会自动运行。

  2. 通过polipo设置本地http代理

    export http_proxy=http://127.0.0.1:8123
    export https_proxy=http://127.0.0.1:8123

    取消代理
    unset http_proxy
    unset https_proxy

pac代理

如果想使用http下的pac机制,可以考虑用provoxy替换polipo

  1. provoxy 安装
    安装:sudo apt-get install -y privoxy
    cp /etc/privoxy/config /etc/privoxy/config.bak
    vim /etc/privoxy/config
    确保 listen-address 127.0.0.1:8118 打开
    在/etc/profile, ~/.bashrc,~/.bash_profile 中添加:

    proxy="http://127.0.0.1:8118"
    export https_proxy=$proxy
    export http_proxy=$proxy
    export ftp_proxy=$proxy

    systemctl enable privoxy
    systemctl restart privoxy

  2. GFWList2Privoxy 制作pac条目
    pip install gfwlist2privoxy
    添加自定义域名:在生成的gfwlist.action文件中添加需要通过proxy访问的域名
    使pac生效:在/etc/privoxy/config文件中加上actionsfile gfwlist.action,然后重启privoxy服务

issue shooting:

  1. AttributeError: module 'collections' has no attribute 'MutableMapping'
    解决:/home/zcj/.local/lib/python3.10/site-packages/shadowsocks/lru_cache.py 34行 MutableMapping前面加上abc.
  2. [Errno 2] No such file or directory: b'liblibsodium.a'
    解决:sudo ln -s /usr/lib/x86_64-linux-gnu/libsodium.a /usr/lib/x86_64-linux-gnu/liblibsodium.a

参考:

  1. https://github.com/enpenguc/linux-backup/blob/master/doc/Ubuntu%20Server%E5%AE%89%E8%A3%85shadowsocks%E5%AE%A2%E6%88%B7%E7%AB%AF.md

燕尾蝶

凭着些许的记忆,我找到了《燕尾蝶》,那是少年时的震撼,一直萦绕于心,趁这个春节有空,得以找到资源。重温后,却感觉些许的迷茫,一种破碎记忆的感觉,时间太久远了,记忆已经模糊,感觉就是印象中的故事,又感觉有些生疏,因为印象中没有这么多细节,我只记依稀得移民,黑社会,各种混杂的语言,昏暗的画面。。。

一时恍惚。

我又仔细搜索了下,着实找不到第二个能对的上记忆的影片,只能悻悻道,可能就是它吧。

人的记忆是会变的,趁年轻,多写些记忆吧。

如何在windows中模拟arm64安卓系统

quem efi:

https://releases.linaro.org/reference-platform/enterprise/17.12/uefi/release/qemu-aarch64/QEMU_EFI.fd

安卓 iso:

https://developers.google.cn/android/images?hl=zh-cn#crosshatch

quem

pacman 所需的msys2 安装

https://www.qemu.org/download/#windows

For 64 bit Windows 8.1 or above (in UCRT64):

pacman -S mingw-w64-ucrt-x86_64-qemu
qemu-img --version
qemu-img version 8.2.0
Copyright (c) 2003-2023 Fabrice Bellard and the QEMU Project developers

qemu-system-aarch64

debian下安装docker后无法使用

安装后提示:
docker is already the newest version (1.5-2)

但是运行docker 命令提示找不到。

然后重新安装:
curl -sSL https://get.docker.com/ | sudo sh
提示:
The repository 'https://download.docker.com/linux/ubuntu bookworm Release' does not have a Release file.

cd /etc/apt/sources.list.d/

发现有个 archive_uri-https_download_docker_com_linux_ubuntu-bookworm.list

rm archive_uri-https_download_docker_com_linux_ubuntu-bookworm.list
删除后再执行,就正常了。

Client: Docker Engine - Community
 Version:           25.0.3
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        4debf41
 Built:             Tue Feb  6 21:14:25 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.3
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       f417435
  Built:            Tue Feb  6 21:14:25 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

gitlab配置

看日志:
gitlab-ctl tail

看运行状态:
gitlab-ctl status

配置:
vi /etc/gitlab/gitlab.rb
打开屏蔽,然后 gitlab-ctl reconfigure

网上的一份最简配置

external_url 'http://git.xxx.com'
gitlab_rails['time_zone'] = 'Asia/Shanghai'

# 关闭电子邮件相关功能
gitlab_rails['smtp_enable'] = false
gitlab_rails['gitlab_email_enabled'] = false
gitlab_rails['incoming_email_enabled'] = false

# Terraform
gitlab_rails['terraform_state_enabled'] = false

# Usage Statistics
gitlab_rails['usage_ping_enabled'] = false
gitlab_rails['sentry_enabled'] = false
grafana['reporting_enabled'] = false

# 关闭容器仓库功能
gitlab_rails['gitlab_default_projects_features_container_registry'] = false
gitlab_rails['registry_enabled'] = false
registry['enable'] = false
registry_nginx['enable'] = false

# 包仓库
gitlab_rails['packages_enabled'] = false
gitlab_rails['dependency_proxy_enabled'] = false

# GitLab KAS
gitlab_kas['enable'] = false
gitlab_rails['gitlab_kas_enabled'] = false

# Mattermost
mattermost['enable'] = false
mattermost_nginx['enable'] = false

# Kerberos
gitlab_rails['kerberos_enabled'] = false
sentinel['enable'] = false

# GitLab Pages
gitlab_pages['enable'] = false
pages_nginx['enable'] = false

# 禁用 PUMA 集群模式
puma['worker_processes'] = 0
puma['min_threads'] = 1
puma['max_threads'] = 2

# 降低后台守护进程并发数
sidekiq['max_concurrency'] = 5

gitlab_ci['gitlab_ci_all_broken_builds'] = false
gitlab_ci['gitlab_ci_add_pusher'] = false

# 关闭监控
prometheus_monitoring['enable'] = false
alertmanager['enable'] = false
node_exporter['enable'] = false
redis_exporter['enable'] = false
postgres_exporter['enable'] = false
pgbouncer_exporter['enable'] = false
gitlab_exporter['enable'] = false
grafana['enable'] = false
sidekiq['metrics_enabled'] = false