![]() ![]() Then use the 'option' flag in the mount command, for example: mount -t iso9660 -o loop key is you want to make sure you FIRST use cryptsetup luksOpen containerfile mappedname to have it mounted to /dev/mapper/mappedname by default (you can give it a full path starting with / and it will mount there instead I believe, and THEN format the /dev/mapper/mappedname target and makes sure you are NOT touching the filecontainer directly, otherwise you are bypassing the encryption engine and just creating an unencrypted loopback file. Bruce, First, make sure you have the loopback module loaded, insmod loop, I believe. At this stage you need to tell mount explicitly which loop device to use. Saying Y here will allow you to use a regular file as a block device you can then create a file system on that block device and mount it just as you would. You could instead go crazy with loopdev=$(sudo losetup -f) mount -o loop, but letting cryptsetup handle it is WAY nicer. The following command creates an encrypted filesystem using the loop device 0. In the debug sudo losetup output, note the AUTOCLEAR = 1 for the filecontainer entry. ![]() Alternatively, use this combined format: mount -F hsfs -o ro lofiadm -a /path/to/image. Sudo mkfs -t ext4 /dev/mapper/filecontainer Mount the loopback device as a randomly accessible file system with mount -F hsfs -o ro /dev/lofi/X /mnt. Sudo cryptsetup luksOpen mypath/filecontainer filecontainer Sudo cryptsetup -y luksFormat mypath/filecontainer It's 2GB when it's empty, and it's 2GB when it's full. How can loopback devices be used Environment Red Hat Enterprise Linux Red Hat Enterprise Linux 6 Red Hat Enterprise Linux 5 Red Hat Enterprise Linux 4 Red Hat Enterprise Linux 3 Subscriber exclusive content A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more. mnt An empty directory to mount the msdos disk on. mount the loopback device to a directory: After writing the custom image onto the loopback device, it should be mounted onto a directory to make it accessible. They appear in the mount point directory. You need /dev/zero for ld-linux.so, /dev/hda to mount the msdos disk and /dev/loop for the lopback device. Mounting a file containing a file system via such a loop mount makes the files within that file system accessible. Sudo losetup # Debug for demonstration, not necessary in a real script Viewed 13k times 26 I know I can create and use a loopback device like this: Create the file truncate disk.img -size 2G Create a filesystem mkfs.ext4 disk.img Mount to use mount disk.img /mnt Clean up umount /mnt However in this case the disk image is fixed at 2GB. The mount and losetup programs for handling the DOS disk and setting up the loopback devices. ![]() Then as Vincent Yu stated cryptsetup can handle the loop setup/teardown for you. You can use dd or fallocate (or head or a few other tools) to create a file to act as your container. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |