0

I have accidentally (well actually carelessly) provided 11gb swap memory for my dual boot Ubuntu 20.04 installation with Windows 10. I have allocated 25gb to the root partition, which I would like to expand. Can I convert my swap memory to root storage in Ubuntu? If so, how? If not, any alternatives?

I'm a complete Linux noob, so sorry if this is a dumb question!

Edit: It is a swap partition that I'm talking about

Edit 2: The following is what I see in Gparted. /ext4 is my root partition, and the one below unallocated is the linux-swap. Can I do the resizing then?

enter image description here

MarianD
  • 1,028
  • You haven't said if it was a swap file, or swap partition. Swap files can be changed easily too (even easier than swap partitions). – guiverc Jan 27 '21 at 11:10
  • it was a swap partition – hackermannn Jan 27 '21 at 11:11
  • @guiverc can I resize swap partitions with gparted as well? – hackermannn Jan 27 '21 at 11:13
  • Yep, though I tend to just delete them, do what I need, then use the space over to re-create swap (or you could drop expand '/' to use all space, and use swapfile instead as it's easily changed). It's done from the live system (eg. installation media). If you delete/re-create, you'll need to amend the UUID in your file system table (/etc/fstab) and expanding "/" may require you to re-write your MBR (ie. grub-install) but I fix that if needed (again using live media) – guiverc Jan 27 '21 at 11:25

1 Answers1

0

Use disk management tool gparted. If not installed you can install it using $ sudo apt update && sudo apt install gparted. Launch the app as a super user $ sudo gparted and enter the password when prompted. You will see the logical representation of your storage device.

It is possible to make these changes if and only if your swap partition is adjacent to the right of the root partition otherwise you are limited! If this is true, proceed to swapoff and resize your partition from left to right creating an unallocated space adjacent to the right of the root partition. After that move the root partition to the right adding the an unallocated space. A green icon should appear to the top asking to apply all changes. Click and proceed as prompted and you are good to go.

For detailed information on how to use gparted find it here.

Hope this serves your purpose. Success!

Justech
  • 186
  • Do I need to do this using a usb live boot? Or can I do this normally? – hackermannn Jan 27 '21 at 13:03
  • You only need a USB live boot when you don't need to install gparted. Otherwise, you need to note that for you to interact with a partition you should unmount it first and for the swap you swapoff. To be specific, if you try it normally as you stated it, you will get unmount partition error as root is critical the system. So go for the USB live boot. – Justech Jan 27 '21 at 13:11
  • I have edited my question. could you check the image and see if resizing is possible or not? – hackermannn Jan 27 '21 at 13:31
  • Answer edited. Follow to get help. – Justech Jan 27 '21 at 14:00
  • The comment about not needing to use live USB to boot is wrong. You will need to unmount your root partition to resize it. Unmounting your root partition while Ubuntu is running from it is like trying to change a tire of your car while driving it. In gparted you will see a ️ icon next to the root partition. – user68186 Jan 27 '21 at 14:36