Lab22.1 Loop devices - /etc/fstab entry
Hello,
maybe anyone can explain the behaviour of loop devices or point me to some literature in this regard.
Basically, when in /etc/fstab I use UUID for a loop device, my machine does not boot and I am put into the emergency mode.
However, when instead I use the full path to the file, the machine boots with no errors.
I am using Xubuntu 18.
/etc/fstab entry:
UUID=36ab310c-d1eb-4746-9456-9526a3a07552 /mnt/secret ext4 loop 1 2 [my machine won't boot and the journal shows:
mnt-secret.mount: Job mnt-secret.mount/start failed with result 'dependency'.
However, when I enter into /etc/fstab the below line, the machine boots up and the file is being mounted:
/home/aga/encrypted /mnt/secret ext4 loop 1 2
Output of df -Th
/dev/loop0 ext4 976M 4,4M 905M 1% /mnt/secret
For UUID I check sudo blkid
/dev/loop0: UUID="36ab310c-d1eb-4746-9456-9526a3a07552" TYPE="ext4"
losetup -a output
/dev/loop0: []: (/home/aga/encrypted)
file info:
encrypted: Linux rev 1.0 ext4 filesystem data, UUID=36ab310c-d1eb-4746-9456-9526a3a07552 (needs journal recovery) (extents) (64bit) (large files) (huge files)
So I am not sure, why I cannot use UUID in this situation.
Any ideas?
Thank you,
Aga
Comments
-
I would also be very grateful if anyone could instruct me how to set up an encrytpted partition on loop device PERSISTENTLY .
What exactly should be entered into the /etc/crypttab and /etc/fstab files?My understanding is that after every reboot loop device is lost and no longer attached to the file.
Therefore, my encrypted partition under /dev/mapper/secret-disk also ceases to exist and so cannot be mounted on boot.systemd[1]: Failed to start Cryptography Setup for secret-disk.
systemd[1]: Dependency failed for dev-mapper-secret\x2ddisk.device.
systemd[1]: Dependency failed for /secret.
systemd[1]: secret.mount: Job secret.mount/start failed with result 'dependency'.
systemd[1]: Dependency failed for File System Check on /dev/mapper/secret-disk.
systemd[1]: systemd-fsck@dev-mapper-secret\x2ddisk.service: Job systemd-fsck@dev-mapper-secret\x2ddisk.service/start failed with result 'dependency'.
systemd[1]: dev-mapper-secret\x2ddisk.device: Job dev-mapper-secret\x2ddisk.device/start failed with result 'dependency'.
systemd[1]: Starting Cryptography Setup for secret-disk...
systemd[1]: systemd-cryptsetup@secret\x2ddisk.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: systemd-cryptsetup@secret\x2ddisk.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Cryptography Setup for secret-diskCheers,
0 -
Hi,
I'm a kind of confused here because Lab 22.1 is about Disk Encryption, but your original question is about a loop device and using UUID on /etc/fstab .
Can you clarify, please?
Regards,
Luis.0 -
https://unix.stackexchange.com/questions/513979/mounting-loop-not-working-with-uuid
I believe this is correct -- I have never tried to mount a loopback device by uuid. How would the system know what it is? You have to mount the filesystem, then find the file etc.
As far as the encrypted partition being loaded persistently, I am not sure what the problem is as the instructions in the lab have been working for quite some time. Please read the instructions carefully, and please tell us exactly what distribution and version you are using etc.
0 -
I am able to follow the instruction and it works when a 'standard' partition is being used such as eg. /dev/sda4.
I am able to make an encrypted partition on a loop device and mount it, however, everything is lost after reboot. Hence, my question re /etc/fstab: what should be put there when we use a loop device for the encrypted partition.
When I reboot, I am put into the emergency mode and the encrypted partition is not mounted. For me, it seems that after the reboot /dev/mapper/secret-disk does not exist.
I am guessing that the loop device to which the encrypted partition is attached is lost after the reboot and that is why the encrypted partition fails to mount but I am not sure if my conclusion is correct.0 -
Ok, think about what you are trying to do. You can indeed mount a loopback device at boot if you are careful by doing something like:
/pathto/imagefile /place/tomount ext4 loop 0 0
to mount an ext4 loop back device at /place/tomount. Note that this has to be done after whatever partition the mount directory has already been mounted (so late in /etc/fstab) but even that is not guaranteed to work depending
on your system setup and distribution since parallel mounts can be allowed. (There is probably a more complicated way to avoid that I guess.) It will probably show up with *df" as /dev/loop0 on your system. And note the "loop" in the mount option.However if you wanted this to be encrypted, you would also have to update the /etc/crypttab entry and I don't feel inclined to figure that out at the moment, because I would never do things this way, and it is not an ext4 filesystem you want to look at anyway. If you are going to be prompted for a password at boot why do it this way?
Whenever I have done this sort of thing, I have a a very short lines script (maybe two lines) that can be executed at boot (using systemd would be best) or even better just at the command line. It is pretty useless having an encrypted filesystem that anyone can see at boot without supplying a password. It doesn't seem useful to me except as an academic challenge question. If the whole system is encrypted why bother encrypting the loopback file?
0 -
Maybe I can help clarify a little:
Can I use a UUID to mount a loop device in fstab?
NOPE. Use the file that contains the file system.
like:
\home\lee\loop.img \home\lee\loopy ext4 loop 0 0Can I use a loop device as the locked encrypted device?
Yes but not with fstab. The crytptab file is read before the mount and the loop device doesn't exist yet, so it fails.
Why does this work with partitions like "/dev/sda6" ? When the crypttab file is processed it locates the "block device" and attempts a "luksOpen" on the device and registers the "unlocked"device with portmapper. The crypttab file is the connection between the encrypted block device an portmapper name.The information (filesystem) on the loop.image file and the unencrypted partition is not lost, the components just need reassembly.
Is this a limitation/bug?
No, not really. We use the loop devices in class to reduce the requirement of "un-partitioned" space on the disks and loop devices work well for learning and experimenting. There is a more complex answer as to "how to make it work" involving systemd-generate and pre-executions scripts in the boot/mount sequence but I would not recommend it.If you are using loop devices because you are out of disk space, try using a USB key as an additional disk.
Lee
4 -
The explanation of Lee is great!
I was researching and I found that cryptsetup (and then dm-crypt) doesn't like loop devices. From man cryptsetup(8):
'In addition, cryptsetup provides limited support for the use of loop-AES volumes and for TrueCrypt compatible volumes'.
I think you need to ask yourself 'why do I want to encrypt a loop device?' and 'why do I want to make it permanent?'. So, loop devices -as Lee said- have been used for testing purposes, as it's easier to make a loop device than make free space in the local storage.
Also, as Coop mentioned, there are some prerequisites that could be difficult to achieve. But it's also a good change to learn and to challenge yourself
Regards,
Luis.0 -
Thank you all for your explanation.
I was trying to use a loop device as I did not have any spare partition and the instruction indicated that a loop device can be used.
I have learnt a lot.
Thanks again2 -
Hi @agnieszka ,
Ok, I see now. Well, we all continue learning, and it's ok to try to do things that are more complex than others. As you said, you learnt a lot in the process, and that's awesome.
Regards,
Luis.0 -
Can I use a loop device as the locked encrypted device?
Yes but not with fstab. The crytptab file is read before the mount and the loop device doesn't exist yet, so it fails.
Why does this work with partitions like "/dev/sda6" ? When the crypttab file is processed it locates the "block device" and attempts a "luksOpen" on the device and registers the "unlocked" device with portmapper. The crypttab file is the connection between the encrypted block device an portmapper name.Lee
Thank's a lot for your explanation.
0
Categories
- All Categories
- 167 LFX Mentorship
- 219 LFX Mentorship: Linux Kernel
- 795 Linux Foundation IT Professional Programs
- 355 Cloud Engineer IT Professional Program
- 179 Advanced Cloud Engineer IT Professional Program
- 82 DevOps Engineer IT Professional Program
- 127 Cloud Native Developer IT Professional Program
- 112 Express Training Courses
- 112 Express Courses - Discussion Forum
- 6.2K Training Courses
- 48 LFC110 Class Forum - Discontinued
- 17 LFC131 Class Forum
- 35 LFD102 Class Forum
- 227 LFD103 Class Forum
- 14 LFD110 Class Forum
- 39 LFD121 Class Forum
- 15 LFD133 Class Forum
- 7 LFD134 Class Forum
- 17 LFD137 Class Forum
- 63 LFD201 Class Forum
- 3 LFD210 Class Forum
- 5 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 1 LFD233 Class Forum
- 2 LFD237 Class Forum
- 23 LFD254 Class Forum
- 697 LFD259 Class Forum
- 109 LFD272 Class Forum
- 3 LFD272-JP クラス フォーラム
- 10 LFD273 Class Forum
- 152 LFS101 Class Forum
- 1 LFS111 Class Forum
- 1 LFS112 Class Forum
- 1 LFS116 Class Forum
- 1 LFS118 Class Forum
- LFS120 Class Forum
- 7 LFS142 Class Forum
- 7 LFS144 Class Forum
- 3 LFS145 Class Forum
- 1 LFS146 Class Forum
- 3 LFS147 Class Forum
- 1 LFS148 Class Forum
- 15 LFS151 Class Forum
- 1 LFS157 Class Forum
- 33 LFS158 Class Forum
- 8 LFS162 Class Forum
- 1 LFS166 Class Forum
- 1 LFS167 Class Forum
- 3 LFS170 Class Forum
- 2 LFS171 Class Forum
- 1 LFS178 Class Forum
- 1 LFS180 Class Forum
- 1 LFS182 Class Forum
- 1 LFS183 Class Forum
- 29 LFS200 Class Forum
- 736 LFS201 Class Forum - Discontinued
- 2 LFS201-JP クラス フォーラム
- 14 LFS203 Class Forum
- 102 LFS207 Class Forum
- 1 LFS207-DE-Klassenforum
- 1 LFS207-JP クラス フォーラム
- 301 LFS211 Class Forum
- 55 LFS216 Class Forum
- 48 LFS241 Class Forum
- 42 LFS242 Class Forum
- 37 LFS243 Class Forum
- 15 LFS244 Class Forum
- LFS245 Class Forum
- LFS246 Class Forum
- 50 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 154 LFS253 Class Forum
- LFS254 Class Forum
- LFS255 Class Forum
- 5 LFS256 Class Forum
- 1 LFS257 Class Forum
- 1.3K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 111 LFS260 Class Forum
- 159 LFS261 Class Forum
- 41 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 20 LFS267 Class Forum
- 24 LFS268 Class Forum
- 29 LFS269 Class Forum
- 1 LFS270 Class Forum
- 199 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- 3 LFS281 Class Forum
- 9 LFW111 Class Forum
- 260 LFW211 Class Forum
- 182 LFW212 Class Forum
- 13 SKF100 Class Forum
- 1 SKF200 Class Forum
- 1 SKF201 Class Forum
- 782 Hardware
- 198 Drivers
- 68 I/O Devices
- 37 Monitors
- 96 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 83 Storage
- 743 Linux Distributions
- 80 Debian
- 67 Fedora
- 15 Linux Mint
- 13 Mageia
- 23 openSUSE
- 143 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 348 Ubuntu
- 461 Linux System Administration
- 39 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 90 Linux Security
- 77 Network Management
- 101 System Management
- 46 Web Management
- 64 Mobile Computing
- 17 Android
- 34 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 371 Off Topic
- 114 Introductions
- 174 Small Talk
- 19 Study Material
- 507 Programming and Development
- 285 Kernel Development
- 204 Software Development
- 1.8K Software
- 211 Applications
- 180 Command Line
- 3 Compiling/Installing
- 405 Games
- 309 Installation
- 97 All In Program
- 97 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)