raspberry pi 5 openwrt SD卡扩展可用分区,# 安装v2raya客户端 apk add v2raya luci-app-v2raya

raspberry pi 5 openwrt SD卡扩展可用分区

一、Raspberry Pi 5/500/CM5 OpenWrt 固件下载

https://firmware-selector.openwrt.org/

OpenWrt Firmware Selector

1、Raspberry Pi 5/500/CM5 特殊注意事项
硬件适配:四个固件均适用于 RPi 5、RPi 500(一体化键盘)和 CM5(计算模块),因三者核心均为 BCM2712 芯片。
启动要求:RPi 5 需更新至最新 Bootloader(2024-03-15 及以上)才能正常引导 OpenWrt。
存储建议:
1)、ext4 版:推荐使用 SSD(避免 SD 卡频繁写入损坏),适合作为主路由、存储大量日志 / 软件。
2)、squashfs 版:SD 卡或 SSD 均可,适合作为旁路由、轻量网关,追求稳定。
跨文件系统升级:不建议直接从 ext4 用 sysupgrade 刷 squashfs(或反之),可能导致配置不兼容,建议备份配置后全新安装。
2、选型建议(快速决策)
首次安装 → 选 factory 版(SD 卡 squashfs 版),(固态硬盘 ssdext4 版):
需大容量存储、频繁装软件 → ext4-factory
追求稳定、旁路由、易恢复 → squashfs-factory
已有 OpenWrt 升级 → 选 sysupgrade 版:
原系统是 ext4 → ext4-sysupgrade
原系统是 squashfs → squashfs-sysupgrade
旁路由场景(如你关注的树莓派旁路由配置) → 优先 squashfs-factory(稳定、抗断电、适合长期运行)。

具体场景(旁路由 / 主路由、存储介质、是否需要频繁装软件)给出明确的固件选择和对应的刷机 / 升级步骤

二、Raspberry Pi Imager  刷openwrt

Raspberry pi 5刷 openwrt

型号
Raspberry Pi 5/500/CM5
平台
bcm27xx/bcm2712
版本
25.12.2 (r32802-f505120278)

三、刷入openwrt成功,拓展SD卡空间致实际空间 sd卡16G 插入到raspberry pi 5 8g

openwrt默认IP地址:192.168.1.1 root 密码为空

1、web:192.168.1.1 连接配置上网,修改为:192.168.2.1

1)ssh更改IP 地址,主路由模式,暂不修改参考

1)、主路由模式(OpenWrt 直接拨号上网,最常用)
# 1. 修改 LAN 地址为 192.168.2.1
uci set network.lan.ipaddr='192.168.2.1'
uci set network.lan.netmask='255.255.255.0'

# 2. 保存配置
uci commit network

# 3. 重启网络生效(执行后 SSH 会断开)
/etc/init.d/network restart
2)、旁路由模式(OpenWrt 接在主路由后面)
# 1. 修改 LAN 地址
uci set network.lan.ipaddr='192.168.2.1'
uci set network.lan.netmask='255.255.255.0'

# 2. 设置主路由为网关(把 192.168.1.1 换成你主路由IP)
uci set network.lan.gateway='192.168.1.1'
uci set network.lan.dns='192.168.1.1'

# 3. 保存+重启
uci commit network
/etc/init.d/network restart

 

2)、web配置上网安装插件

 

2、默认ssh连接

ssh root@192.168.2.1

Connecting to 192.168.2.1:22…
Connection established.
To escape to local shell, press ‘Ctrl+Alt+]’.

WARNING! The remote SSH server rejected X11 forwarding request.

BusyBox v1.37.0 (2026-03-25 20:09:53 UTC) built-in shell (ash)

_______ ________ __
| |.—–.—–.—–.| | | |.—-.| |_
| – || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
—————————————————–
OpenWrt 25.12.2, r32802-f505120278 Dave’s Guitar
—————————————————–

=== WARNING! =====================================
There is no root password defined on this device!
Use the “passwd” command to set up a new password
in order to prevent unauthorized SSH logins.
————————————————–

OpenWrt recently switched to the “apk” package manager!

