I am aware that similar questions have been asked before but I am a bit unsure about the particulars in my case.
As the title says, I’d like to resize and move around partitions, some of which are encrypted. More specifically I am running a dual-boot setup with Windows and Endeavour. I’d like to shrink the bitlocker encypted windows partition (I can do that from within windows) and subsequently move my linux partition right after it so there is now free space to the right. Subsequently I’d like to grow the linux partition to take up all the remaining space. My exact setup looks like this in GParted:
What worries me is the encryption involved and the dual-boot setup itself and I haven’t seen a case discussed yet, where all of that has to be taken into account.
What I think I could do is:
- shrink the bitlocker/ntfs-partition (/dev/sda3) in Windows. That should just work I guess.
- boot into a live system and run gparted there.
- move /dev/sda5 to the left so it is adjacent to the now shrinked /dev/sda3.
- resize /dev/sda5 to take up the remaining free space to the right of it
- reboot and be happy? (maybe resize the actual filesystem on /dev/sda5 or would GParted already take care of this?)
Not so sure about step 5. Will the preboot authentication still work? There is a password prompt for hd0,gp5. Only after that prompt do I see the actual GRUB menu. Will GRUB still work and let me boot both, Windows and Linux or does something need to be adjusted?
Am I missing any crucial steps (besides backing up important data…). I assume I don’t have to reinstall GRUB since I just move the partition which it is installed to, right?
Thank you in advance!
edit: success! summary below
I marked one post as the answer, but really - you should skim through everything for better understanding and useful hints!
So basically what I wrote above worked. But still, let me summarize:
- Backup everything that is dear to you if you haven’t already!
- I shrunk my Windows bitlocker partition from inside Windows. That was painless. However I could not use all the remaining free space for shrinking because of “unmovable files”. I was okay with that, but in case you wonder what to do, this should get you started. That can take a little while - be partient. After that I rebooted into Windows just to be sure everything still works - this is unnecessary though.
- I then booted into a live system. I used the latest Endeavour-ISO for that. Eventhough this isn’t strictly necessary, I backed up the LUKS header of the partition I was going to move/resize. Not sure if this is tremendously helpful in case things go south, but I thought it couldn’t hurt.
sudo cryptsetup luksHeaderBackup /dev/sda5 --header-backup-file /path/to/backupfile`
Be sure to adjust sda5 to whatever partition you are going to mess with.
After that, I installed gparted inside the live system. In case you mounted your partition, unmount it now. In order to move my partition to the left, I needed to lock/close it! That couldn’t be done with the partition unlocked. Then I let gparted do its job. Once again, this can take a while.
gparted finished successfully. There was a notice that read like this:
Maximize closed LUKS encryption skipped because it will automatically fill the partition when opened
You can skip to step 7. I rebooted into my locally installed Linux and everything worked! However the available free space on the filesystem didn’t change, eventhough the partition was grown properly. => back to the live system and gparted
Now unlock the freshly moved/grown partition, rightclick and choose “check”. This will ensure that all the newly freed space is indeed available. This is, what gparted did in my case:
grow encryption volume to fill the partition 00:00:00 ( SUCCESS )
cryptsetup -v resize 'sda5_crypt' 00:00:00 ( SUCCESS )
grow file system to fill the partition 00:00:07 ( SUCCESS )
resize2fs -p '/dev/mapper/sda5_crypt' 00:00:07 ( SUCCESS )
Resizing the filesystem on /dev/mapper/sda5_crypt to 28835328 (4k) blocks.
- Reboot into your Linux installation and enjoy your free space. I booted into Windows aswell - everything works. Thanks for all the help!
Some minor clarification about some of the stuff in the posts below: I said “something” gets loaded from the ESP (efi system partition) and so on. @dalto clarified that this something is grub. I was wondering how grub is supposed to know which parition to unlock - so in case you are wondering about the same thing: turns out that this information is “baked” into the efi-binary in /boot/efi/EFI/Boot/bootx64.efi, where /EFI/… is just the contents of your efi system partition mounted to /boot/efi. I stumbled across this here.
So thanks again everybody for your help.