Extending A LUKS Encrypted HDD To Utilize All Of The Drive (500 GB)
from irmadlad@lemmy.world to selfhosted@lemmy.world on 27 May 16:43
https://lemmy.world/post/47418211

Operation:

Never did this before on an encrypted drive. Is this the proper procedure? Obviously a complete image back up is in order, however, are there any gotchas, caveats, pitfalls that I should be aware of before proceeding?

#selfhosted

threaded - newest

themachine@lemmy.world on 27 May 16:53 next collapse

You can’t resize the filesystem without first resizing the crypted volume.

You would expand this LV. Expand the crypted volume. The decrypt the volume and expand the underlying filesystem.

irmadlad@lemmy.world on 27 May 16:57 collapse

hmmmm…I thought that the command sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv would extend the encrypted volume, and this command sudo resize2fs /dev/ubuntu-vg/ubuntu-lv would extend the filesystem.

themachine@lemmy.world on 27 May 17:04 collapse

I realize now i may have been confused as you didn’t specify everything.Is the LUKS volume created right on the disk on a raw partition?

irmadlad@lemmy.world on 27 May 17:30 collapse

Is the LUKS volume created right on the disk on a raw partition?

Yes. I’m sorry for the confusion and incomplete info. I’m flying a little blind here. The first two commands in the OP were to check what I have, and the last two were to extend the LUKS and then the filesystem.

i_am_not_a_robot@discuss.tchncs.de on 27 May 17:47 collapse

lv* commands are for LVM logical volumes. They’re not related to LUKS. Unless your LVM “physical” volume is on a LUKS encrypted device, you aren’t using LUKS. You’ll need to make the LUKS encrypted PV larger before you can grow your LV.

Unless your PV is already taking up the whole disk, in which case whether it is LUKS encrypted or not is irrelevant and the question you want to be asking is “how do I resize my LVM LV to fill the rest of my LVM PV?”, which is probably what the commands you have do.

themachine@lemmy.world on 27 May 17:03 next collapse

Edit: meant this to be a comment reply, not a post reply.

kat@lemmy.blehiscool.com on 27 May 17:09 collapse

Do a backup image of the partition first before you run these commands.

If you decide to use all free space: sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

Should suffice I’m pretty sure.

irmadlad@lemmy.world on 27 May 17:44 collapse

sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

As I understand (which is limited in this scenario) this command extends the LUKS and then you would have to follow up with sudo resize2fs /dev/ubuntu-vg/ubuntu-lv to extend the file system.