xixiha's Blogs

https://github.com/xixiha5230/

0%

  1. 官方教程

  2. 本方法适用于squashfs文件系统

  3. 本方法适用于对SD卡扩容

通过本方法扩容,系统更新后只要将分区重新挂载到overlay分区上就可以保留之前安装的软件和设置。

1. 准备

安装必要软件:

1
2
opkg update
opkg install block-mount kmod-fs-ext4 e2fsprogs parted fdisk

2. 创建分区

openwrt默认只有两个分区,通过fdisk -l查看分区:

其中/dev/mmcblk0是SD卡设备,它有两个分区。/dev/mmcblk0p1boot分区,不需要修改。/dev/mmcblk0p2overlay分区,openwrt会默认将软件安装到这个地方,也不需要修改。

接下来通过fdisk在SD卡剩余空间创建新的分区,打开SD卡fdisk /dev/mmcblk0

输入p现实目前的分区:

输入n创建新分区,p设置primary,3分区, 344064扇区为起始扇区到最后一个扇区。具体如下图:

这样就创建好了新分区。现在输入p结果如下:

3. 设置extroot

/dev/mmcblk0p3挂载到/overlay

1
2
3
4
5
6
7
8
DEVICE=/dev/mmcblk0p3
eval $(block info ${DEVICE} | grep -o -e 'UUID="\S*"')
eval $(block info | grep -o -e 'MOUNT="\S*/overlay"')
uci -q delete fstab.extroot
uci set fstab.extroot="mount"
uci set fstab.extroot.uuid="${UUID}"
uci set fstab.extroot.target="${MOUNT}"
uci commit fstab

4. 迁移数据

将原始overlay中的数据迁移到/dev/mmcblk0p3

1
2
mount ${DEVICE} /mnt
tar -C ${MOUNT} -cvf - . | tar -C /mnt -xf -

5. 配置rootfs_data/ubifs

将原始overlay(也就是/dev/mmcblk0p2)挂载到/rwm

1
2
3
4
5
6
DEVICE="$(block info | sed -n -e '/MOUNT="\S*\/overlay"/s/:\s.*$//p')"
uci -q delete fstab.rwm
uci set fstab.rwm="mount"
uci set fstab.rwm.device="${DEVICE}"
uci set fstab.rwm.target="/rwm"
uci commit fstab

这将允许您访问rootfs_data/ubifs分区,并自定义extroot配置/rwm/upper/etc/config/fstab

6. 重启

1
reboot

完成。

如果有错误可以参考这里

直接安装

直接安装会报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
root@OpenWrt:~# pip uninstall peewee
Found existing installation: peewee 3.17.0
Uninstalling peewee-3.17.0:
Would remove:
/usr/bin/pwiz.py
/usr/lib/python3.10/site-packages/peewee-3.17.0-py3.10.egg
Proceed (Y/n)? y
Successfully uninstalled peewee-3.17.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@OpenWrt:~# pip install peewee
Collecting peewee
Using cached peewee-3.17.0.tar.gz (2.9 MB)
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 2
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Installing build dependencies ... error
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 2
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

通过源码安装

1
2
3
git clone https://github.com/coleifer/peewee.git
cd peewee
python setup.py install

会出现如下报错

1
2
3
4
5
6
7
8
9
10
oot@OpenWrt:~/peewee# python setup.py install
...
/tmp/tmp_pw_sqlite3_1wb7m_b7/test_pw_sqlite3.c:1:10: fatal error: sqlite3.h: No such file or directory

1 | #include <sqlite3.h>

| ^~~~~~~~~~~

compilation terminated.
...

openwrt无法直接安装sqlite3,需要通过sqlite3源码来安装,下载源码

1
2
3
4
5
6
7
8
9
10
11
12
# 先安装依赖
opkg install grep
opkg install make

wget https://sqlite.org/2023/sqlite-autoconf-3440000.tar.gz
tar -zxvf sqlite-autoconf-3440000.tar.gz
cd sqlite-autoconf-3440000
./configure --prefix=/usr

make -j1
make install
# ldconfig: not found 可以忽略

安装完成后回到 peewee

1
2
3
4
5
6
# 先更新setuptools
pip install --upgrade setuptools

python setup.py clean
python setup.py install
# playhouse/_sqlite_ext.c: No such file or directory 可以忽略

完成~

适用于 Debian 10

v2ray

安装

1
2
3
4
5
wget https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh

sudo chmod u+x install-release.sh

sudo bash install-release.sh

