1

I know I can just create a new and larger luksencrypted container and copy the contents from the previous luks container to the new one, but is there a way to enlarge a luks encrypted container (luks.img)?

I have seen several tutorials on stackexchange such as this: Extend a LUKS encrypted partition to fill disk

However, these are all for luks encrypted partitions, not containers.

3
  • 1
    Have you tried just making the file larger? It should work…? Commented Aug 31, 2024 at 7:50
  • what do you mean by making the file larger? like concatating another file to it, and then trying the same thing as the tutorial? Commented Sep 1, 2024 at 17:40
  • 1
    Thing is while cryptsetup will format and use files, it does not really help you at all in creating or managing them. So it's all up to you how you do it. There are many different ways to change a file's size; I usually do it with truncate --size but if you get the size wrong the data is gone... the example shown in Windigo's answer should be safer. And then you still have to resize whatever is encrypted inside the image. Commented Sep 1, 2024 at 18:02

1 Answer 1

2

Depending on what image file format your virtual disk is using, you will most likely need to use a disk utility to resize the virtual disk. Ideally, the same utility you used to create it in the first place.

If you used qemu-img to create the disk image, the command to increase your disk by 1GB would be:

qemu-img resize luks.img +1G

Since we are also talking about disk encryption, you should overwrite the new space with random noise before you expand the partition inside of LUKS to take advantage of the new space.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.