安装解包工具
apt install squashfs-tools
解压openwrt包
gzip -d openwrt-x86-64-generic-squashfs-rootfs.img.gz
对得到的img进行解包
unsquashfs openwrt-x86-64-generic-squashfs-rootfs.img
.打包为pve的CT模板
cd squashfs-root tar zcf ../openwrt.rootfs.tar.gz
将openwrt.rootfs.tar.gz上传到/var/lib/vz/template/cache后,在PVE的WEB管理CT Templates里会出现此模板
安装pve lxc openwrt
pct create 201 local:vztmpl/openwrt.rootfs.tar.gz --rootfs local-lvm:0.5 --ostype unmanaged --hostname CTOpenWrt --arch amd64 --cores 2 --memory 512 --swap 0 -net0 bridge=vmbr0,name=eth0 -net1 bridge=vmbr1,name=eth1
修改op lxc配置文件
/etc/pve/lxc/"PVE-id".conf 脚本是201请自行修改
添加
lxc.mount.auto: cgroup:rw lxc.mount.auto: proc:rw lxc.mount.auto: sys:rw lxc.include: /usr/share/lxc/config/openwrt.common.conf lxc.cap.drop: sys_admin lxc.apparmor.profile: unconfined lxc.cgroup.devices.allow: c 108:0 rwm lxc.autodev: 1 lxc.cgroup.devices.allow: c 10:200 rwm lxc.hook.autodev: /var/lib/lxc/201/device_hook.sh lxc.mount.entry: tmp tmp tmpfs rw,nodev,relatime,mode=1777 0 0
-------------------------------------------------------------
添加文件 vi /var/lib/lxc/201/device_hook.sh
mknod /${LXC_ROOTFS_MOUNT}/dev/ppp c 108 0 mkdir -p ${LXC_ROOTFS_MOUNT}/dev/net mknod /${LXC_ROOTFS_MOUNT}/dev/net/tun c 10 200
设置权限
chmod + x /var/lib/lxc/201/device_hook.sh
发表评论