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:

  1. fdisk /dev/sda
  2. x (select expert mode)
  3. f (to fix partition numbering)
  4. r (to return to the main menu)
  5. 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:

  1. Boot with a Live ISO of the same operating system.
  2. Elevate privileges.
  3. Create a mount point: mkdir /mnt/chroot.
  4. Unlock the LUKS partition: cryptsetup luksOpen /dev/sda8 sda8_crypt.
  5. mount /dev/mapper/sda8_crypt /mnt/chroot
  6. mount --bind /dev /mnt/chroot/dev
  7. mount --bind /proc /mnt/chroot/proc
  8. mount --bind /sys /mnt/chroot/sys
  9. mount --bind /tmp /mnt/chroot/tmp
  10. chroot /mnt/chroot
  11. 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:

  1. export CRYPTSETUP=y
  2. update-initramfs -u
  3. update-grub
  4. 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: Category: Usability Tagged: General

Next: Odd VirtualBox Audio Bug

Previous: Phoning Home