【PVE】软路由在 PVE 中安装 OpenWrt

Posted by 西维蜀黍 on 2024-08-23, Last Modified on 2025-02-04

Build

# unzip
gunzip openwrt-23.05.4-x86-64-generic-squashfs-combined-efi.img.gz

Upload the .img to PVE

创建新的虚拟机

删掉磁盘

使用默认网络设置

导入镜像

选择宿主机,进入 Shell

# 注意 VM ID 104 (104是 虚拟机 ID) 和路径 以及镜像名称 , 最后又 local-lvm
qm importdisk 104  /var/lib/vz/template/iso/openwrt-23.05.5-x86-64-generic-ext4-combined-efi.img local-lvm
importing disk '/var/lib/vz/template/iso/openwrt-23.05.5-x86-64-generic-ext4-combined-efi.img' to VM 104 ...
  Rounding up size to full physical extent 124.00 MiB
  Logical volume "vm-104-disk-0" created.
transferred 0.0 B of 120.3 MiB (0.00%)
transferred 2.0 MiB of 120.3 MiB (1.66%)
transferred 4.0 MiB of 120.3 MiB (3.33%)
transferred 6.0 MiB of 120.3 MiB (4.99%)
transferred 8.0 MiB of 120.3 MiB (6.65%)
transferred 10.0 MiB of 120.3 MiB (8.31%)
transferred 12.0 MiB of 120.3 MiB (9.98%)
transferred 14.0 MiB of 120.3 MiB (11.64%)
transferred 16.0 MiB of 120.3 MiB (13.30%)
transferred 18.0 MiB of 120.3 MiB (14.96%)
transferred 20.0 MiB of 120.3 MiB (16.63%)
transferred 22.0 MiB of 120.3 MiB (18.29%)
transferred 24.0 MiB of 120.3 MiB (19.95%)
transferred 26.0 MiB of 120.3 MiB (21.62%)
transferred 28.0 MiB of 120.3 MiB (23.28%)
transferred 30.0 MiB of 120.3 MiB (24.94%)
transferred 32.0 MiB of 120.3 MiB (26.60%)
transferred 34.0 MiB of 120.3 MiB (28.27%)
transferred 36.0 MiB of 120.3 MiB (29.93%)
transferred 38.0 MiB of 120.3 MiB (31.59%)
transferred 40.0 MiB of 120.3 MiB (33.26%)
transferred 42.0 MiB of 120.3 MiB (34.92%)
transferred 44.0 MiB of 120.3 MiB (36.58%)
transferred 46.0 MiB of 120.3 MiB (38.24%)
transferred 48.0 MiB of 120.3 MiB (39.91%)
transferred 50.0 MiB of 120.3 MiB (41.57%)
transferred 52.0 MiB of 120.3 MiB (43.23%)
transferred 54.0 MiB of 120.3 MiB (44.89%)
transferred 56.0 MiB of 120.3 MiB (46.56%)
transferred 58.0 MiB of 120.3 MiB (48.22%)
transferred 60.0 MiB of 120.3 MiB (49.88%)
transferred 62.0 MiB of 120.3 MiB (51.55%)
transferred 64.0 MiB of 120.3 MiB (53.21%)
transferred 66.0 MiB of 120.3 MiB (54.87%)
transferred 68.0 MiB of 120.3 MiB (56.53%)
transferred 70.0 MiB of 120.3 MiB (58.20%)
transferred 72.0 MiB of 120.3 MiB (59.86%)
transferred 74.0 MiB of 120.3 MiB (61.52%)
transferred 76.0 MiB of 120.3 MiB (63.19%)
transferred 78.0 MiB of 120.3 MiB (64.85%)
transferred 80.0 MiB of 120.3 MiB (66.51%)
transferred 82.0 MiB of 120.3 MiB (68.17%)
transferred 84.0 MiB of 120.3 MiB (69.84%)
transferred 86.0 MiB of 120.3 MiB (71.50%)
transferred 88.0 MiB of 120.3 MiB (73.16%)
transferred 90.0 MiB of 120.3 MiB (74.82%)
transferred 92.0 MiB of 120.3 MiB (76.49%)
transferred 94.0 MiB of 120.3 MiB (78.15%)
transferred 96.0 MiB of 120.3 MiB (79.81%)
transferred 98.0 MiB of 120.3 MiB (81.48%)
transferred 100.0 MiB of 120.3 MiB (83.14%)
transferred 102.0 MiB of 120.3 MiB (84.80%)
transferred 104.0 MiB of 120.3 MiB (86.46%)
transferred 106.0 MiB of 120.3 MiB (88.13%)
transferred 108.0 MiB of 120.3 MiB (89.79%)
transferred 110.0 MiB of 120.3 MiB (91.45%)
transferred 112.0 MiB of 120.3 MiB (93.12%)
transferred 114.0 MiB of 120.3 MiB (94.78%)
transferred 116.0 MiB of 120.3 MiB (96.44%)
transferred 118.0 MiB of 120.3 MiB (98.10%)
transferred 120.0 MiB of 120.3 MiB (99.77%)
transferred 120.3 MiB of 120.3 MiB (100.00%)
transferred 120.3 MiB of 120.3 MiB (100.00%)
Successfully imported disk as 'unused0:local-lvm:vm-104-disk-0'

双击添加的磁盘,点击 "Add"

扩大容量

删掉 CD-ROM, 直接删没用 (不删也可以不重要完全不影响)

添加网络 (LAN, WAN 两个口肯定是最少要两张网卡)

然后查看当前系统的 USB 设备情况

$ lsusb
Bus 004 Device 004: ID 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
Bus 004 Device 003: ID 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 8087:0026 Intel Corp. AX201 Bluetooth
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

查询 USB 网卡对应网卡名,网卡名可以在 PVE 的网络菜单里找到:

Set NICs Pass Through

Install OpenWrt

Add a Disk for OpenWrt Img by selecting Add hard disk - Existing hard disk, and then select the vmdk

Reference