1

I want to resize my root partition using Gparted but before doing it I want to make sure I'm doing it correctly. Here is a screenshot of my GParted:

GParted screen

So, my question is:

Assuming I launch Ubuntu from a LiveCD and I get to run GParted how should I give space from the home folder to the root folder knowing that the SWAP is in the middle? What is the correct process to minimize the risk of screwing up?

Nobita
  • 263

2 Answers2

5

I recently did this. Be careful to boot your computer from a live cd of the SAME version of ubuntu as you have installed, if you can. (I'm superstitious!)

Then start Gparted. From here on it is a slow sliding block puzzle.

Click on your /home partition, then right click it and select 'Resize/Move. When the graphic pops up, use your mouse pointer to take hold of the left hand handle of the /home partition and slide it right to shrink the partition as much as you need. Click on the Resize/move button, then the green check mark on the toolbar and the shrinking will start -and it will take a fair time to complete.

Now click the swap partition, then right click it and select 'Resize/Move. When the graphic pops up, use your mouse pointer to grab the middle of its graphic and slide it right until it butts up against the /home partition. Then click the Resize/Move button, then the green check mark on the toolbar to move it. When this is done, there will be space on its left to fill up with the /root partition.

Click on your /root partition, then right click it and select 'Resize/Move. When the graphic pops up, use your mouse pointer to take hold of the right hand handle of the / partition and slide it right to bring it up against the swap partition. Click on the Resize/move button, then the green check mark on the toolbar and the expanding will start -and, again, it will take a time to complete.

I know, I know, I could have done the whole sliding block thing in one go and then clicked on the green check mark just once, but to me the process feels less risky doing each move independently. You WILL back off any irreplaceable files before you start, won't you? A power cut could prove disastrous... Wordy though my solution is, this is the simplest, entirely graphical way, if you can believe that!

For added security, you could install Boot Repair on your hard disk (https://help.ubuntu.com/community/Boot-Repair) . Then if you find it has all gone wrong, you could use a SuperGrub2 CD to boot your system and then run boot repair to fix grub.

Good luck,

Vic

Vic
  • 418
0

The simple way is to delete the swap partition, shrink /dev/sda7, expand /dev/sda5, then recreate /dev/sda6 as swap. Once you've done that, you can find the swap partition's UUID by running this

ls -la /dev/disk/by-uuid | grep sda6 #(assuming it was created as /dev/sda6)
lrwxrwxrwx 1 root root  10 2012-02-12 10:35 8bfea793-5cb2-480c-a4e3-2b3c331463bb -> ../../sda6
#                                           |---- This is the UUID ------------|

and then copy and paste that into fstab in place of the old UUID.

cat /etc/fstab | grep swap
UUID=8bfea793-5cb2-480c-a4e3-2b3c331463bb none            swap    sw              0       0
#    |------ Replace this part   -------|                 ^Will be the only line that says 'swap'
Huckle
  • 7,188
  • You'll need to be root to edit /etc/fstab, run sudo gedit /etc/fstab or sudo nano /etc/fstab. You should back it up first with sudo cp /etc/fstab /etc/fstab.old – Huckle Feb 19 '12 at 21:53
  • I should do all that while running from a Live CD right? – Nobita Feb 19 '12 at 22:22
  • You need to use the live cd because the partitions can't be mounted while doing this. – Marty Fried Feb 19 '12 at 22:33
  • @Huckle: I think a simpler way to get the uuids is using "sudo blkid", but it's best to make sure you get any changed values, rather than cached values, by specifying no cache, ie: sudo blkid -c /dev/null – Marty Fried Feb 19 '12 at 22:38
  • When I shrinkg sda7 will that make space for swap? I'm afraid that when I delete sda6 (swap) and I expand sda5, I will be eating space of sda6 and therefore when trying to create it back, there will be no space between sda5 and sda7. – Nobita Feb 19 '12 at 22:43
  • @Nobita you will have to resize both sda5 AND sda7. If you increase one by 15 GB you need to decrease the other by 15 GB as well. This way you will only be laterally shifting the swap over. – Huckle Feb 20 '12 at 01:22
  • @Huckle - When running graphical applications ( such as gedit) you should use gksu. If editing with a command line editor, such as nano, all you need is sudo -e /etc/fstab , see https://help.ubuntu.com/community/RootSudo#Graphical_sudo – Panther Feb 20 '12 at 04:48
  • I was assuming both were being run from the terminal. Pressing ALT+F2 and running sudo will not do much to help anyone. I guess more accurately I should have put (sudo gedit /etc/fstab > /dev/null 2>&1)& – Huckle Feb 20 '12 at 18:50