Wednesday, May 1, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 513  / 3 Years ago, tue, september 28, 2021, 7:43:13

I have one partition that is full and about 17gb of unallocated space which I would like to combine. When I try to unmount the partition I get an error that says could not unmount. Is there any way of doing this ?



enter image description here


More From » partitioning

 Answers
2

You can think of the root filesystem (/) as the C: drive in windows. It contains (unless you tell it otherwise) nearly all of the operating system files. In order to do any operations on the partition mounted on / you need to unmount the partition. To unmount the partition you have to stop using all the files on the partition. To stop using your operating system files you need to shut down your computer.



So how might one do this? Well, we could use a different operating system. A Linux live CD is an entire copy of Linux compressed onto a CD. When you boot it, it creates a root partition in your RAM, instead of your hard drive. This allows you to play with your hard drives partitions (including /dev/sda1) unencumbered.



There are of course other methods as well, for example you could install Linux on a second hard drive and attach that to your computer. Or you could network boot your computer, which works much like the CD but instead it uses a TFTP server.



However there is one other thing that is going to get in your way, even if you use a Linux live disk: your swap space. The partition /dev/sda2 (and the swap partition /dev/sda5 that it contains) will prevent you from expanding /dev/sda1 into the unallocated space. Thankfully, it is easier to stop using the swap space. You an turn it on and off momentarily with sudo swapoff -a and sudo swapon -a, however that is not the full solution. Once you turn the swap off, you need to move the swap partition. If you move your swap partition, you must tell Ubuntu that you did so.



This can be done in the file sudo vim /etc/fstab. There will be a long string followed by swap that will look like the line below. This is where you tell your computer where the swap to use is. After you move your swap, you need to get the new string to use here. This can be obtained using lsblk -f.



UUID=4209c845-f495-4c43-8a03-5363dd433153 none swap defaults 0 0



So the full procedure looks like:




  1. Boot a live CD, or another OS.

  2. Turn off the swap, if the OS automatically started using it

  3. Delete swap and extended partition

  4. Recreate swap elsewhere (and extended partition if you want)

  5. Update /etc/fstab

  6. Extend /dev/sda1

  7. Reboot



Now there are things that can wrong in this process. Namely, you could mess up your /etc/fstab or your /dev/sda1 can get corrupted. The first is not really a big deal, as you can always boot a live CD and fix it. There's a good chance your computer will actually boot fine with an error on the swap line anyway. The second is a much bigger concern. Modern tools are pretty good at expanding partitions, but to be safe ALWAYS BACK UP THE DATA ON THE PARTITION / DISK YOU ARE EDITING.



Sources:




  1. https://wiki.archlinux.org/index.php/fstab#UUID


[#28042] Wednesday, September 29, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
uffno

Total Points: 283
Total Questions: 93
Total Answers: 111

Location: Saint Vincent and the Grenadines
Member since Thu, Oct 15, 2020
4 Years ago
uffno questions
Thu, Sep 2, 21, 18:08, 3 Years ago
Sun, Apr 2, 23, 15:15, 1 Year ago
Sat, Jan 8, 22, 16:37, 2 Years ago
;