Originally Posted by
cAlpha
Not looking for another place to keep files, looking for extra space for the base Ubuntu installation.
First - I don't know if you were just lucky or made a smart choice, but excellent that the HDD partitioning is using GPT. That provides options and simplifies things that the old 1984 MBR/MSDOS partitioning method would vastly complicate. MSDOS partitioning almost always means dealing with Logical Partitions inside an Extended Partition. With GPT that stuff doesn't exist and we can simply create partitions - I think 128 are allowed. This can be very handy.
There are lots of options, but none are easy or without great risk.
Shifting a partition has risks and takes a very long time. I did it once and would never, ever, ever, do it again.
If you had installed with LVM (it is a checkbox in most installers), making use of the extra storage wouldn't be very hard. LVM == Logical Volume Management. You can look what it can do up on wikipedia or 500 different websites. It is more complex than "simple partitions." Also, at install time, it takes expert level control to setup on a dual-boot system.
The way that I deal with dual-boot - is that I don't. I put Windows inside a virtual machine and let the more advanced OS control all the hardware.
There are other options too. Like you could probably copy the 40G partition into the start of the 140G space, then setup the boot stuff to point to that other partition and delete the old 40G partition. That will oddly be faster than shifting, but it will entail manually doing some things that the installers handle automatically. Expect to manually edit the /etc/fstab file. It isn't hard, but it is extremely detailed work. If you get anything wrong in doing that, forgetaboutit.
What I would do is 2 things.
0) Create a full backup of everything on the system that you cannot lose. This is all very dangerous stuff.
1) Create 3 new partitions from the start of the free space. Use gparted. Give each a unique LABEL. UNUSED01, SWAP01, HOME01
2) The first will be a placeholder that we'll delete when done. Make it 20G. It will be emergency space that your Windows can grow into if you out grow it, just a little. Expanding to the "right" is easy. Expanding to the "left" is very, very, hard. This 20G will be a little reminder that you need to buy a new HDD, should you expand into it. Do not format it.
3) Remove the swap file from the main Linux partition (swapoff) and create a swap partition - 4.1G in size. Put that in the unused space, far "left" after the 20G free space. You can look up how to accomplish that. Format it as "Linux Swap" - LABEL = SWAP01
4) Create a new partition to hold /home. Make it the size you think you'll need, but do not allocate all the space. Leave room to grow to the "right." Maybe start with 30G. Format it as ext4. - LABEL = HOME01
After changing all this, reboot and see the new "names" for the partitions. If you can, reboot into a Try Ubuntu environment off a flash USB drive. This will make things easier for the next steps. Ubuntu, Xubuntu, Lubuntu, ... whatever ... it doesn't matter. Just make it the same release that you have installed.
The next steps are to tell the Ubuntu OS where this new storage is, how to mount it (/etc/fstab) and copy files from the OLD /home over to the new /home/ while both are mounted to .... somewhere else. I'd create 2 directories - /mnt/old and /mnt/new, then mount the old / to /mnt/old and the new 30G partition we created above as ext4, to /mnt/new. Then I'd use sudo mv /mnt/old/home/* /mnt/new/ Note the exact levels of the FROM and TO commands. The mv command is destructive, so if you get it wrong (or I made a mistake), it won't be good. You cannot use a GUI and copy/paste stuff. That will break things and doesn't provide the control over details that is needed.
After that move is done, we need to mount the home and swap partitions. It would be smart to use either a LABEL= or UUID= instead of the device name. Use the blkid command to get the mapping between the device name and the LABEL/UUID. Remember those labels we put on each partition? Those will come in handy now. Labels are must easier for humans than UUIDs. You can use either, as you like. Having a label on a partition doesn't prevent using UUIDs.
I'd verify that the /mnt/old/etc/fstab file is correct for the new storage and new swap partition.
A new line will be needed to mount /home partition onto /home.
Code:
LABEL=HOME01 /home ext4 noatime,errors=remount-ro 0 1
For the swap, you'll change from a swap file line ... probably something like /swapfile ---> the new 4.1G swap partition ... /dev/nvme0n1p8? I don't know the actual device.
Code:
LABEL=SWAP01 none swap sw 0 0
Don't forget to delete the unused swapfile. Since we deleted that line in the /etc/fstab file, deleting it now or after reboot isn't hard.
In theory, that should be it. Reboot into the Ubuntu, not using the flash drive. Label's are cool. Just know they have to be unique for any storage ever connected to the system. To see a label for a partition (or other file system object), use:
Code:
lsblk -e 7 -o name,size,type,fstype,label,mountpoint
There are other ways, but this is very handy.
It takes much more to write this out than it takes to actually do the task.
What you've done is used about 60G of space in the 140G unallocated area. The new HOME01 area can be expanded to-the-right easily using gparted in the future, if needed.
You've switched from using a swapfile to using a swap partition. 4.1G is probably the best size for a swap file on a desktop Linux. You cannot hibernate if you have more RAM, but if you've gone to the effort to use encryption for data, then you don't want to use hibernation anyways. Standby mode still works, btw.
And we freed up the space in the old OS partition used by both the swap and /home files. That should be 10G or more. If you autoremove and autoclean and remove unused snaps, the amount of storage there should be fine for years.
Here's my 20.04 desktop:
Code:
$ dft
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vgubuntu--root ext4 19G 11G 7.2G 60% /
/dev/mapper/vgubuntu--home ext4 12G 6.8G 4.4G 61% /home
Note the used sizes.
I use LVM, so don't worry about the first column too much. I'm running a minimal install and don't install 50 different bloated GUI programs on it. You can't see it, but those allocations are actually split across 2 SSDs. 1 is 30G and the other is 10G. I was caught running out of space just like you. Thanks to LVM, I was able to expand the / (root) logical volume into the 2nd disk. I left home where it was. I would never allow an LV to span across physical devices ... and I haven't here either. Both the disks are virtual and come from the same physical SSD.
Bookmarks