[systemd-devel] How to handle loop mounts?
Eelco Dolstra
eelco.dolstra at logicblox.com
Wed Aug 8 06:52:16 PDT 2012
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.
Now for this ext4 example I can live without running fsck, but in general loop
filesystems may require fsck. Any ideas on how to fix this?
Also, there doesn't seem to be a workaround for using loop devices with
crypttab. Example:
$ dd if=/dev/zero of=/disk2.img bs=1M count=100
$ cryptsetup luksFormat /disk2.img
...
$ echo 'crypted /disk2.img - timeout=60' > /etc/crypttab
$ systemctl daemon-reload
$ systemctl start cryptsetup.target
(hangs)
$ systemctl list-jobs --full
JOB UNIT TYPE STATE
8534 cryptsetup.target start waiting
8535 systemd-cryptsetup at crypted.service start waiting
8538 disk2.img.device start running
8539 dev-mapper-crypted.device start running
$ journalctl
...
Aug 08 15:33:51 machine systemd[1]: Job disk2.img.device/start timed out.
Aug 08 15:33:51 machine systemd[1]: Job cryptsetup.target/start failed with
result 'dependency'.
...
(I'm running systemd 187 BTW.)
--
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/
More information about the systemd-devel
mailing list