You are not logged in.

#1 2022-11-14 17:03:14

Registered: 2022-11-14
Posts: 1

Automatically creating loop-devices on boot

I need a loop device at login time as pam_mount (and its mount.crypt helper) needs a free loop device to mount a luks-encrypted file.
I followed the the wiki to setup pam_mount , the relevant line in /etc/security/pam_mount.conf.xml looks like:

<volume user="redforallp" fstype="crypt" path="/home/redforallp/sensitive.img" mountpoint="/mnt/sensitive" options="rw,fstype=ext4" /> 

After a reboot, the volume does not get mounted, a look in the journal shows that mount.crypt can't find a free loop device.

mount: could not find any free loop device

Once logged logged in,

 ls /dev/loop* 

only shows /dev/loop-control . True, There are no loop devices.
Running losetup -f as root creates a new one, but I want an automated way to do this...

Some Linux Distributions populate loop devices on boot by default, I wanted to reproduce that behavior.
I searched around but only found the rather cumbersome solution to create a systemd-service which runs after local-fs is reached:

File: /usr/lib/systemd/system/new-loop-device.service

Description=Create one loop device
ExecStart=losetup -f

This service simply executes "losetup -f" and exits, I don't like to have a service for that...
Also: invoking losetup -f is a indirect way to get a loop device, and re-running the service won't create a new loop device unless the old one gets used...

Somebody got a better idea ?


Board footer

Powered by FluxBB