0

Currently, I am running low on space on my root partition (I need more space to execute the 20.04 update).

I have a 14.9 GB swap partition, and a half-filled home partition. I'm thinking I would delete the swap partition, extend my root partition into some, or all of the remaining space, then make a new swap partition by resizing my home partition.

This is currently what my partitions in GParted look like, with the first few partitions are for my Windows dual boot:

partitions in GParted

How would I accomplish this?

Matthew Ha
  • 3
  • 1
  • 2

1 Answers1

0

We'll convert your partition-based swap, to a /swapfile. We'll delete the swap partition, and use that unallocated space to increase the / partition. You'll need to have a bootable Ubuntu Live DVD/USB to proceed.

Edit /etc/fstab...

To edit, use sudo -H gedit /etc/fstab or sudo pico /etc/fstab

and comment out this line:

UUID=xxxx-xxxx-xxxx-xxxx none  swap       sw       0       0

Save the edit and quit the editor

Boot to a Ubuntu Live DVD/USB

Start gparted.

Do a swapoff on the /dev/nvme0n1p6 partition

Delete the /dev/nvme0n1p6 partition, as it won't be used any more

Drag the right side of the /dev/nvme0n1p5 partition all the way right

Click the Apply button

Quit gparted

Reboot

Create a /swapfile...

Note: Incorrect use of the dd command can cause data loss. Suggest copy/paste.

In the terminal...

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile # set proper file protections sudo mkswap /swapfile # init /swapfile sudo swapon /swapfile # turn on swap free -h # confirm xxG RAM and 4G swap

Confirm this /swapfile line at the end of /etc/fstab... and confirm no other uncommented “swap” lines...

To edit, use sudo -H gedit /etc/fstab or sudo pico /etc/fstab

Note: Use SPACES, not TABS

/swapfile  none  swap  sw  0  0

reboot                    # reboot and verify operation
heynnema
  • 73,649