2

As mentioned I bought myself a bigger hard drive (1TB to 2TB, keeping my old one for backups). I dd the small one to the big one so I have all my data on my new drive. The only issue I have that 1TB of now unallocated space. Can I extend /dev/sda3 so it becomes ~2TB? or due to /dev/sda3 being encrypted is it not an option? The encryption, by the way, was done during the installation of the OS (Linux Mint 18.x).

shmink
  • 43
  • 1
  • 10

2 Answers2

2

I found this walk through on the Ubuntu website

https://help.ubuntu.com/community/ResizeEncryptedPartitions

Ctrl-F for "Enlarging an encrypted partition"

(Just copying and pasting so you don't have to click again, but there are some warnings on the actual ubuntu web page)


  1. Boot a live CD and, using any tool, using any tool create a new partition, lets call it /dev/sda6 , next to and to the left of (after) your crypt.

  2. Write random data to the new partition with dd.

    Make sure you have the correct partition for this command or you will overwrite your crypt.

sudo dd if=/dev/urandom of=/dev/sda6

IconsPage/tip.png You can run that command as many times as your paranoia requires.
  1. Use fdisk as above to delete and then re-create a larger crypt partition.

  2. Reboot to the live CD.

  3. Install lvm2 and cryptsetup

sudo apt-get update && sudo apt-get install lvm2 cryptsetup

  1. Load the cryptsetup module.

sudo modprobe dm-crypt

  1. Decrypt your file system.

sudo cryptsetup luksOpen /dev/sda5 crypt1

  1. Get the live CD to recognize (activate) your LVM.

sudo vgscan --mknodes sudo vgchange -ay

  1. Resize the Crypt.

sudo cryptsetup resize crypt1

  1. Resize the (LVM) Physical Volume.

sudo pvresize /dev/mapper/crypt1

  1. Resize your root (LVM) Logical Volume.

    Unlock the (LVM) Physical Volume.

    sudo pvchange -x y /dev/mapper/crypt1

    Resize the (LVM) Physical Volume.

    sudo lvresize -l +4G /dev/ubuntu-vg/root

    Note: Change the +4G to the amount of space you are adding, or +100%FREE to use all of the available space. 
    

    Re-lock the physical volume.

    sudo pvchange -x n /dev/mapper/crypt1

  2. Resize the filesystem.

sudo e2fsck -f /dev/mapper/ubuntu--vg-root sudo resize2fs -p /dev/mapper/ubuntu--vg-root

0

Whilst @mathew-gunther answer is the facutal answer and ultimatley the more accurate guide I found it convoluted due to the way Ubuntu had laid it out. I found the following answer to be easier to follow and ultimatley got what I wanted.

https://askubuntu.com/questions/747073/how-to-expand-an-encrypted-ubuntu-partition-with-lvm

shmink
  • 43
  • 1
  • 10