1

I'm running Ubuntu 12.04 LTS Server vm with esxi. I added an additional 20 GB to my thick provisioned lazy zero disk, but I'm not able to resize my current partition. I am booting from a gparted live iso. I would like to merge /dev/sda1 and unallocated, but I do not seem to get the option.

enter image description here

Does anyone have any suggestions on increasing the size of /dev/sda1?

1

Yes, it's possible to merge unallocated space with /dev/sda1.

  • Boot from Ubuntu live disk or gparted live disk.

  • Note that your unallocated space is just outside of your extended partition. Open gparted partition editor, right-click on the extended partition(/dev/sda2) and select Resize/Move option.

  • Move the right-arrow to extreme right, so that the unallocated space will comes under your extended partition(just below to your swap partition).

  • Now right-click on your swap partition and select Resize/Move option. Move the dragger to the extreme right, so that the unallocated space would come before to your swap partition(just above to your swap).

  • After that, you can be able to get out of the unallocated space from that extended partition by right-clicking on the extended partition(/dev/sda2) and selecting Resize/Move option. Then shrink it's space, so that the unallocated space present inside your extended partition will get out of that.

  • After doing the above step, now your unallocated space would come just above to your /dev/sda2 extended partition.

  • Finally, now you can be able to resize(increase the space of) your /dev/sda1 partition.

NOTE: Make sure that all the partitions are unmounted before doing the above operations.

6
  • Do I need to apply it before being able to resize /dev/sda1 ? As I did the following and currently have [/dev/sda1][[unallocated][/dev/sda5][1mb unallocated]] . When I right click on /dev/sda1 and try to Resize/Move I don't get an option to move into unallocated space. – user316477 May 16 '14 at 5:00
  • yes, you have to apply it. Please take a screenshot of that screen and upload it to imgur.com. Finally post back the link here. – Avinash Raj May 16 '14 at 5:03
  • This is my current status: imgur.com/tySPa7i – user316477 May 16 '14 at 5:08
  • please get out of that unallocated space from the extended partition by right-clicking on the extended partition , selecting resize move, shrinking it's space. (Just above to your extended partition) – Avinash Raj May 16 '14 at 5:13
  • 2
    Awesome! Ubuntu booted and shows the new disk space. Adding last link for others. imgur.com/C5AaMPb – user316477 May 16 '14 at 5:30
0

You can't merge a primary partition with an extended partition.

If you want to do it, you will need to first move the swap to the end of the extended partition (sda2) - actually, just delete it, and recreate it at the end at some point.

So, delete the extended partition (sda2); then, you should be able to expand the primary partition.

Then create a swap file at the at the end of the disk.

It would have been best to create one big extended partition at the beginning, then create logical drives in that partition for everything. But you are OK as long as you don't want to try to create more than 4 partitions, which is the limit of primary partitions.

EDIT: I forgot one thing. If you delete the swap file, you will need to update the file /etc/fstab because there will be a new UUID. If you want to do that, you can run blkid to get the UUID, and paste that into fstab:

sudo blkid -c /dev/null is the best way to invoke it to get the correct UUID

But really, you don't want to do that; you should just move the swap file/extended partition to the end of the unused space. After doing that, you can grow the primary partition.

8
  • Similarly extend sda2 all the way to the end of drive, move swap to end of sda2 so unallocated is at beginning of extended, then move start of sda2 to beginning of swap. Or if you just delete swap and extended you have to recreate at end and edit fstab with new UUID for new swap. – oldfred May 15 '14 at 22:37
  • 1
    It's easier to move than to delete and recreate, since if you do that, you will have a new uuid and need to update /etc/fstab. – psusi May 16 '14 at 1:46
  • @psusi: Thanks, didn't think about updating fstab. I originally was suggesting moving it, but then thought it would be easier to recreate it rather than take time to move it. For me, it's easier to update fstab anyway (simple run blkid, then cut and paste), but in any case, I'll edit my answer. – Marty Fried May 16 '14 at 2:14
  • @MartyFried you don't need to delete any partitions. – Avinash Raj May 16 '14 at 3:10
  • 1
    @MartyFried Thanks for clarifying the blank spaces. Everything is running smooth and plenty of space now. – user316477 May 17 '14 at 7:13
0

You are unable to add it because it's a logical partition of an extended partition. You could however delete the extended partition, expand the primary partition as desired, and then create a new swap partition afterwards.

Steps:

  1. Boot up Ubuntu.

  2. In terminal type sudo apt-get install gparted.

  3. Open Gparted. You can do so from your applications screen.

  4. Choose your device from the devices menu on the far right.

  5. Right click on the swap partition and choose "swapoff".

  6. Right click on the swap partition (sda5), and choose "delete". Right click on the extended partition (sda2), and choose "delete".

  7. Click the green checkmark on the top menu to apply these changes.

  8. Right click on the primary partition (sda1), and choose "resize/move". Add the amount of space you want to it, but make sure to leave some for swap.

  9. Click the green checkmark on the top menu to apply these changes.

  10. Right click on the unallocated space, and click "new".

  11. Choose "linux-swap" as the filesystem type, and click "add".

  12. Click the green checkmark on the top menu to apply these changes, and then close Gparted.

  13. Right click on the swap partition, choose "swapon", and close Gparted.

  14. In terminal type sudo blkid, and copy the UUID for your swap partition.

  15. In terminal type gksu gedit /etc/fstab, and change the UUID of the swap entry to match your current one. Then change the sda# to sda2 in the swap location comment line. Save your changes, and close Gedit. [If you don't have "Gksu" installed you can use sudo gedit /etc/fstab instead.]

  16. Reboot.

Notes:

  • When resizing a partition that Ubuntu is running on you will be able to expand, but not shrink. You can get around this by partitioning from a livecd instead which is often considered better practice, but the fstab editing must be done within Ubuntu.

  • You can verify your swap is recognized by checking your System Monitor. It will have an entry for SWAP, and list the amount used (if any) along with the total available.

  • Tested May 15 2014 10:02 PM on Ubuntu 14.04 - Desktop X86-64

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.