You are not logged in.
Pages: 1
Topic closed
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/keyThen I created the BTRFS filesystem in it.
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 here 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?
Last edited by MountainX (2020-11-27 23:00:03)
Offline
Your luks encrypted partitions and btrfs FS need to be treated separately.
First you need to resize your btrfs FS:
btrfs filesystem resize -30G /mnt/btrfsvolumeAfter that https://wiki.archlinux.org/index.php/Re … UKS_volume
I have never tried it myself, though this seems the right path maybe someone who has actually done this can confirm.
BTW resizing could take forever(read a long time...)
edit: for btrfs at least have a look at the man page 'man --pager='less -p resize' btrfs-filesystem'
Last edited by qinohe (2020-11-27 23:44:59)
Offline
I have never tried it myself, though this seems the right path maybe someone who has actually done this can confirm.
Thank you. I am trying it now, but taking my time to read the wiki and man page. I will check back here for other comments before I actually do the operation.
EDIT: BTW, I'm not use LVM.
Last edited by MountainX (2020-11-28 00:00:05)
Offline
Running into a problem now:
The Parted - ArchWiki page suggests
As of parted v4.2 resizepart may need the use of #Interactive mode.[2]
However, I'm running version 3.3-2 of parted:
(parted) version
GNU Parted 3.3I don't see a version 4:
Arch Linux - parted 3.3-2 (x86_64)
And I get this message:
Error: The resize command has been removed in parted 3.0Is there another package I should be using?
Last edited by MountainX (2020-11-28 00:13:47)
Offline
Yeah, sorry about that LVM cryptsetup resize wiki.
I think that version number should be '3.2'
(see) man --pager='less -p resizepart' parted
Offline
Yeah, sorry about that LVM cryptsetup resize wiki.
I think that version number should be '3.2'
(see) man --pager='less -p resizepart' parted
Oh! I thought the functionality had been removed. But it's just the command name is different. Thanks!
Offline
It looked straightforward, so I did these steps:
mount /mnt/btrfsvolume
btrfs fi resize 1:-500G /mnt/btrfsvolume
parted /dev/sda
print
NOTE: shows end at 5001GB
resizepart 1 4505
print
quitThat 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.)
Good thing I didn't need the data on that device because I'm pretty sure it can no longer be used.
Last edited by MountainX (2020-11-28 01:53:20)
Offline
Did you read the complete piece about resizepart in the manual?
That's why I explicitly pasted it;)
Offline
Did you read the complete piece about resizepart in the manual?
That's why I explicitly pasted it;)
Yes, I read it. Do you see something I missed?
Offline
Or I missed something, but
The resize command does not manipulate the size of underlying partition. If you wish to enlarge/reduce a
filesystem, you must make sure you can expand the partition before enlarging the filesystem and shrink
the partition after reducing the size of the filesystem. This can done using fdisk(8) or parted(8) to
delete the existing partition and recreate it with the new desired size. When recreating the partition
make sure to use the same starting partition offset as before.
Offline
Yes, I read that. I did the steps in the correct order.
Offline
Resizing encrypted partitions with logical volumes inside it can be tricky and error-prone. That's why I simulated the problem on a virtual machine the first time I tried it, just to make sure I understood the wiki completely. It took me a couple of tries to get it right before I was confident enough to do it on the actual encrypted partition.
Never argue with an idiot, they will drag you down to their level and then beat you with experience.
It is better to light a candle than curse the darkness.
A journey of a thousand miles begins with a single step.
Offline
Ah okay, well I think you did it like you should..
Too bad you have problems, try and figure out if they are solvable;)
Offline
Resizing encrypted partitions with logical volumes inside it can be tricky and error-prone. That's why I simulated the problem on a virtual machine the first time I tried it, just to make sure I understood the wiki completely. It took me a couple of tries to get it right before I was confident enough to do it on the actual encrypted partition.
Yes, tricky. I am working on a "test system". It's not the real laptop or the actual USB HDD that I need to resize. But my test system was in good working order before this. Now I think I need to recreate the filesystem on the USB HDD. I definitely will not be trying this on the actual system -- unless I learn exactly where I went wrong first.
Offline
Hello,
I have the same problem. Could you please give the steps if you have resolved your problem?
Thanks.
Offline
This thread is almost three years old, and the OP has not been back since July 2022. Please do not necrobump. Instead, start a new topic (which you can mark solved when you find a solution) and refer back to this one if you think it still applies.
Closing.
Offline
Pages: 1
Topic closed