RHEL 6 SWAP Partition erweitern

Vor der Aufgabe stand ich vor ein paar Tagen. Adding and Managing RHEL 6 Swap Space

Es ist total einfach. Hier läuft das in einer VM und die SWAP ist eine Extra Platte, dieser Platte geben wir mal etwas mehr Plattenplatz. Jetzt sollte man diesen Plattenplatz noch dem SWAP zu ordnen, damit es genutzt werden kann.

fdisk -cul /dev/sdd

Disk /dev/sdd: 21.5 GB, 21474836480 bytes
181 heads, 40 sectors/track, 5793 cylinders, total 41943040 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: 0x000162ca

Device Boot Start End Blocks Id System
/dev/sdd1 2048 10485759 5241856 82 Linux swap / Solaris

Damit sehen wir wie groß die SWAP Partition ist. Ca. 5 GB

SWAP Datei ausschalten und prüfen ob es auch wirklich deaktviert ist

# swapoff /dev/sdd1
# cat /proc/swaps
Filename Type Size Used Priority

FDISK aufrufen mit folgendem Befehl um die Disk zu partitionieren.

# fdisk -cu /dev/sdd

Dann stehen einem gewisse Befehle zur Verfügung
p steht für print
d für delete
t für toggle
w für schreiben

Damit ihr seht wie das genau funktioniert hier mal ein vollständiger Auszug

Command (m for help): p

Disk /dev/sdd: 21.5 GB, 21474836480 bytes
181 heads, 40 sectors/track, 5793 cylinders, total 41943040 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: 0x000162ca

Device Boot Start End Blocks Id System
/dev/sdd1 2048 10485759 5241856 82 Linux swap / Solaris

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/sdd: 21.5 GB, 21474836480 bytes
181 heads, 40 sectors/track, 5793 cylinders, total 41943040 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: 0x000162ca

Device Boot Start End Blocks Id System

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039

Command (m for help): p

Disk /dev/sdd: 21.5 GB, 21474836480 bytes
181 heads, 40 sectors/track, 5793 cylinders, total 41943040 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: 0x000162ca

Device Boot Start End Blocks Id System
/dev/sdd1 2048 41943039 20970496 83 Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sdd: 21.5 GB, 21474836480 bytes
181 heads, 40 sectors/track, 5793 cylinders, total 41943040 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: 0x000162ca

Device Boot Start End Blocks Id System
/dev/sdd1 2048 41943039 20970496 82 Linux swap / Solaris

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Partition formatieren

# mkswap /dev/sdd1
Setting up swapspace version 1, size = 20970492 KiB
no label, UUID=2c13a1f2-b245-40c6-b104-f43b1465156e

SWAP aktivieren

# swapon /dev/sdd1
# cat /proc/swaps
Filename Type Size Used Priority
/dev/sdd1 partition 20970488 0 -1

die obige UUID ersetzt die alte UUID und beim Neustart geht die SWAP Partition nicht verloren.
Das muss noch in FSTAB geschrieben werden die UUID

# nano /etc/fstab

Das war alles, total einfach und manche Anleitungen hantieren hier mit DD und sonstwas.

Adding and Managing RHEL 6 Swap Space