Can I use gparted to resize a Truecrypt-encrypted partition?

9,050

Solution 1

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.

Solution 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

Solution 3

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.

Share:
9,050

Related videos on Youtube

ash108
Author by

ash108

Updated on September 17, 2022

Comments

  • ash108
    ash108 over 1 year

    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.

  • KamikazeCZ
    KamikazeCZ almost 11 years
    Nice solution indeed! I'll just highlight: backup, backup, backup! There are some parts where this can go terribly wrong.
  • ash108
    ash108 almost 11 years
    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.
  • Dr. Koutheir Attouchi
    Dr. Koutheir Attouchi almost 3 years