在Centos7上运行systemd-nspawn
这是2017年systemd-nspawn附属的Advent Calendar活动的第23日文章。
我来试试在Centos7上运行systemd-nspawn,但实际上几乎和Ubuntu等一样。所以只有一些差异而已。
网络周围
我已经切换到了systemd-networkd。
systemctl disable network
systemctl disable NetworkManager
yum install bridge-utils systemd-networkd
systemctl enable systemd-networkd
准备容器
wget https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1503.raw.xz
xz -d CentOS-7-x86_64-GenericCloud-1503.raw.xz
# パーティションの開始位置を確認
fdisk CentOS-7-x86_64-GenericCloud-1503.raw
# mountしてコピー
losetup -o 1048576 /dev/loop0 ./CentOS-7-x86_64-GenericCloud-1503.raw
mount /dev/loop0 /mnt/
rsync -a --numeric-ids /mnt/ /var/lib/machines/centos7/
之后按照平常的步骤启动了。