April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

CREATING A SWAP PARTITION IN RHEL

In this demonstration, I will be adding at 2GB swap partition to /dev/sdb.

You can identify the relevant disk which you wish to add the swap partition to from issuing the following command:

[root@slave ~]# fdisk -l
To add the swap partition, rerun the fdisk command with the relevant disk location:

[root@slave ~]# fdisk /dev/sdb
Type in “n” and press “ENTER” until you reach a prompt asking for the “Last sector” size.

Type in “+2G” and press “ENTER“.

Type in “t” and press “ENTER“. For the hex code, enter in “82” and press “ENTER“.

Type in “w” and press “ENTER” to activate the changes.

Run partprobe next (this will save you rebooting the host).

[root@slave ~]# partprobe
We can now create the swap space.

[root@slave ~]# mkswap /dev/sdb -f
mkswap: /dev/sdb: warning: wiping old swap signature.
Setting up swapspace version 1, size = 3145724 KiB
no label, UUID=7de886fb-d692-4783-8c17-11a871114ff9
Copy the above UUID.

Enable the swap space:

[root@slave ~]# swapon -a
Modify the fstab to contain the new swap space.

[root@slave ~]# vi /etc/fstab
UUID=7de886fb-d692-4783-8c17-11a871114ff9 swap swap defaults 0 0
I needed to reboot the host to make the changes live.

[root@slave ~]# swapon -s
Filename Type Size Used Priority
/dev/sdb partition 3145724 0 -1
/dev/dm-1 partition 839676 0 -2

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>