配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
"inbounds": [
{
"port": 10809,
"listen": "127.0.0.1",
"protocol": "vless",
"settings": {
"clients": [
{
"id": "UUID",
"level": 0,
"email": "email"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"path": "/path"
}
},
"sniffing": {
"enabled": true,
"destOverride": ["http", "tls"]
}
}
],
"outbounds": [
{
"tag": "default",
"protocol": "freedom"
}
]
}

重启、开机自启

1
2
3
sudo service v2ray restart

sudo systemctl enable v2ray

caddy

安装

1
2
3
4
5
6
7
8
9
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list

sudo apt update

sudo apt install caddy

配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
www.your_domain.com
{
log {
output file /var/log/caddy/caddy.log
}
tls email@gmail.com
root * /home/user/web
try_files /home/user/web/index.html
@websockets {
header Connection Upgrade
header Upgrade websocket
}
reverse_proxy @websockets localhost:10809
}

wgcf

安装

1
2
3
4
5
6
7
wget https://github.com/ViRb3/wgcf/releases/tag/v2.2.17

tar -zcvf wgcf_2.2.17_linux_amd64

sudo mv wgcf_2.2.17 /user/local/bin/wgcf

sudo chmod u+x /user/local/bin/wgcf

注册

1
wgcf register

The new account will be saved under wgcf-account.toml

生成wireguard配置文件

1
wgcf generate

The WireGuard profile will be saved under wgcf-profile.conf.

WireGuard

参考

升级debian内核

1
2
3
4
5
6
7
8
echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/backports.list

apt update
apt -t buster-backports install linux-image-amd64
apt -t buster-backports install linux-headers-amd64
update-grub

shutdown -r now

卸载旧内核

1
2
3
4
5
6
uname -r

dpkg --list | grep linux-image
apt -y remove --purge $(dpkg -l | grep linux-image | awk '{print$2}' | grep -v $(uname -r))

dpkg --list | grep linux-headers

安装

1
2
3
4
echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/backports.list
sudo apt update

sudo apt install wireguard

配置文件wgcf-profile.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[Interface]
PrivateKey = XXXXXXXX
Address = 172.16.0.2/32
Address = XXXX:XXXX:XXXX:XXXX/128
PostUp = ip rule add from xx.xx.xx.xx(vps主网卡的ipv4)lookup main # v4 機器要雙棧接管的話要加上這行规则
PostDown = ip rule del from xx.xx.xx.xx(vps主网卡的ipv4)lookup main # v4 機器要雙棧接管的話要加上這行规则
PostUp = ip rule add from xx.xx.xx.xx(vps主网卡的ipv6)lookup main # v6 機器要雙棧接管的話要加上這行规则
PostDown = ip rule del from xx.xx.xx.xx(vps主网卡的ipv6)lookup main # v6 機器要雙棧接管的話要加上這行规则
DNS = 1.1.1.1
MTU = 1280
[Peer]
PublicKey = XXXXXXXX
AllowedIPs = 0.0.0.0/0
AllowedIPs = ::/0
EndPoint = engage.cloudflareclient.com:2408
#EndPoint = 162.159.192.1:2408
#EndPoint = 2606:4700:d0::a29f:c001:2408

根据不同的需求,有不同的地方需要修改 - IPv4 Only VPS

接管出口 VPS IP AllowedIPs Endpoint PostUp/PostDown
v4 v4 刪掉 ::/0 改成 v4 地址 加 v4 規則
v6 v4 刪掉 0.0.0.0/0 改成 v4 地址 不用加
v4+v6 v4 不用刪 改成 v4 地址 加 v4 規則

根據不同的需求,有不同的地方需要修改 - IPv6 Only VPS

接管出口 VPS IP AllowIPs Endpoint PostUp/PostDown
v4 v6 刪掉 ::/0 改成 v6 地址 不用加
v6 v6 刪掉 0.0.0.0/0 改成 v6 地址 加 v6 規則
v4+v6 v6 不用刪 改成 v6 地址 加 v6 規則

根據不同的需求,有不同的地方需要修改 - IPv4/IPv6 Dual Stack VPS

接管出口 VPS IP AllowedIPs Endpoint PostUp/PostDown
v4 v4+v6 刪掉 ::/0 不用改 加 v4 規則
v6 v4+v6 刪掉 0.0.0.0/0 不用改 加 v6 規則
v4+v6 v4+v6 不用刪 不用改 加 v4/v6 規則

复制配置文件并重启

1
2
3
cp wgcf-profile.conf /etc/wireguard/wgcf.conf
sudo systemctl enable wg-quick@wgcf
sudo systemctl start wg-quick@wgcf

测试

