[systemd-devel] How to handle loop mounts?

Lennart Poettering lennart at poettering.net
Wed Aug 8 09:10:27 PDT 2012


On Wed, 08.08.12 09:52, Eelco Dolstra (eelco.dolstra at logicblox.com) wrote:

> 
> Hi,
> 
> On 08/08/12 08:24, Mike Kazantsev wrote:
> 
> >> I have an /etc/fstab that contains the following line:
> >>
> >>   /disk1.img /disk1 ext4 loop 0 2
> >>
> >> where /disk1.img is a regular file containing an ext4 filesystem.  Systemd fails
> >> to mount /disk1 if I run "systemctl start disk1.mount":
> >>
> > ...
> > 
> > Same thing seem to work here:
> > 
> >   dd if=/dev/zero of=looptest bs=1M count=100 
> >   losetup /dev/loop0 looptest
> >   mkfs.ext4 /dev/loop0
> >   losetup -D
> >   echo '/root/looptest /mnt/tmp ext4 loop' >>/etc/fstab
> 
> Ah!  This did work.  It turns out that the problem is actually caused by having
> a non-zero fs_passno field in /etc/fstab.  I.e.
> 
>   /disk1.img /disk1 ext4 loop 0 0
> 
> works, while
> 
>   /disk1.img /disk1 ext4 loop 0 2
> 
> hangs because systemd adds a dependency on systemd-fsck at disk1.img.service, which
> in turn has a dependency on the non-existent disk1.img.device.

Hmm, so there is a fundamental problem here. The mount command is what
creates the loopback device and what then eventually does the mount, but
it is systemd that would need to do the fsck in between. This can't
work. Also, the loop device name is undefined, since this takes the
first free device available, which means the name is completely
undefined and hence we have a hard time creating the right dependencies
for it.

Not sure what we can do about this. We probably have to implement proper
loopback support inside of systemd, so that we set up the loopback
device on our own, so that we can order the fsck between that and the
actual mount, but that's not trivial to do and needs some care to be
taken. Umm...

I have added this to the TODO list now.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list