Shrinking root partition to make space for Windows on a 250GB SSD


#1

Hi,
After installing Archlabs some time ago I forgot to leave enough space for Windows 10 on my SSD.
The ammount of unused space is too low currently so I need to shrink my root partition to free up some space.
I’ve done partition resizing on virtual machines before but I think this is my first time doing it on actual hardware and I’d like to do that without data loss and I want to be able to have a bootable system afterwards.
Honestly I’ve forgotten how procedure goes.
I would believe that this is done through the Live USB that I still have from the initial install of my system and from there through cfdisk?
Do I need to fiddle with fstab after the resizing?

This is my current lsblk output:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   1.8T  0 disk 
└─sda1   8:1    0   1.8T  0 part 
sdb      8:16   0 223.6G  0 disk 
├─sdb1   8:17   0     2G  0 part /boot
├─sdb2   8:18   0   180G  0 part /
└─sdb3   8:19   0    15G  0 part [SWAP]
sr0     11:0    1 407.1M  0 rom

Device sdb is my SSD that I want to work on and currently my root partition is 180GB.
I’d like to reduce it to 100GB and then use the unallocated space for my Windows install.
Currently I have 29GB of free space as seen from the gnome-disk-utility.

This is my fstab:

# /dev/sdb2
UUID=025e3784-84e8-4a5a-8f5a-69e0ca2274dd	/         	ext4      	rw,relatime	0 1

# /dev/sdb1
UUID=c3b56587-4320-4b1c-bae0-4323b225fde9	/boot     	ext4      	rw,relatime	0 2

# /dev/sdb3
UUID=f0b3096c-8bf2-4ed3-a540-59943f29dbee	none      	swap      	defaults,pri=-2	0 0

I will be dualbooting Archlabs and Windows 10.
I will provide you with any additional info that you may require by replying to you.

EDIT: forgot to add picture of the gnome-disk-utility


#2

I think cfdisk is probably a bit adventurous (and you would have to resize the filesystem beforehand to prevent data loss), I would use gparted instead — the grml ISO image includes that program and it is an excellent recovery image:

https://grml.org/

You will also have to delete the swap partition to make use of the freed up space because it’s in the way and then the UUID for the swap partition in /etc/fstab won’t match for the new swap partition (if you create one). Update the UUID in /etc/fstab by checking the output of blkid after creating the new swap partition.

As an aside, 15GiB of swap is rather a lot, do you really need that much? Also, a swap file would make things a lot easier in respect of partitioning and would also free up an extra partition.

Note that you will have to re-install the GRUB bootloader to the hard drive after installing Windows because it will take control of the boot process during the installation.

mount /dev/sdb2 /mnt
mount /dev/sdb1 /mnt/boot
arch-chroot /mnt
grub-install --target=i386-pc /dev/sdb
exit
reboot

^ Run those commands from the ArchLabs “live” image after installing Windows to get the GRUB menu back.

The other problem I can see is that I think Windows will refuse to install on anything but the “first” disk so it may use /dev/sda by default rather than /dev/sdb but this depends on whether /dev/sda is the main internal drive or not.

EDIT: corrected grub-install target drive, thanks OP.


#3

Oh wow, that sounds really scary in my opinion.
I better double check that before I hit install because I got invaluable data on that drive.
I got backups but that data must stay intact.

Thank you for taking your time and creating quite an in-depth guide.
I will attempt this tomorrow probably and I will keep this thread posted as I progress along.


#4

Not all windows versions do this, I remember installing W8 and it allowed picking which device and partition to use.


#5

I only have one drive on all my machines so I can’t say for sure if Windows will have issues installing on a second drive, I may in fact be mistaken about this but the OP can check before going ahead with the installation.


#6

If I remember well I had no issue resizing my root partition for windows.
But, just in case, I would backup my important files, I’ve seen windows installation screwing up Linux install in the past.

I’m wondering, why not install windows first and then Linux ? So far I’ve always done that and encountered no issue at all ^^


#7

Alright I booted grml from my USB and resized the root partition from there.
It all went without any difficulties.
It automatically read my hostname and named itself archlabs which I think is quite neat because I don’t know how it did it. (that’s a neat set of system rescue tools btw!)
This is my lsblk:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   1.8T  0 disk 
└─sda1   8:1    0   1.8T  0 part 
sdb      8:16   0 223.6G  0 disk 
├─sdb1   8:17   0     2G  0 part /boot
└─sdb2   8:18   0   100G  0 part /
sr0     11:0    1 407.1M  0 rom  

This is my fstab:

# /dev/sdb2
UUID=025e3784-84e8-4a5a-8f5a-69e0ca2274dd	/         	ext4      	rw,relatime	0 1

# /dev/sdb1
UUID=c3b56587-4320-4b1c-bae0-4323b225fde9	/boot     	ext4      	rw,relatime	0 2

# /dev/sdb3
#UUID=f0b3096c-8bf2-4ed3-a540-59943f29dbee	none      	swap      	defaults,pri=-2	0 0

I uncommented the line but didn’t delete it.
If I ever feel like creating a new Swap partition I can just use that template and change the UUID.
I might not need any swap with 16GB of Ram memory :smiley: .
I was really hitting the reefer when I installed this system and that shows :laughing:
Now all that there is left to do is install Windows on that unallocated space at the end of my drive and restore GRUB.

Will keep this thread posted.


#8

I followed your guide and got Windows installed successfully and I can see both boot options at Grub for Archlabs and for Windows.

I did one thing differently than your guide said.

Shouldn’t that be:

grub-install --target=i386-pc /dev/sdb

instead?

Anyways my system works as it should and I didn’t lose any data in the progress.
Thank you for your time.
I’ll mark the thread as solved.

Also you were right, kinda, Windows recommended me to install the OS to Disk 0 which is my HDD rather than Disk 1 which is my SSD.
Luckily It’s easy as just clicking on the correct drive and partition.


#9

Yes indeed, good catch, sorry about that.

Glad you got it sorted.