Rabu, 24 April 2019

How to resize swap disk redhat 7.3 lvm

  Tidak ada komentar
Before we resize the swap partition, resize the swap lvm first, make sure you have enough volume group
[root@myhost ~]# pvscan
  PV /dev/sda3   VG rhel            lvm2 [18.99 GiB / 0    free]
  Total: 1 [18.99 GiB] / in use: 1 [18.99 GiB] / in no VG: 0 [0   ]
[root@myhost ~]#
[root@myhost ~]# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[root@myhost ~]#
[root@myhost ~]# pvs
  PV         VG   Fmt  Attr PSize  PFree
  /dev/sda3  rhel lvm2 a--  48.99g 30.00g
[root@myhost ~]#
[root@myhost ~]# lvs
  LV   VG   Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root rhel -wi-ao---- 16.99g
  swap rhel -wi-ao----  2.00g
[root@myhost ~]#
Extend the lvm
[root@myhost ~]# lvextend -L +27G /dev/rhel/root
  Size of logical volume rhel/root changed from 16.99 GiB (4350 extents) to 43.99 GiB (11262 extents).
  Logical volume rhel/root successfully resized.
[root@myhost ~]#
[root@myhost ~]# lvextend -L +2G /dev/rhel/swap
  Size of logical volume rhel/swap changed from 2.00 GiB (512 extents) to 4.00 GiB (1024 extents).
  Logical volume rhel/swap successfully resized.
[root@myhost ~]#
[root@myhost ~]# lvs
  LV   VG   Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root rhel -wi-ao---- 43.99g
  swap rhel -wi-ao----  4.00g
[root@myhost ~]#

Check the block disk
[root@myhost ~]# lsblk
NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda             8:0    0  50G  0 disk
├─sda1          8:1    0   4M  0 part
├─sda2          8:2    0   1G  0 part /boot
└─sda3          8:3    0  49G  0 part
  ├─rhel-root 253:0    0  44G  0 lvm  /
  └─rhel-swap 253:1    0   4G  0 lvm  [SWAP]
sr0            11:0    1   3G  0 rom
[root@myhost ~]#
Check the swap size
[root@myhost ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       2097088 0       -1
[root@myhost ~]#
Turn off the swap
[root@myhost ~]# swapoff -v /dev/rhel/swap
swapoff /dev/rhel/swap
[root@myhost ~]#
Make swap
[root@myhost ~]# mkswap /dev/rhel/swap
mkswap: /dev/rhel/swap: warning: wiping old swap signature.
Setting up swapspace version 1, size = 4194240 KiB
no label, UUID=07620b10-fc56-429f-a433-4caa67594d47
[root@myhost ~]#
Check the swap
[root@myhost ~]# swapon -va
swapon /dev/mapper/rhel-swap
swapon: /dev/mapper/rhel-swap: found swap signature: version 1, page-size 64, same byte order
swapon: /dev/mapper/rhel-swap: pagesize=65536, swapsize=4294967296, devsize=4294967296
[root@myhost ~]#
Check the swap size
[root@myhost ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       4194240 0       -1
[root@myhost ~]#

Tidak ada komentar :

Posting Komentar