[systemd-devel] nspawn and Qemu compatibility?

Alison Chaiken alison at she-devel.com
Fri Apr 3 14:14:18 PDT 2015


I've been using Qemu to cross-compile packages and root filesystems
for a while and thought I'd try nspawn instead.    While I sometimes
want a full GUI desktop in the walled-off environment, mostly console
is enough, and for that nspawn sounds more efficient.

Here's the base sequence:

Install
==========
qemu-img create -f raw /opt/debian.raw 50G
qemu-system-x86_64  -machine accel=kvm --enable-kvm --cdrom
/opt/debian.iso -boot d -hda /opt/debian.raw -m 4096 -net
nic,model=e1000  -net user,hostfwd=tcp:127.0.0.1:6666-:22 -name debian
-localtime -no-reboot

Boot as Qemu
===============
qemu-system-x86_64 -enable-kvm -boot c -hda /opt/debian.raw -m 4096
-usb -net nic,model=e1000  -net user,hostfwd=tcp:127.0.0.1:6666-:22
-name debian -localtime -machine accel=kvm -chardev
spicevmc,id=charchannel1,name=vdagent -chardev pty,id=charconsole0
(inside Qemu) systemctl poweroff

Login with nspawn
===============
mount -t auto -o ro,loop,offset=1048576 /opt/debian.raw /mnt/loop
[offset moves past /boot partition to linux ext4]
systemd-nspawn -D /mnt/loop
exit
umount /mnt/loop

So far, all smiles.    However, when I try the same "Boot as Qemu"
instructions again, the kernel comes up, but then "Reading hard disk .
. . " appears, and then nothing.     So I guess that using
systemd-nspawn has somehow corrupted the filesystem, although I'm not
sure *why* that would happen.    Is there some reason that switching
between nspawn and Qemu should fail, or that nspawn would have a
problem with a loop mount?   Should I invoke nspawn differently?

Thanks,
Alison

-- 
Alison Chaiken                           alison at she-devel.com
650-279-5600
http://{she-devel.com,exerciseforthereader.org}
One consumes a great deal of silence in the course of becoming
educated. -- Matthew B. Crawford


More information about the systemd-devel mailing list