Moving a LUKS Partition
I had three operating systems installed on my laptop. I no longer wanted one of the operating systems. The respective partitions were in between the two operating system I wanted to retain.
I wanted to delete partitions /dev/sda7 and /dev/sda8. Partitions /dev/sda9 and /dev/sda10 would be moved and renumbered respectively.
I booted to the primary operating system and deleted the unwanted partitions.
I renumbered the partition order:
fdisk /dev/sdax(select expert mode)f(to fix partition numbering)r(to return to the main menu)w(to write changes)
I rebooted to verify the correct partition order.
I used gparted to move the outer partitions into the newly freed space.
I needed to modify the outer operating system system. Partition /dev/sda10 is encrypted. There is a pecking order to perform the necessary steps. A chroot environment is needed. I performed the following:
- Boot with a Live ISO of the same operating system.
- Elevate privileges.
- Create a mount point:
mkdir /mnt/chroot. - Unlock the LUKS partition:
cryptsetup luksOpen /dev/sda8 sda8_crypt. mount /dev/mapper/sda8_crypt /mnt/chrootmount --bind /dev /mnt/chroot/devmount --bind /proc /mnt/chroot/procmount --bind /sys /mnt/chroot/sysmount --bind /tmp /mnt/chroot/tmpchroot /mnt/chrootmount -a
I edited config files to match the partition movement and renumbering. This required only changing references of sda10 to sda8 in the following files:
/etc/crypttab/etc/fstab/etc/initramfs-tools/conf.d/cryptroot
I ran the following commands:
export CRYPTSETUP=yupdate-initramfs -uupdate-grubgrub-install /dev/sda7 --force
I rebooted into the other operating system. The LUKS partition mounted to /dev/mapper/sda8_crypt. There were no boot issues.
Posted: Category: Usability Tagged: General
Next: Odd VirtualBox Audio Bug
Previous: Phoning Home
