Encrypting whole device with LUKS
by someone_ from LinuxQuestions.org on (#6CA9M)
I have a block device called /dev/sdb, i want to know if it is possible to encrypt it completely, including the partition table.
I did
Code:$ cryptsetup luksFormat -y -v /dev/sdb
$ cryptsetup open /dev/sdb usbthen i created a new partition table, and partition with fdisk on /dev/mapper/usb
Code:Disk /dev/mapper/usb: 184 MiB, 192937984 bytes, 376832 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xca187b28
Device Boot Start End Sectors Size Id Type
/dev/mapper/usb-part1 2048 376831 374784 183M 83 LinuxBut the device fdisk is referring to does not exist
I was able to use the created partition by doing
Code:$ losetup /dev/loop0 /dev/sdb -o $(( 2048 * 512 ))and then using /dev/loop0 as the partition device, i want to know if there is a better way of doing this, or to make the kernel automatically create the new partition device.
I did
Code:$ cryptsetup luksFormat -y -v /dev/sdb
$ cryptsetup open /dev/sdb usbthen i created a new partition table, and partition with fdisk on /dev/mapper/usb
Code:Disk /dev/mapper/usb: 184 MiB, 192937984 bytes, 376832 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xca187b28
Device Boot Start End Sectors Size Id Type
/dev/mapper/usb-part1 2048 376831 374784 183M 83 LinuxBut the device fdisk is referring to does not exist
I was able to use the created partition by doing
Code:$ losetup /dev/loop0 /dev/sdb -o $(( 2048 * 512 ))and then using /dev/loop0 as the partition device, i want to know if there is a better way of doing this, or to make the kernel automatically create the new partition device.