SWAP - Increasing /tmp on Oracle Linux 7 with Logical Volume
To see the free space
[root@localhost ~]# free
total used free shared buff/cache available
Mem: 3781836 663624 2618184 10952 500028 3040988
Swap: 2306044 0 2306044
To see the specify devices on which paging and swapping
[root@localhost ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 2306044 0 -1
To see the disk
[root@localhost ~]# ls -la /dev/sd*
brw-rw----. 1 root disk 8, 0 Sep 14 11:25 /dev/sda
brw-rw----. 1 root disk 8, 1 Sep 14 11:25 /dev/sda1
brw-rw----. 1 root disk 8, 2 Sep 14 11:25 /dev/sda2
brw-rw----. 1 root disk 8, 16 Sep 14 11:25 /dev/sdb
brw-rw----. 1 root disk 8, 32 Sep 14 11:25 /dev/sdc
brw-rw----. 1 root disk 8, 48 Sep 14 11:25 /dev/sdd
brw-rw----. 1 root disk 8, 64 Sep 14 11:25 /dev/sde
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 22G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 21G 0 part
├─ol-root 249:0 0 18.8G 0 lvm /
└─ol-swap 249:1 0 2.2G 0 lvm [SWAP]
sdb 8:16 0 3G 0 disk
sdc 8:32 0 1G 0 disk
sdd 8:48 0 1G 0 disk
sde 8:64 0 1G 0 disk
sr0 11:0 1 1024M 0 rom
note: you have in this case 4 disk available, we will work with sdb that have 3Gb.
To create a Partitio sdb1 from disk sdb
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xcd36e216.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-6291455, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-6291455, default 6291455):
Using default value 6291455
Partition 1 of type Linux and of size 3 GiB is set
Command (m for help): p
Disk /dev/sdb: 3221 MB, 3221225472 bytes, 6291456 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 label type: dos
Disk identifier: 0xcd36e216
Device Boot Start End Blocks Id System
/dev/sdb1 2048 6291455 3144704 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
To see new partition
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 22G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 21G 0 part
├─ol-root 249:0 0 18.8G 0 lvm /
└─ol-swap 249:1 0 2.2G 0 lvm [SWAP]
sdb 8:16 0 3G 0 disk
└─sdb1 8:17 0 3G 0 part
sdc 8:32 0 1G 0 disk
sdd 8:48 0 1G 0 disk
sde 8:64 0 1G 0 disk
sr0 11:0 1 1024M 0 rom
To see Logical Volume information
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/ol/swap
LV Name swap
VG Name ol
LV UUID UMPpQD-v2og-cnPr-02bc-0uqS-YTNq-iMrxa3
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2017-09-14 07:16:13 +0100
LV Status available
# open 2
LV Size <2.20 GiB
Current LE 563
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:1
--- Logical volume ---
LV Path /dev/ol/root
LV Name root
VG Name ol
LV UUID tmRvjB-ukki-pFnt-WZGK-icIy-sdTC-QmSdJ3
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2017-09-14 07:16:13 +0100
LV Status available
# open 1
LV Size 18.79 GiB
Current LE 4811
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:0
To see physical volume
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 ol lvm2 a-- <21.00g 4.00m
Creating physical volume with /dev/sdb1
[root@localhost ~]# pvcreate -v /dev/sdb1
Wiping internal VG cache
Wiping cache of LVM-capable devices
Wiping signatures on new PV /dev/sdb1.
Set up physical volume for "/dev/sdb1" with 6289408 available sectors.
Zeroing start of device /dev/sdb1.
Writing physical volume data to disk "/dev/sdb1".
Physical volume "/dev/sdb1" successfully created.
Seeing If It has been create a new one
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 ol lvm2 a-- <21.00g 4.00m
/dev/sdb1 lvm2 --- <3.00g <3.00g
To see volume group
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
ol 1 2 0 wz--n- <21.00g 4.00m
To extend ol volume
[root@localhost ~]# vgextend -v ol /dev/sdb1
Wiping internal VG cache
Wiping cache of LVM-capable devices
Wiping signatures on new PV /dev/sdb1.
Archiving volume group "ol" metadata (seqno 3).
Adding physical volume '/dev/sdb1' to volume group 'ol'
Volume group "ol" will be extended by 1 new physical volumes
Creating volume group backup "/etc/lvm/backup/ol" (seqno 4).
Volume group "ol" successfully extended
To see if our PV belong to ol VG
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 ol lvm2 a-- <21.00g 4.00m
/dev/sdb1 ol lvm2 a-- <3.00g <3.00g
note: there a 3Gb free
To check ol VG has been increased
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
ol 2 2 0 wz--n- 23.99g 3.00g
note: before value had been 21.00g
To check Logical Volume /dev/ol/swap
[root@localhost ~]# lvdisplay /dev/ol/swap
--- Logical volume ---
LV Path /dev/ol/swap
LV Name swap
VG Name ol
LV UUID UMPpQD-v2og-cnPr-02bc-0uqS-YTNq-iMrxa3
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2017-09-14 07:16:13 +0100
LV Status available
# open 2
LV Size <2.20 GiB
Current LE 563
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:1
To increase ol Logical Volume
[root@localhost ~]# lvextend -L+3Gb /dev/ol/swap
Size of logical volume ol/swap changed from <2.20 GiB (563 extents) to <5.20 GiB (1331 extents).
Logical volume ol/swap successfully resized.
To check if ol increased
[root@localhost ~]# lvdisplay /dev/ol/swap
--- Logical volume ---
LV Path /dev/ol/swap
LV Name swap
VG Name ol
LV UUID UMPpQD-v2og-cnPr-02bc-0uqS-YTNq-iMrxa3
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2017-09-14 07:16:13 +0100
LV Status available
# open 2
LV Size <5.20 GiB
Current LE 1331
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 249:1
note: Lv size has been increased
To see physical volume status
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 ol lvm2 a-- <21.00g 0
/dev/sdb1 ol lvm2 a-- <3.00g 0
To see swap device
[root@localhost ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 2306044 0 -1
To turn off swap
[root@localhost ~]# swapoff -v /dev/ol/swap
swapoff /dev/ol/swap
To make as a swap area
[root@localhost ~]# mkswap /dev/ol/swap
mkswap: /dev/ol/swap: warning: wiping old swap signature.
Setting up swapspace version 1, size = 5451772 KiB
no label, UUID=f34131e6-1c41-4ee7-aa63-bf804feb0726
To turn on swap
[root@localhost ~]# swapon /dev/ol/swap
To see swap device
[root@localhost ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 5451772 0 -1
note: swap has bee increased
To see free space for swaping
[root@localhost ~]# free
\ total used free shared buff/cache available
Mem: 3781836 664976 2615932 10956 500928 3039684
Swap: 5451772 0 5451772
To list disk disk
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 22G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 21G 0 part
├─ol-root 249:0 0 18.8G 0 lvm /
└─ol-swap 249:1 0 5.2G 0 lvm [SWAP]
sdb 8:16 0 3G 0 disk
└─sdb1 8:17 0 3G 0 part
└─ol-swap 249:1 0 5.2G 0 lvm [SWAP]
sdc 8:32 0 1G 0 disk
sdd 8:48 0 1G 0 disk
sde 8:64 0 1G 0 disk
sr0 11:0 1 1024M 0 rom