2

I have an external USB HDD (WD Elements). The entire drive is currently one large partition. Call it /dev/sda1. This partition was encrypted like this:

cryptsetup -v --type luks --cipher aes-xts-plain64 --hash sha512 --key-size 512 --use-random luksFormat /dev/sda1 --key-file /path/to/key

Then I created the BTRFS filesystem in it. (Note: I'm not using LVM.)

Now I have a need to reduce the size of that partition and create an NTFS partition on the USB HDD. (I'm actually doing this for a friend.)

I came across this article Resize an Encrypted Partition without Breaking your Linux System | by Timothy D Beach | Medium

That articles doesn't give me full confidence, so before starting I want to ask about potential pitfalls. What steps should I use to resize the partition and give me space for an NTFS partition?

I believe the NTFS partition cannot be encrypted if I want to share it between Windows and Linux, right?

EDIT: So far I completed this step:

mount /mnt/btrfsvolume
btrfs fi resize 1:-500G /mnt/btrfsvolume

EDIT 2:

Then I did these steps:

parted /dev/sda
(parted) print
  NOTE: shows end at 5001GB
(parted) resizepart 1 4505
(parted) print
(parted) quit

That should have given me 4 GB "margin of safety" because I reduced the filesystem by 500G and I reduced the partition by only 496G.

Everything seemed OK afterwards. The device could be decrypted and mounted, and I could read files on it. But I started getting strange system errors. For examples, if the drive is mounted, "pacman -Syu" fails with errors that are not logical. If I unmount the drive, I don't get any errors. (The errors are a long story, probably not worth adding to this thread because the problem is clearly the result of resizing the partition on the external device, not anything wrong with my system.)

8
  • 1
    As you mention /dev/sda1, I assume you have a partition table there. I believe the answer will be along the lines of first resizing the btrfs volume, then the luks volume, then the actual disk partition. If you're able to reduce all 3 "layers" you should get unused disk space to create a new partition (say /dev/sda2), which you should format as ntfs and see if Windows (or perhaps veracrypt) will be able to encrypt it. If I get the time I might write a proper answer, but I hope this can already help you somehow.
    – Zip
    Commented Nov 28, 2020 at 1:23
  • @Zip do you know how to resize the luks parition? I can probably figure out the other 2 layers.
    – MountainX
    Commented Nov 28, 2020 at 1:55
  • I believe you can find the answer here: unix.stackexchange.com/questions/460374/…
    – Zip
    Commented Nov 28, 2020 at 3:55
  • @Zip I'm not using LVM, as I said in my question.
    – MountainX
    Commented Nov 28, 2020 at 4:08
  • Have you scrubbed and btrfs check'ed (without repair) the btrfs filesystem? Commented Nov 28, 2020 at 12:02

0

You must log in to answer this question.

Browse other questions tagged .