lxc安装openwrt
借助搜索引擎可以发现openwrt.org上有篇wiki讲如何在lxc里安装openwrt,但文章内容有些问题,照搬并不能成功启动容器。这里简单贴一下实际可以进行的步骤。
首先创建虚拟网桥桥接物理网卡。编辑网卡配置文件后重启网络。
# cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto enp3s0
iface enp3s0 inet manual
auto br0
iface br0 inet static
bridge_ports enp3s0
address 192.168.1.100
gateway 192.168.1.1
netmask 255.255.255.0
dns-nameservers 192.168.1.1
安装需要的软件。apparmor可能不是必须项。
# apt install -y lxc apparmor
创建lxc文件夹和配置文件,并从openwrt.org下载对应架构rootfs文件解压到对应目录。
/var/lib/lxc/openwrt/
├── config
└── rootfs
├── bin
├── dev
├── etc
├── lib
├── lib64
├── mnt
├── overlay
├── proc
├── rom
├── root
├── sbin
├── sys
├── tmp
├── usr
├── var
└── www
编辑配置文件。
# cat /var/lib/lxc/openwrt/config
lxc.include = /etc/lxc/default.conf
lxc.include = /usr/share/lxc/config/common.conf
lxc.include = /usr/share/lxc/config/userns.conf
lxc.arch = linux64
lxc.apparmor.profile = unconfined
lxc.uts.name = omv.local
lxc.mount.auto = proc sys cgroup
lxc.start.auto = 1
lxc.net.0.type = veth
lxc.net.0.link = br0
lxc.rootfs.path = /var/lib/lxc/openwrt/rootfs
启动并进入容器。
# lxc-start -n openwrt && lxc-attach -n openwrt
增加自定义opkg源并安装插件。
# cat /etc/opkg/customfeeds.conf
# add your custom package feeds here
#
# src/gz example_feed_name http://www.example.com/path/to/files
src/gz base https://caoli5288.gitlab.io/openwrt_x86-64-packages/base
# opkg update && opkg install luci luci-app-ssr-plus