17

I have a Virtual Box Ubuntu guest and i need to have more space on my disk (actually it's 8 gb). I have already increased the space allocated for the VDI to 16 gb.

Now with GParted Live i'm trying to expand my partition, but the swap blocks the expansion, as is in this image

the situation now

I'm going to do some move/resize to get the unallocated space near the /dev/sda1.

The operations are these:

future

Now, if i do this, surely i will have problems with the next boot. What i have to do to fix that?

aureianimus
  • 3,586

3 Answers3

12

The resizing operations won't cause any issues with the filesystem, but you may need to update your /etc/fstab to point at the new partition ID.

  1. use GParted as you've described.

  2. Find the updated UUID of the swap partition from the output of:

    sudo blkid

  3. edit /etc/fstab in the guest OS to have the new UUID in the line with a 'type' of 'swap'

That should do it.

9

Just delete the swap partition and use a swap file. To do this type: This example is for a 1GB swap file

dd if=/dev/zero of=/swapfile bs=1024 count=1048576
chmod 0600 /swapfile
mkswap /swapfile
swapon /swapfile

Be sure to tell the OS to stop using the swap partition before you delete it, like this.

swapoff /dev/nameOfCurrentSwap

And remove or comment out the line in fstab that points to it.

Then you have to enable the swap space at boot time, add this line in fstab:

/swapfile none swap sw 0 0
0

In my case, with an Ubuntu 20.04, just updating the UUID address in /etc/fstab file produced a 30' lag in boot time at "Begin: Running /scripts/local-premount" step. Following this link : Boot hangs for 30 seconds at "Begin: Running /scripts/local-premount", one should try the following:

  • create the /etc/initramfs-tools/conf.d/resume file (in my case it didn't exist)
  • find the UUID for the newly created swap partition using the command sudo blkid /dev/my_new_swap_partition
  • edit the file and put the line RESUME=UUID=xxx in it, where xxx is the number for UUID found above
  • run sudo update-initramfs -u
  • reboot the system
alinux
  • 11