We have already discussed about use of swap space and the amount of swap size. To increasing swap size have used dd command and swap partition.
Another option is can make a swap size of the Logcal volume (LVM). For this post increase +2GB for swap space.
Current RAM memory and swap size satus,
# free -m
total used free shared buffers cached
Mem: 1777 1654 122 0 9 404
-/+ buffers/cache: 1240 537
Swap: 3672 155 3517
create a swap Logical volume:
-p Specified that print the partition,
-n Specified to create new partition
-t Type of partition (for LVM code type 8e)
-w Specified that write the changes (save)
# fdisk /dev/sda
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Command (m for help): n
All primary partitions are in use
Adding logical partition 15
First sector (491483136-579295231, default 491483136):
Using default value 491483136
Last sector, +sectors or +size{K,M,G} (491483136-579295231, default 579295231): +10G
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sda15 491483136 493531135 1024000 83 Linux
Command (m for help): t
Partition number (1-15): 15
Hex code (type L to list codes): 8e
Changed system type of partition 15 to 8e (Linux LVM)
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sda15 491483136 493531135 1024000 8e Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Command (m for help): n
All primary partitions are in use
Adding logical partition 15
First sector (491483136-579295231, default 491483136):
Using default value 491483136
Last sector, +sectors or +size{K,M,G} (491483136-579295231, default 579295231): +10G
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sda15 491483136 493531135 1024000 83 Linux
Command (m for help): t
Partition number (1-15): 15
Hex code (type L to list codes): 8e
Changed system type of partition 15 to 8e (Linux LVM)
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sda15 491483136 493531135 1024000 8e Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
It's necessary to reboot the system, once LVM partitioned
Crate physical volume:
# pvcreate /dev/sda15
Physical volume "/dev/sda15" successfully created
Check your physical volume size:
# pvs
/dev/sda15 swaps lvm2 a-- 10.00g 9.02g
Create Volume Group:
# vgcreate swaps /dev/sda15
Volume group "swaps" successfully created
Displaying volume group swaps details:
# vgdisplay swaps
--- Volume group ---
VG Name swaps
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 10.00 GiB
PE Size 4.00 MiB
Total PE 2559
Alloc PE / Size 0 / 0
Free PE / Size 2559 / 10.00 GiB
VG UUID cBIjt0-lXNB-07gQ-7q7G-HMjV-4zyC-dO4a63
Create a new swap space:
# mkswap /dev/mapper/swaps-swap1
mkswap: /dev/mapper/swaps-swap1: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 1023996 KiB
no label, UUID=e989f379-f428-4581-83f9-8bc42079c431
Tuning on swap space,
# swapon -v /dev/mapper/swaps-swap1
swapon on /dev/mapper/swaps-swap1
swapon: /dev/mapper/swaps-swap1: found swap signature: version 1, page-size 4, same byte order
swapon: /dev/mapper/swaps-swap1: pagesize=4096, swapsize=1048576000, devsize=1048576000
# swapon -s
Filename Type Size Used Priority
/dev/sda1 partition 5858300 159356 -1
/dev/mapper/swaps-swap1 partition 1023996 0 -2
parmanently swapon for every reboot system Open a /etc/fstab file and add the line
UUID=e989f379-f428-4581-83f9-8bc42079c431 swap swap defaults 0 0
Swap space off:
You want to remove the line from the file "/etc/fstab" and execute swapoff command,
UUID=e989f379-f428-4581-83f9-8bc42079c431 swap swap defaults 0 0
# swapoff /dev/mapper/swaps-swap1
Comments (0)