1
2
3
4
# IPv4 Only VPS
curl -6 ip.p3terx.com
# IPv6 Only VPS
curl -4 ip.p3terx.com

步骤

  1. 管理员模式的CMD中运行如下命令行来添加doh服务器

    阿里云doh:

    1
    netsh dns add encryption server=223.5.5.5 dohtemplate=https://223.5.5.5/dns-query autoupgrade=yes udpfallback=no

    腾讯doh

    1
    netsh dns add encryption server=1.12.12.12 dohtemplate=https://1.12.12.12/dns-query autoupgrade=yes udpfallback=no
  2. 添加后可以使用win+r,输入regedit在以下路径中查看到注册表已经添加了doh服务器

    计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers

    image-20220711175808392

  3. 使用WIFI 打开 设置 -> 网络和Internet -> WLAN,点击硬件属性,不是具体WiFi的属性,下一步

    使用网线打开 设置 -> 网络和Internet -> 以太网,下一步

    image-20220711180232871

  4. 在dns设置栏点击编辑,再输入刚刚添加的doh服务器的IP,并选择是否加密,完成!

image-20220711180447951

用途

使openvpn只代理指定的ip,而不是默认的全局代理

openvpn配置文件

关闭默认route:route-nopull

指定ip段进行代理:route 58.199.160.0 255.255.248.0 vpn_gateway

SHU-Student 修改后的配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
client
dev tun
proto tcp

route-nopull
route 58.199.160.0 255.255.248.0 vpn_gateway
route 202.120.112.0 255.255.248.0 vpn_gateway

<connection>
remote openvpn3.shu.edu.cn 443
</connection>

comp-lzo
resolv-retry infinite
nobind
persist-key
persist-tun
setenv CLIENT_CERT 0
auth-user-pass
remote-cert-tls server
verb 3

sndbuf 0
rcvbuf 0
mssfix 0
cipher none

<ca>
-----BEGIN CERTIFICATE-----
MIIEoTCCA4mgAwIBAgIJAMW52H83M9JAMA0GCSqGSIb3DQEBCwUAMIGRMQswCQYD
VQQGEwJDTjELMAkGA1UECBMCU0gxETAPBgNVBAcTCFNoYW5nSGFpMQwwCgYDVQQK
EwNTSFUxDDAKBgNVBAsTA1NIVTEPMA0GA1UEAxMGU0hVIENBMRAwDgYDVQQpEwdF
YXN5UlNBMSMwIQYJKoZIhvcNAQkBFhRyb2RkeTE5ODZAc2h1LmVkdS5jbjAeFw0x
NzA2MjEwOTQwMjlaFw0yNzA2MTkwOTQwMjlaMIGRMQswCQYDVQQGEwJDTjELMAkG
A1UECBMCU0gxETAPBgNVBAcTCFNoYW5nSGFpMQwwCgYDVQQKEwNTSFUxDDAKBgNV
BAsTA1NIVTEPMA0GA1UEAxMGU0hVIENBMRAwDgYDVQQpEwdFYXN5UlNBMSMwIQYJ
KoZIhvcNAQkBFhRyb2RkeTE5ODZAc2h1LmVkdS5jbjCCASIwDQYJKoZIhvcNAQEB
BQADggEPADCCAQoCggEBAJ17qOLBJgX7DKsBxVhqpfYkZcPwy8DggDiwRHNLLP3h
aEWRcS5NViqGthWh4mWvVkD9RypYlUywbYewoSkuLyllsFuw+iZUR93cWGMjccq/
9ZdhVPpYCGRJrtkTNeVtU9XTXEjZ3vWEwAMpOcVdhLQz6kxCVTt2qrB4ClhIAdPh
jaz5tusNlwVGzaM7EMIr3O08Y8gYlAe78tkD+18uCMYIyKPORs9H31UHbreLcONv
4Lc3dOz/g4KOQTkuwqcRnTJN1AVVfpjFUQeabyxFV/u4BkSvU33HWxLzYiyDGZkU
W8PLr1mouNEXWGHxfhooZb9wozk+jfuLYk3KhKh9+ZMCAwEAAaOB+TCB9jAdBgNV
HQ4EFgQU2sjeWJZf5o/1eL1Ke5PyE7K1nw4wgcYGA1UdIwSBvjCBu4AU2sjeWJZf
5o/1eL1Ke5PyE7K1nw6hgZekgZQwgZExCzAJBgNVBAYTAkNOMQswCQYDVQQIEwJT
SDERMA8GA1UEBxMIU2hhbmdIYWkxDDAKBgNVBAoTA1NIVTEMMAoGA1UECxMDU0hV
MQ8wDQYDVQQDEwZTSFUgQ0ExEDAOBgNVBCkTB0Vhc3lSU0ExIzAhBgkqhkiG9w0B
CQEWFHJvZGR5MTk4NkBzaHUuZWR1LmNuggkAxbnYfzcz0kAwDAYDVR0TBAUwAwEB
/zANBgkqhkiG9w0BAQsFAAOCAQEATqu24naX9L6jyzXt+mBJAS5IWr7gfh5Ymi7X
Tl+uSXS+H0w7VYqSGsrQsd17U9RfcAxglhGx2FtYvuYVWHQ4InaUjbrzxDrFO+ZG
rN471ASybovHR97rHfPOnqigAbDaKLynb8JoFYkzAxRAclPh/jZFXpG06KC+fkW/
ox+1WKF/6d5gXOZOTf0GuJi4JHRojDzb5p/Z6/8gxE9krVsQmfiR3HnaegyTVMle
KzpCQRuEx5rn/uDvV6joYCwy4q0BkQTKGBeUofR2ETlTeC7t6l+GKRPwCQ8BeBvL
e0+RSP6QWl/+flS0qdmtSswuZF98OqAuu6wW2PHXB3auUn77nw==
-----END CERTIFICATE-----
</ca>

