4

I have an external drive with two partitions - one encrypted, the other not so. I'd like to move all the data to the encrypted partition, and then resize it to take up the whole drive.

If I use gparted on a truecrypt-encrypted partition, will that destroy the data?

Otherwise I have to decrypt, merge, resize and then re-encrypt.

4 Answers 4

4

Gparted only knows about physical disks - a Truecrypt parition won't even show up in Gparted, unless perhaps the whole partition has been specified as a Truecrypt partition. Certainly containers don't appear.

There is no way to resize an exisiting truecrypt parition (there was a convoluted method that worked prior to version 6.3, but it no longer works in recent versions).

I think your only option is to move your data to another volume, format your drive and Truecrypt it, then copy your data on to the newly created Truecrypt drive.

0
2

I am aware that this question is 2 years old now but there is a simple solution and others might ask the same question, so here is what I did:

  • copy all your data to the encrypted partition
  • overwrite the area where the partition will be resized into with random data. In your example you can just overwrite the now obsolete partition (cat /dev/urandom >/dev/oldpartition is slow so there are hints to use something like this: openssl enc -aes-128-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero | dd of=/dev/sdd obs=4096 input the correct sector size in the obs and make sure to use the correct device in the of-parameter. This is way faster than using /dev/urandom but no guarantees it is as secure.)
  • make a backup of the partition table using dd
  • delete the now obsolete partition using parted
  • umount the encrypted partition leaving the crypted container open
  • note down the starting sector of the partition you want to resize (first switch the units to sectors in parted using "unit s")
  • delete the partition you want to resize in parted (don't worry your data stays intact, only the partition table is edited)
  • create a partition having the exact same start-sector and the intended length
  • run cryptsetup resize on the opened crypt-container
  • resize your filesystem for ext4 use resize2fs /dev/mapper/crypt-container

=> you are done. Depending on your filesystem you can even re-mount your filesystem before resizing it

3
  • Nice solution indeed! I'll just highlight: backup, backup, backup! There are some parts where this can go terribly wrong.
    – KamikazeCZ
    Jun 10, 2013 at 22:49
  • 1
    That's a nice solution - thanks for bringing it up! For me, it'd be SUPER risky, and quite complicated to execute. If I'm backing up anyway due to the risk, I might as well just encrypt the whole drive and restore from the backup.
    – Jono
    Jun 11, 2013 at 9:30
  • This doesn't work: gitlab.com/cryptsetup/cryptsetup/-/issues/571 Jun 21, 2021 at 14:50
1

Assuming you created the Truecrypt volume by formatting it and not in-place encrypting the data, you can achieve you goal like this (gparted is not an option):

  • mount the encrypted partition
  • copy the whole data form the unencrpyted partition to the mounted Truecrypt volume
  • unmount the encrypted partition
  • use parted to alter the partition table (assuming MBR partition table layout)
    • delete the second/unencrypted partition
    • write down the start sector of the Truecrypt partition
    • delete the Truecrypt partition
    • create a new partition using the old start sector of the old Truecrypt partition and the last sector of the drive so that the partition spans the whole disk
  • use extcv in Windows with Truecrypt 7.1a installed to expand the Truecrypt volume within the new partition

A more detailed guide is available which will also explain what to do for in-place encrypted partition hosted volumes.

0

Last I heard support for encrypted partitions in GParted was being developed, but no working code had been released. As such, while you can probably get away with moving the partition, or possibly even allocating it more space (provided you stick the more space onto the end and not the beginning) There is no way for GParted to resize the filesystem inside it, so the additional space won't be usable. You might be able to add the space on, and then mount the partition and resize the FS from there, but I'm not sure. I will test it when I get some free time and post back if I can make it work.

Your best bet is probably to decrypt it, shuffle your data around, and re-encrypt it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .