How I created a new swap partition for my Linux Mint 14 PC using Gparted.

Posted: February 9, 2013. At: 12:16 AM. This was 5 years ago. Post ID: 5358

Creating a new /swap partition with Gparted.
Creating a new /swap partition with Gparted.

I have 6 Gigabytes of RAM in my computer and I found out that my swap partition was only 2 Gigabytes. So I needed to create a larger partition. I used the Gparted application to delete a useless Gentoo partition and then I created a 12 Gigabyte partition to use as swap space. This will be more than enough for any future requirements. This might also help the performance of my computer as well. I only needed to type sudo apt-get install gparted to install the partition manager and then I could create the new swap partition. After the partition has been created use the command below to switch on the new swap partition.

[email protected] ~ $ sudo swapon /dev/sdb2

Then the new swap will be active. Here are the details of my new swap partition. As you can see, there is a 2 Gigabyte partition and a 12 Gigabyte partition that are both for swap.

[email protected] ~ $ sudo fdisk -l /dev/sdb
[sudo] password for john: 

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x03eec363

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048      882687      440320   83  Linux
/dev/sdb2          882688    25458687    12288000   82  Linux swap / Solaris
/dev/sdb3       717682688   971634687   126976000   83  Linux
/dev/sdb4       971638782   976758783     2560001    5  Extended
/dev/sdb5       971638784   976758783     2560000   82  Linux swap / Solaris

This is how to list partitions by their uuid.

[email protected] ~ $ ls -hula /dev/disk/by-uuid/
total 0
drwxr-xr-x 2 root root 260 Feb  9  2013 .
drwxr-xr-x 6 root root 120 Feb  8 23:27 ..
lrwxrwxrwx 1 root root  10 Feb  8 22:38 1323B2B1180C1879 -> ../../sdh2
lrwxrwxrwx 1 root root  10 Feb  8 22:38 3fabc97d-c76a-4922-8705-5536e89cfd21 -> ../../sda2
lrwxrwxrwx 1 root root  10 Feb  8 22:38 4282F11082F10965 -> ../../sda1
lrwxrwxrwx 1 root root  10 Feb  8 22:38 4AD44F236B9F5FEA -> ../../sdh3
lrwxrwxrwx 1 root root  10 Feb  8 22:38 52d826a6-7de5-45db-b693-dd7c7e82af37 -> ../../sda5
lrwxrwxrwx 1 root root  10 Feb  8 22:48 a6f66737-afea-48c3-9694-f6da22904d37 -> ../../sdb3
lrwxrwxrwx 1 root root  10 Feb  8 22:39 a87281f5-c64c-40dc-a3c4-5b10f475296e -> ../../sdb5
lrwxrwxrwx 1 root root  10 Feb  8 22:48 b1e29c2d-865c-4b81-a151-9a3c0db72e19 -> ../../sdb2
lrwxrwxrwx 1 root root  10 Feb  8 22:38 bc5b19b4-1674-42f6-9508-08b7b37f3645 -> ../../sdh1
lrwxrwxrwx 1 root root  10 Feb  8 22:38 e01436e0-4aa5-420b-94aa-0b35bd00020e -> ../../sdb1
lrwxrwxrwx 1 root root  10 Feb  8 22:38 F824FD9424FD565A -> ../../sdg1

Using the UUID I get for the /dev/sdb2 partition, I can use this to alter the /etc/fstab partition to set the 12 Gigabyte partition as the default swap partition. This is easily done in the VIM editor. Here I have replaced the swap entry with the new UUID of the partition and then saved the file. Upon rebooting the new larger swap partition will be used. Adding the entry for the swap partition using the UUID instead of the name of the partition; e.g /dev/sdb2 makes much more sense when you are removing and adding devices to the computer.

1 # /etc/fstab: static file system information.
      2 #
      3 # Use 'blkid' to print the universally unique identifier for a
      4 # device; this may be used with UUID= as a more robust way to name devices
      5 # that works even if disks are added and removed. See fstab(5).
      6 #
      7 #                
      8 proc            /proc           proc    nodev,noexec,nosuid 0       0
      9 # / was on /dev/sdh1 during installation
     10 UUID=bc5b19b4-1674-42f6-9508-08b7b37f3645 /               ext4    errors=remount-ro 0       1
     11 # swap was on /dev/sdb5 during installation
     12 UUID=b1e29c2d-865c-4b81-a151-9a3c0db72e19 none            swap    sw              0       0
     13 UUID=F824FD9424FD565A /mnt/Elements ntfs-3g     rw,nosuid,nodev,allow_other,default_permissions,blksize=4096 0 0
     14 
     15 UUID=1323B2B1180C1879 /mnt/MyMedia ntfs-3g      rw,nosuid,nodev,allow_other,default_permissions,blksize=4096 0 0
     16 UUID=4AD44F236B9F5FEA /mnt/MoreMedia ntfs-3g    rw,nosuid,nodev,allow_other,default_permissions,blksize=4096 0 0
~
~
~
~
~
~
~
~
~
:wq

After this I have a new swap partition and I have much more swap space to give me more breathing room.

No comments have been made. Use this form to start the conversation :)

Leave a Reply