[systemd-devel] Requirements for successful mounting of RootImage?

Lennart Poettering lennart at poettering.net
Thu Aug 31 16:32:02 UTC 2017


On So, 20.08.17 13:20, Topi Miettinen (toiwoton at gmail.com) wrote:

> >> The file /fs has a MBR partition table:
> >> Disk /dev/loop0: 1.1 MiB, 1192960 bytes, 2330 sectors
> >> Units: sectors of 1 * 512 = 512 bytes
> >> Sector size (logical/physical): 512 bytes / 512 bytes
> >> I/O size (minimum/optimal): 512 bytes / 512 bytes
> >> Disklabel type: dos
> >> Disk identifier: 0x3990f3e6
> >>
> >> Device       Boot Start   End Sectors  Size Id Type
> >> /dev/loop0p1 *       34  2329    2296  1.1M 83 Linux
> > 
> > That should work. See if "systemd-nspawn -i" can get a shell in it. If
> > so, RootImage= should work too, it uses the same code.
> > 
> > Also, consider invoking /usr/lib/systemd/systemd-dissect on the image
> > file, it will tell you whether it can make sense of the image, and how
> > it would mount it.
> 
> # /lib/systemd/systemd-dissect /root.sqsh
> Found writable 'root' partition of type squashfs without verity
> (/dev/block/7:0)

Hmm, I figure we shouldn't claim "writable" here, given that it is
squashfs, which is r/o

> 
> >> Perhaps I miss some RootImage requirements? What exactly they are?
> > 
> > They are documented briefly in "systemd-nspawn's" --image= setting.
> 
> I tried systemd-nspawn with the image, but that also refuses. There's
> this error:
> # systemd-nspawn --image=/root.sqsh
> Spawning container root.sqsh on /root.sqsh.
> Press ^] three times within 1s to kill container.
> Timezone Europe/Helsinki does not exist in container, not updating
> container timezone.
> Failed to create /var/log: Read-only file system
> 
> It looks like the image is mounted read-only:
> 2427  mkdir("/tmp/nspawn-root-jlYu4k/var/log", 0755) = -1 EROFS
> (Read-only file system)

Yeah, it's squashfs, squashfs is read-only by definition...

If you are using a read-only image you need to populate /var properly,
or you --volatile= in some form... (which is similar to --tmpfs=/var...

> If I add "--tmpfs=/var" and move the mount_custom() call in nspawn.c
> between setup_seccomp() and setup_timezone(), there's no error and
> systemd-nspawn can mount the image and run the command. But it would be
> nice to understand why the image is mounted read-only in the first
> place.

squashfs...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list