本帖最后由 KDE 于 2022-5-14 20:05 编辑
OpenWrt 是一个路由器系统 资源占用很小 整个准系统大小也就几十MB而已
如果只是做网络通信 用这个足够了
体积小的系统可以直接DD 如果是那些几百兆的不能直接DD 体积大的要进内存救援系统mfslinux才能DD不然会出错
# 创建内存临时文件夹 mount -t tmpfs tmpfs /tmp/ cd /tmp
# 下载OpenWrt x86_64镜像 wget https://downloads.openwrt.org/releases/22.03.0-rc1/targets/x86/64/openwrt-22.03.0-rc1-x86-64-generic-ext4-combined.img.gz
# 解压 gzip -d openwrt-22.03.0-rc1-x86-64-generic-ext4-combined.img.gz
# 加载镜像 kpartx -av openwrt-22.03.0-rc1-x86-64-generic-ext4-combined.img
# 挂载镜像 mount /dev/mapper/loop0p2 /mnt
# 改SSH密码 (LUCI密码跟SSH一样) [root@localhost ~]# openssl passwd -1 www.hostloc.com $1$rsXLgwJ2$LHU.ix0C56QmY2TXwxYSt0
nano /mnt/etc/shadow root:$1$rsXLgwJ2$LHU.ix0C56QmY2TXwxYSt0::0:99999:7:::
# 设置网络连接(DHCP获取IPV4 IPV6) cat <<EOF> /mnt/etc/config/network config interface ‘loopback’ option device ‘lo’ option proto ‘static’ option ipaddr ‘127.0.0.1’ option netmask ‘255.0.0.0’
config interface ‘lan’ option device ‘eth0’ option proto ‘dhcp’
config interface ‘ipv6’ option device ‘eth0’ option proto ‘dhcpv6’ option reqaddress ‘try’ option reqprefix ‘auto’ EOF
# 设置网络连接(静态IPV4 IPV6地址 注意/24 /64这些CIDR代码要根据实际来定 可以小 但是不能大 CIDR代码要包含网关 ip addr show 看地址 ip -4 route 看V4网关 ip -6 route 看V6网关) cat <<EOF> /mnt/etc/config/network config interface ‘loopback’ option device ‘lo’ option proto ‘static’ option ipaddr ‘127.0.0.1’ option netmask ‘255.0.0.0’
config interface ‘lan’ option device ‘eth0’ option proto ‘static’ list ipaddr ‘IPV4地址/24‘ option ipgw ‘IPV4网关‘ list ip6addr ‘IPV6地址/64‘ option ip6gw ‘IPV6网关‘ list dns ‘2606:4700:4700::1111’ list dns ‘2606:4700:4700::1001’ list dns ‘1.1.1.1’ list dns ‘1.0.0.1’ EOF
# 强制取消挂载 umount -l /mnt
# 取消加载镜像 kpartx -d openwrt-22.03.0-rc1-x86-64-generic-ext4-combined.img
# 让文件系统只读 echo 1 > /proc/sys/kernel/sysrq echo u > /proc/sysrq-trigger
# DD dd if=/tmp/openwrt-22.03.0-rc1-x86-64-generic-ext4-combined.img of=/dev/实际硬盘位置 bs=4M status=progress
# 强制重启 echo 1 > /proc/sys/kernel/sysrq echo b > /proc/sysrq-trigger
|