I want to mount a file, with ext4 filesystem, in a very unusual way. It works, but I wonder if I am breaking some rule.
I have a file, testdummy.ext4, in folder testdummy. I created a ext4 filesystem in it:
Code: Select all
# losetup /dev/loop2 testdummy/testdummy.ext4
# mke2fs -t ext4 -L "EASYSAVE" -m 0 -b 4096 -O encrypt /dev/loop2
# sync
# losetup -d /dev/loop2
To access the ext4 filesystem, I mounted it:
Code: Select all
# losetup /dev/loop2 testdummy/testdummy.ext4
# mount -t ext4 -o discard /dev/loop2 testdummy
So now the file testdummy.ext4 has disappeared:
Code: Select all
# ls testdummy
lost+found
#
It works, I can read and write files.
Although I cannot see testdummy.ext4 anymore, /dev/loop2 is still connected to it, so it works. I suppose that /dev/loop2 is connected to the inode of testdummy.ext4, not the path, which is why it continues to work.
If I unmount /dev/loop2, I can once again see testdummy/testdummy.ext4
I am just wondering if I am doing something that works "accidentally" and is not really supposed to be done?
Ignore those "-O encrypt" and "-o discard", that is not relevant.