Need to move my swap partition to let my root partition grow. How?
Solution 1
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.
use GParted as you've described.
Find the updated UUID of the swap partition from the output of:
sudo blkid
edit /etc/fstab in the guest OS to have the new UUID in the line with a 'type' of 'swap'
That should do it.
Solution 2
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
Related videos on Youtube
![apelliciari](https://i.stack.imgur.com/WJGeI.jpg?s=256&g=1)
apelliciari
Updated on September 18, 2022Comments
-
apelliciari almost 2 years
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
I'm going to do some move/resize to get the unallocated space near the /dev/sda1.
The operations are these:
Now, if i do this, surely i will have problems with the next boot. What i have to do to fix that?
-
Admin over 12 yearsYou may not even need a swap when running Ubuntu in virtual box.
-
Admin over 12 yearswhat are the disadvantages of having swap on a file like albercuba said?
-
Admin over 12 yearsNone, swap on file is fine but you don't really need a swap that would enable you to suspend your RAM to disk - however you don't do that in virtual box. Try without (you can always assign a swap on file later if you feel like you need it).
-
-
apelliciari over 12 yearsthis worked, even without the edit to /etc/fstab; there was no line of type 'swap' in there and system booted successfully after the gparted operations
-
Matt almost 9 yearsHow can I direct the swap file to be on a specific storage device?
-
cardiff space man almost 9 yearsInterestingly, using this strategy I forgot to edit fstab and when I checked it later, the swap mount's UUID was already the same as what blkid showed. So I guess it's good to have the UUID's match, but depending on which OS you use it might track itself or depending on which Gparted version you use it might be kept in line by Gparted ?rising-tone-like-a-question?
-
Brett G almost 8 years@cardiffspaceman Actually I just did the same operation as OP... I checked my UUID before and after. Turns out that the UUID just didn't change.