OPKG Command APK Equivalent Description
——————————————————————
opkg install <pkg> apk add <pkg> Install a package
opkg remove <pkg> apk del <pkg> Remove a package
opkg upgrade apk upgrade Upgrade all packages
opkg files <pkg> apk info -L <pkg> List package contents
opkg list-installed apk info List installed packages
opkg update apk update Update package lists
opkg search <pkg> apk search <pkg> Search for packages
——————————————————————

For more information visit:
https://openwrt.org/docs/guide-user/additional-software/opkg-to-apk-cheatsheet

3、apk update

root@OpenWrt:~# apk update
[https://downloads.openwrt.org/releases/25.12.2/targets/bcm27xx/bcm2712/packages/packages.adb]
[https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/base/packages.adb]
[https://downloads.openwrt.org/releases/25.12.2/targets/bcm27xx/bcm2712/kmods/6.12.74-1-c48576c95291bf2086b1569f64c9c7f0/packages.adb]
[https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/luci/packages.adb]
[https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/packages/packages.adb]
[https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/routing/packages.adb]
[https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/telephony/packages.adb]
[https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/video/packages.adb]
OK: 11058 distinct packages available

4、 apk add –no-cache fdisk resize2fs parted losetup

root@OpenWrt:~# apk add --no-cache fdisk resize2fs parted losetup
[fetch https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/packages/packages.adb]
OK: 23.3 MiB in 192 packages

5、扩展16Gsd卡空间!OpenWrt 25.12 把 `resize2fs` 做成了一个**完全独立的包**,就叫 `resize2fs`

root@OpenWrt:~# fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 14.84 GiB, 15938355200 bytes, 31129600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9655b5ec

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 8192 139263 131072 64M c W95 FAT32 (LBA)
/dev/mmcblk0p2 147456 31129599 30982144 14.8G 83 Linux

6、扩展fdisk 空间

#1.

fdisk -l /dev/mmcblk0

# 2. 进入fdisk分区工具
fdisk /dev/mmcblk0

# 3. 按以下顺序输入命令(每输入一行按回车):
p               # 打印分区表,确认第二个分区是/dev/mmcblk0p2,起始扇区是360448(和截图一致)
d               # 删除分区
2               # 选择第二个分区
n               # 新建分区
p               # 主分区
2               # 分区号2
147456     # 起始扇区(必须和原来的第二个分区起始扇区完全一致!特别注意:16GSD卡)
# 回车
N              # 直接按回车,使用所有剩余空间
w              # 保存分区表并退出

 

7、
partprobe /dev/mmcblk0

8、
reboot

root@OpenWrt:~# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.41.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.

Command (m for help): p

Disk /dev/mmcblk0: 14.84 GiB, 15938355200 bytes, 31129600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9655b5ec

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 8192 139263 131072 64M c W95 FAT32 (LBA)
/dev/mmcblk0p2 147456 31129599 30982144 14.8G 83 Linux

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-31129599, default 2048): 147456
Last sector, +/-sectors or +/-size{K,M,G,T,P} (147456-31129599, default 31129599):

Created a new partition 2 of type 'Linux' and of size 14.8 GiB.
Partition #2 contains a squashfs signature.

Do you want to remove the signature? [Y]es/[N]o: N

Command (m for help): w

The partition table has been altered.
Syncing disks.

root@OpenWrt:~# partprobe /dev/mmcblk0
root@OpenWrt:~# reboot

 

9、

root@OpenWrt:~# losetup -f /dev/mmcblk0p2
root@OpenWrt:~# losetup | grep mmcblk0p2
/dev/loop1 0 0 0 0 /dev/mmcblk0p2 0 512
/dev/loop0 0 5898240 1 0 /mmcblk0p2 0 512
root@OpenWrt:~# resize2fs /dev/loop0
resize2fs 1.47.3 (8-Jul-2025)
Filesystem at /dev/loop0 is mounted on /overlay; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 119
The filesystem on /dev/loop0 is now 15485312 (1k) blocks long.
10、
root@OpenWrt:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 5.8M 5.8M 0 100% /rom
tmpfs 3.9G 232.0K 3.9G 0% /tmp
/dev/loop0 13.9G 2.6M 13.3G 0% /overlay
overlayfs:/overlay 13.9G 2.6M 13.3G 0% /
/dev/mmcblk0p1 63.9M 15.0M 48.8M 24% /boot
tmpfs 512.0K 0 512.0K 0% /dev

====================================================================================

# 安装Trojan专用的v2raya客户端 apk add v2raya luci-app-v2raya

五、安装Trojan专用的v2raya客户端
1、
apk update && apk add v2raya luci-app-v2raya
2、
reboot
3、

ssh root@192.168.2.1
apk add v2raya luci-app-v2raya

上传geosite.date,geoip.dat两个文件到 /usr/share/xray

参考如下

root@OpenWrt:~# killall -9 apk
root@OpenWrt:~# rm -f /tmp/apk.lock
root@OpenWrt:~# rm -f /var/cache/apk/lock
root@OpenWrt:~# mount -o remount,rw /
root@OpenWrt:~# apk update
 [https://downloads.openwrt.org/releases/25.12.2/targets/bcm27xx/bcm2712/packages/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/base/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/targets/bcm27xx/bcm2712/kmods/6.12.74-1-c48576c95291bf2086b1569f64c9c7f0/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/luci/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/packages/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/routing/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/telephony/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/video/packages.adb]
OK: 11058 distinct packages available
root@OpenWrt:~# apk add v2raya luci-app-v2raya
ERROR: Unable to lock database: Resource temporarily unavailable
ERROR: Failed to open apk database: Resource temporarily unavailable
root@OpenWrt:~# killall -9 apk opkg 2>/dev/null
root@OpenWrt:~# find / -name "*apk.lock*" -o -name "*lock*apk*" | xargs rm -f 2>/dev/null
root@OpenWrt:~# mount -o remount,rw /
root@OpenWrt:~# rm -rf /var/cache/apk/*
root@OpenWrt:~# apk update && apk add v2raya luci-app-v2raya
 [https://downloads.openwrt.org/releases/25.12.2/targets/bcm27xx/bcm2712/packages/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/base/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/targets/bcm27xx/bcm2712/kmods/6.12.74-1-c48576c95291bf2086b1569f64c9c7f0/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/luci/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/packages/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/routing/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/telephony/packages.adb]
 [https://downloads.openwrt.org/releases/25.12.2/packages/aarch64_cortex-a76/video/packages.adb]
OK: 11058 distinct packages available
(1/5) Installing kmod-nf-tproxy (6.12.74-r1)
  Executing kmod-nf-tproxy-6.12.74-r1.post-install
(2/5) Installing kmod-nft-tproxy (6.12.74-r1)
  Executing kmod-nft-tproxy-6.12.74-r1.post-install
(3/5) Installing xray-core (26.2.6-r1)
 18% ##########################                                                                                                                   
  Executing xray-core-26.2.6-r1.post-install
(4/5) Installing v2raya (2.2.7.5-r1)
  Executing v2raya-2.2.7.5-r1.post-install
(5/5) Installing luci-app-v2raya (26.120.35050~a611522)
  Executing luci-app-v2raya-26.120.35050~a611522.post-install
OK: 77.2 MiB in 197 packages

 

五、有问题按以下方法处理

# 1. 强制杀死所有包管理进程 
killall -9 apk opkg 2>/dev/null 

# 2. 搜索并删除所有apk锁文件(全覆盖) 
find / -name "*apk.lock*" -o -name "*lock*apk*" | xargs rm -f 2>/dev/null

 # 3. 强制重新挂载系统为可读写模式 
mount -o remount,rw / 

# 4. 清理apk缓存 
rm -rf /var/cache/apk/* 

# 5. 最后尝试更新+安装 
apk update && apk add v2raya luci-app-v2raya

# 6.重启安装
reboot
apk add v2raya luci-app-v2raya

六、winscp 上传文件到openwrt

1、上传geosite.date,geoip.dat两个文件到 /usr/share/xray

2 web登录

192.168.1.1:2017

用户名steven_roc haixiao579@A

3、导入trojan

trojan://efe51121-4350-4872-a443-dbb61f488c77@v2ray.zhonjin.com:443?security=tls&insecure=0&allowInsecure=0&type=ws&host=v2ray.zhonjin.com&path=%2Fefe5dd21-4dd0-4872-a443-ddw466t25#dd-ws-v2ray.zhonjin.com

 

您可能还喜欢...

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注