This shows you the differences between two versions of the page.
lvm_handling [2011/06/10 10:38] root [Prepare new disk/VolumeGroup/Logical Volume] |
lvm_handling [2017/04/16 23:50] (current) root [Prepare new disk/VolumeGroup/Logical Volume] |
||
---|---|---|---|
Line 2: | Line 2: | ||
===== Prepare new disk/VolumeGroup/Logical Volume ===== | ===== Prepare new disk/VolumeGroup/Logical Volume ===== | ||
+ | |||
+ | Add disk/LUN to server. Have a look at [[rescan_scsi_bus|Rescan SCSI bus]] for scanning the SCSI bus online. Alternative reboot the server. | ||
Prepare PV's with | Prepare PV's with | ||
Line 8: | Line 10: | ||
Create VG | Create VG | ||
- | vgcreate <vgname> -s <PE size> <path to PV> | + | vgcreate <vgname> -s <Physical Extent size> <path to PV> |
| | ||
Create LV | Create LV | ||
Line 14: | Line 16: | ||
| | ||
Create filesytem | Create filesytem | ||
+ | |||
+ | EXT FS: | ||
mkfs.ext4 -F -b 4096 /dev/<vgname>/<lvname> | mkfs.ext4 -F -b 4096 /dev/<vgname>/<lvname> | ||
Depending on distribution use relevant ext2/ext3/ext4 file system type. | Depending on distribution use relevant ext2/ext3/ext4 file system type. | ||
+ | XFS FS: | ||
+ | mkfs.xfs /dev/<vgname>/<lvname> | ||
===== Resize existing Logical volume ===== | ===== Resize existing Logical volume ===== | ||
+ | |||
+ | Extend the disk on the underlying infrastructure (SAN LUN / Virtulization platform) | ||
+ | |||
+ | Make OS detect the changed disk size | ||
+ | |||
+ | echo 1 > /sys/block/<device>/device/rescan | ||
+ | |||
+ | Where the <device> paramter is the physical disk eg. sdb | ||
Resize Physical Volume | Resize Physical Volume | ||
pvresize /dev/<device> | pvresize /dev/<device> | ||
+ | |||
+ | If LUN is under multipath: | ||
+ | multipathd resize map <multipath_device> | ||
+ | |||
+ | Where <multipath_device> is mpath<x> or wwid depending on multipath configuration. | ||
Extend Logical Volume | Extend Logical Volume | ||
Line 27: | Line 46: | ||
Extend filesytem which resides on Logical Volume | Extend filesytem which resides on Logical Volume | ||
+ | |||
+ | EXT FS: | ||
resize2fs /dev/<vgname>/<lvname> | resize2fs /dev/<vgname>/<lvname> | ||
- | + | ||
+ | XFS FS: | ||
+ | xfs_growfs /dev/<vgname>/<lvname> | ||
[[https://access.redhat.com/kb/docs/DOC-9855]] | [[https://access.redhat.com/kb/docs/DOC-9855]] | ||
+ | |||
+ | ===== Resize swap on Logical volume ===== | ||
+ | |||
+ | Determine which LV is in use by swap space | ||
+ | |||
+ | grep swap /etc/fstab | ||
+ | Example of output: | ||
+ | /dev/mapper/VolGroup00-LogVol01 swap swap defaults 0 0 | ||
+ | |||
+ | Disable swap: | ||
+ | | ||
+ | swapoff /dev/mapper/VolGroup00-LogVol01 | ||
+ | |||
+ | Resize swap space. | ||
+ | |||
+ | In this example swap spaze is adjusted to 4GB. | ||
+ | |||
+ | lvresize -L 4G /dev/mapper/VolGroup00-LogVol01 | ||
+ | |||
+ | Setup swap area on LV | ||
+ | |||
+ | mkswap /dev/mapper/VolGroup00-LogVol01 | ||
+ | |||
+ | Enable swap space again | ||
+ | |||
+ | swapon /dev/mapper/VolGroup00-LogVol01 | ||
+ | | ||
+ | Verify with top or /proc/swaps: | ||
+ | | ||
+ | top | ||
+ | |||
+ | output:\\ | ||
+ | top - 13:32:16 up 14 min, 2 users, load average: 0.22, 0.08, 0.02\\ | ||
+ | Tasks: 138 total, 2 running, 136 sleeping, 0 stopped, 0 zombie\\ | ||
+ | Cpu(s): 4.2%us, 1.5%sy, 0.0%ni, 93.0%id, 1.1%wa, 0.0%hi, 0.1%si, 0.0%st\\ | ||
+ | Mem: 3925256k total, 486996k used, 3438260k free, 102092k buffers\\ | ||
+ | //**Swap: 4194296k total**//, 0k used, 4194296k free, 118264k cached | ||
+ | |||
+ | cat /proc/swaps | ||
+ | Filename Type Size Used Priority | ||
+ | /dev/dm-1 partition 4194296 0 -1 | ||
+ | |||
+ | |||
+ | |||