I’m afraid you cannot do this non-destructively without messing with lvm2
, and if you are new to GNU/Linux, then you definitely don’t want to go there.
However, what you can do is repurpose the Windows partition. And here’s how you do it…
< insert scary music here >
Reformat your Windows partition with ext4
─ you can do this by way of the partitioning tool. Then, use lsblk
in a terminal window to find out the UUID
of the newly formatted partition.
lsblk
Write down the
UUID
on a piece of paper…
… and keep in mind that GNU/Linux is case-sensitive. Make sure you get it all correctly!
Next, log out of your GUI environment completely.
When the login screen reappears, press Ctrl+Alt+F3 to switch to a tty
. Log in as yourself at the character-mode login prompt. Now issue the following command…
sudo systemctl isolate rescue.target
You will now be prompted to either enter the root password or press Ctrl+D to return. Enter the root password.
Note: Depending on what you chose when you installed the system, this may or may not be the same as your sudo
password. If it is different, then the root password is what you need, not the sudo
password.
After entering the root password, you are now in single-user maintenance mode, as the root user. Now issue the following command to temporarily mount the new partition into the tree…
mount -t ext4 /dev/nvme0n1p4 /mnt
Next, we’re going to copy over the entire content of /usr
into the new partition.
cp -RPpv /usr/* /mnt/
This is going to take some time, so sit back and let it finish. When it is done and the command prompt returns, verify that everything has been copied over correctly. Normally everything should have worked.
ls -l /mnt | less
Press q to exit the pager.
Next, you need to modify /etc/mkinitcpio.conf
.
nano /etc/mkinitcpio.conf
Look for the line that starts with HOOKS=
. Insert the word usr
behind the word udev
, with proper spacing, so that it reads something like…
HOOKS=(base udev usr autodetect modconf block keyboard keytable filesystems shutdown fsck)
… or similar enough to that. Remember, you only need to add the word usr
, as well as ─ at the end of the list of hooks ─ the words shutdown
and fsck
.
Save the file with Ctrl+O and exit the editor with Ctrl+X. Now rebuild your initramfs
…
mkinitcpio -P
Now, you must edit /etc/fstab
. We’ll use nano
again as the editor. Grab the piece of paper that you wrote that UUID
on earlier, and add a blank line underneath the line for your root filesystem, with the following content…
UUID=the-UUID-that-you-wrote-down /usr ext4 auto,ssd,noatime,defaults 0 0
If the mount options on your root partition differ from the mount options that I’ve given you here-above, then it’s safe to use those same mount options on the new partition as well. I’m only giving you a couple of generic ones for ext4
on a solid-state drive, but you may have additional ones for your root filesystem, and in that case they should be fine for use on the new /usr
partition as well .
When you’re done, save the file and exit the editor ─ you already know how to do that: Ctrl+O and Ctrl+X.
Now you can finish up, but you need to take a few extra steps in order to do it all cleanly. Enter the following commands, but only if everything you did so far was successful.
PATH=${PATH}:/mnt/bin
rm -rf /usr/*
update-grub
sync
systemctl reboot
Cross your fingers, but if you did everything right, then your system will come up fine again, and then your former Windows partition will now be mounted as /usr
, while all of the space that /usr
used to take up when it was still on the root filesystem will now be available again.
If everything went as planned, then you can pat yourself on the back for having pulled off a courageous maneuver, and for having done so without needing to chroot
from the live session of the install CD/USB. But never forget this very important advice from one of my fellow Middle-Earthers…