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/sda
x
(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/chroot
mount --bind /dev /mnt/chroot/dev
mount --bind /proc /mnt/chroot/proc
mount --bind /sys /mnt/chroot/sys
mount --bind /tmp /mnt/chroot/tmp
chroot /mnt/chroot
mount -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=y
update-initramfs -u
update-grub
grub-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: Usability Tagged: General
Category:Next: Odd VirtualBox Audio Bug
Previous: Phoning Home