用处

wsl2 获取外部ip 获取局域网ip 虚拟网卡

系统版本要求

Windows 10 Build 18362及更高版本或Windows 11

安装预览版WSL

应用商店搜索:windows subsystem for linux preview

windows可选功能中打开Hyper-V并重启

image

打开Hyper-V管理器 –> 虚拟交换机管理器 –> 新建虚拟交换机

image

关闭wsl

1
wsl --shutdown

修改.wslconfig配置文件:位于C:\Users\<用户名>\.wslconfig

1
2
3
[wsl2]
networkingMode=bridged
vmSwitch=替换成你创建的虚拟交换机名称

ROS使用注意事项

  • 远程连接可以rostopic list,但是rostopic echo /sometopic 没有内容:

    前提:两边的网络都要开放所有端口

    主机和从机都要在~/.bashrc中配置

    1
    2
    export ROS_IP='<ip>'
    export ROS_HOSTNAME='<hostname>'

    其中<ip>是本机IP,<hostname>在命令行中输入hostname查看。

    主机配置

    1
    export ROS_MASTER_URI=http://<MasterIP>:11311

    其中<MasterIP>是主机的IP。

    从机配置(注意!以下hostname不能直接用IP代替)

    1
    export ROS_MASTER_URI=http://<hostname>:11311

    其中<hostname>主机hostname

    除此之外从机还要在/etc/hosts中添加一条,把master的hostname解析成IP

    1
    2
    1.1.1.1       rosmaster
    <ip> <hostname>

有些国内网站走了代理,直接取消代理

V2rayN -> 设置 -> 参数设置 -> 系统代理设置

填入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
*.cn;
sys;
*.microsoft.com;
*.sharepoint.com;
*.live.com;
*.office.com;
*.windows.net;
*.windows.com;
*.onenote.com;
*.epicgames.com;
*.wandb.ai;
*.bilibili.com;
*.bilivideo.com;
*.chaoxing.com;
*.qq.com;

因为uwp应用有网络隔离,开v2ray会导致uwp应用无法联网,关闭网络隔离就行了

关闭

1
foreach ($n in (get-appxpackage).packagefamilyname) {checknetisolation loopbackexempt -a -n="$n"}

恢复

1
foreach ($n in (get-appxpackage).packagefamilyname) {checknetisolation loopbackexempt -d -n="$n"}

HEXO博客创建方法

安装nvm来安装node

1
2
3
4
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

nvm install v16.14.0

安装hexo

1
npm install -g hexo-cli

初始化项目

1
2
3
hexo init myBlog
cd myBlog
npm install

github配置ssh密钥让hexo能上传文件

1
2
3
密钥生成: ssh-keygen -t rsa -C 'github邮箱'

密钥路径:cat ~/.ssh/id_rsa.pub

配置 _config.yaml 文件

1
2
github库连接要使用ssh模式:
git@github.com:xixiha5230/xixiha5230.github.io.git

安装 hexo-deployer-git

1
npm install hexo-deployer-git --save

部署上传

1
hexo g -d

如果fatal: in unpopulated submodule '.deploy_git'报错直接

1
2
3
rm -rf .deploy_git
hexo g
hexo d

创建新的文章

1
hexo new '文章标题'

More info: 参考