You are not logged in.

#1 2021-11-24 18:54:08

ua4000
Member
Registered: 2015-10-14
Posts: 248

[SOLVED] mount cryptsetup loop file over *same* folder ?

I tested it already and it seems to works fine,
mounting a luks flle over the same folder where the loop file is:

sudo cryptsetup open /home/ua4000/123/luks2 m123
sudo mount /dev/mapper/m123 /home/ua4000/123

But is this safe, or can this damge the loop file ?
Or any disadvantage ? Did I miss anything ?

The real question is,
all examples I found for loopfiles, incl. Systemd-homed uses two different directories, one that holds the loop image file, and the other holds the target mountpoint:
https://wiki.archlinux.org/title/Systemd-homed
"The image path for the LUKS mechanism is set to /home/username.home. The directory path for the directory mechanism is set to /home/username.homedir."

So why not use the same folder ?
Having in /home/ua4000/luks2 the loop image and then open and mount it to /home/ua4000 ?

Thanks very much!

Last edited by ua4000 (2021-11-25 17:56:29)

Offline

#2 2021-11-24 19:28:00

frostschutz
Member
Registered: 2013-11-15
Posts: 1,090

Re: [SOLVED] mount cryptsetup loop file over *same* folder ?

Mounting works in layers, so its possible to hide files under mounts, and the hidden files will no longer be reachable (without extra steps).

It is "safe" in that it does not affect already open filehandles (files that have already been reached and opened before "hiding" them). So it won't damage or affect the loop device in any way.

But it is perhaps cumbersome / intransparent to use and might confuse some tools (and users). I'm not sure if systemd itself needs the file to be reachable for statistics and the like.

Last edited by frostschutz (2021-11-24 19:29:10)

Offline

#3 2021-11-25 17:56:15

ua4000
Member
Registered: 2015-10-14
Posts: 248

Re: [SOLVED] mount cryptsetup loop file over *same* folder ?

Thanks very much for the detailed answer!
I understood now why it works, and will test it on a real example. The advantage is, I have to store nothing outside my homedir, and after mounting it to homedir, I can be sure everything in it is encrpyted.

Offline

Board footer

Powered by FluxBB