PDA

View Full Version : [SOLVED] Moving my swap partition?



RobotGymnast
March 31st, 2011, 01:57 PM
I have two Ubuntu partitions, a side-effect of when I had Windows installed, installed Ubuntu, removed Windows, and installed Ubuntu into the free space. My partitions look like this:

/dev/sda1: My actual ext4 partition.
/dev/sda3: Extended partition.
/dev/sda5: Old Ubuntu partition, ext4 (can delete all this data).
/dev/sda6: Swap partition.

I'd like to remove /dev/sda3, /dev/sda5, and /dev/sda6, extend my /dev/sda1 partition to fill the entire hard drive (except 2 GBs), then create a /dev/sda2 swap partition to fill up my remaining space.

However, I don't know how to move my swap partition without messing things up, and I hesitate to try. How do I move my swap partition and get my system to recognize it?

Anonymous is Incognito
March 31st, 2011, 02:08 PM
Partitioning

Make sure you switched swap off with the following command.


swapoff -a

Remove and create the partitions with


sudo cfdisk /dev/sda

or


gksudo gparted

Be sure to select swap as filetype for /dev/sda2.

Utilising the swap partition

mkswap /dev/sda2 will use the partition as swap space, but only for the current session.

To automatically mount the partition as swap on boot add the following lines to the /etc/fstab:


/dev/sda2 swap swap defaults 0 0

Does this adequately answer your question?

RobotGymnast
March 31st, 2011, 10:24 PM
Yes, that's great. Thanks.