====== UNIX LVM disk management ======
===== Disk best practices =====
Best practice is to have a good design on system disk during deployment, as after the install it can be very difficult to review the OS storage.
**Logical Volume Manager** brings a virtualization level on disks and partitions management, with more flexibility, resizing, moving...
Why using multiple disks on a production server ?
* All access to data doesn't need the same level of availability, as cost is important, you can for example assign slow disks on archiving datas, high speed for database...
* For backup, to be able to use different backup policies we have to split the datas on different disks. On VMware the increment for backup is the disk, so to make a consistent backup, you have to split maybe the database on one disk, the OS on another, archives on another...
* On physical servers, we can also do snapshots on SAN disks, so it's important to think you storage
* On virtual servers, backup increment is the disk (Ex VMware), so be aware of you disk configuration
* LVM on Linux and AIX is also a best practice. LVM will bring flexibility in volume resizing, disks movements...
Why using LVM ?
* A volume manager is required (based installed) on AIX. On AIX, all disks are assigned to a volume group to be used (except special
case with Oracle RAC...). OS disk is also assign to a volume group, no boot partition, but instead a boot logical partition into the
rootvg volume group
* On Linux you can work on different ways, using static partitions, which can be very complicated to resize, with server downtime.
So better usage can be done if you use a volume manager (LVM). One filesystem has to be created based on a partition: /boot. All
other filesystems (volumes) can be included into a Volume group, including the the swap volume.
===== LVM =====
{{unix:unix_lvm01.jpg?650|}}
==== Physical Disks / hard drives ====
List Linux physical disks and partitions
[root@redhat01 ~]# lsscsi -s
[0:0:0:0] disk VMware Virtual disk 2.0 /dev/sda 268GB
[0:0:0:1] disk VMware Virtual disk 2.0 /dev/sdb 268GB
[root@redhat01 ~]# fdisk -l
Disk /dev/sda: 268.4 GB, 268435456000 bytes, 524288000 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: 0x0009f12e
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 524287999 261630976 8e Linux LVM
List AIX physical disks, no partitions on AIX
[root@aix01]/export/softs/openssl# lsdev -Cc disk
hdisk0 Available C5-T1-01 MPIO IBM 2076 FC Disk
hdisk1 Available C5-T1-01 MPIO IBM 2076 FC Disk
hdisk2 Available C5-T1-01 MPIO IBM 2076 FC Disk
hdisk3 Available C5-T1-01 MPIO IBM 2076 FC Disk
hdisk4 Available C5-T1-01 MPIO IBM 2076 FC Disk
hdisk5 Available C8-T1-01 MPIO Other FC SCSI Disk Drive
hdisk6 Available C5-T1-01 MPIO Other FC SCSI Disk Drive
==== Physical Volume ====
It a disk on AIX or Linux, or a disk partition on Linux, which has a type LVM, with a LVM physical volume identifier PVID or PV UUID (uniq ID)
**Example a partition on Linux**
[root@redhat01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <249.51g 0
[root@LIN-SDSMON01-VH ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <249.51 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 63874
Free PE 0
Allocated PE 63874
PV UUID jipWn3-SXwO-GS8R-fcj0-xxxx-xxxx-hd2Mx3
**Example a disk on AIX**
[root@aix01]/root# lspv
hdisk10 00c2fcc8dfe7288e altinst_rootvg
hdisk0 00fa343b8f050a76 rootvg active
hdisk5 00fa343b99011146 None
hdisk6 00fa343b990e37a0 None
hdisk1 00fa343b8f050ea7 None
hdisk2 00fa343b8f01b1e2 rootvg active
hdisk7 00fa343b990e38be None
hdisk8 00fa343b990e39ea nimvg active
hdisk9 00fa343b990e3b0b nimvg active
hdisk11 00c2fcc8dfe729fd altinst_rootvg
hdisk3 00fa343b98f0c47d SOURCEvg
hdisk4 00fa343b98f0c47d SOURCEvg
[root@aix01]/root# lspv hdisk0
PHYSICAL VOLUME: hdisk0 VOLUME GROUP: rootvg
PV IDENTIFIER: 00fa34xxxxx50a76 VG IDENTIFIER 00c2fcc800004c0000000xxxxxxd3dce
PV STATE: active
STALE PARTITIONS: 0 ALLOCATABLE: yes
PP SIZE: 128 megabyte(s) LOGICAL VOLUMES: 21
TOTAL PPs: 639 (81792 megabytes) VG DESCRIPTORS: 1
FREE PPs: 112 (14336 megabytes) HOT SPARE: no
USED PPs: 527 (67456 megabytes) MAX REQUEST: 512 kilobytes
FREE DISTRIBUTION: 01..00..00..00..111
USED DISTRIBUTION: 127..128..127..128..17
MIRROR POOL: None
==== Volume Group ====
A volume group 'll agregate one or multiple physical disks. In a VG, the space is devide in extend with a fix size, this size can't be changed. It a increment when you create logical volumes. In a VG, you can add or remove PVs.
A system can manage multiple VG, and each VG can have up to 1024 PV on AIX, and no limit on Linux
**Example a VG on Linux**
[root@redhat01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <249.51g 0
[root@redhat01 ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 17
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <249.51 GiB
PE Size 4.00 MiB
Total PE 63874
Alloc PE / Size 63874 / <249.51 GiB
Free PE / Size 0 / 0
VG UUID 9fkgje-aAf5-Zb8m-YPBi-khAj-xxxx-RoOqCZ
**Example a VG on AIX**
[root@aix01]/root# lsvg rootvg
VOLUME GROUP: rootvg VG IDENTIFIER: 00c2fcc800004c00000001xxxx1d3dce
VG STATE: active PP SIZE: 128 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 1278 (163584 megabytes)
MAX LVs: 256 FREE PPs: 224 (28672 megabytes)
LVs: 21 USED PPs: 1054 (134912 megabytes)
OPEN LVs: 20 QUORUM: 1 (Disabled)
TOTAL PVs: 2 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 2 AUTO ON: no
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 512 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
PV RESTRICTION: none INFINITE RETRY: no
DISK BLOCK SIZE: 512 CRITICAL VG: no
FS SYNC OPTION: no CRITICAL PVs: no
ENCRYPTION: no
[root@aix01]/root# lsvg -p rootvg
rootvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk2 active 639 112 01..00..00..00..111
hdisk0 active 639 112 01..00..00..00..111
==== Logical Volume ====
A volume group can be partitionned logicaly by defining Logical Volumes. These logical volumes can be extended, sometimes reduced, move from on PV to another into the same VG (useful for migration to new disks).
**On Linux**
[root@redhat01 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <247.51g
swap centos -wi-ao---- 2.00g
[root@redhat01 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID Jd4pYt-5OSL-Ks0c-ywGe-yJCu-xxxx-DSyaFs
LV Write Access read/write
LV Creation host, time localhost, 2015-09-23 16:24:57 +0200
LV Status available
# open 2
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID WQLbI3-M3sb-TtF6-enML-xxxx-pb3C-MqVVD0
LV Write Access read/write
LV Creation host, time localhost, 2015-09-23 16:24:57 +0200
LV Status available
# open 1
LV Size <247.51 GiB
Current LE 63362
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
**On AIX, list LV per VG**
[root@aix01]/export/softs/openssl# lsvg | xargs lsvg -l
rootvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
hd5 boot 1 2 2 closed/syncd N/A
hd6 paging 33 66 2 open/syncd N/A
hd8 jfs2log 1 2 2 open/syncd N/A
hd4 jfs2 92 184 2 open/syncd /
hd2 jfs2 91 182 2 open/syncd /usr
hd9var jfs2 48 96 2 open/syncd /var
hd3 jfs2 208 416 2 open/syncd /tmp
hd1 jfs2 197 394 2 open/syncd /home
hd10opt jfs2 48 96 2 open/syncd /opt
hd11admin jfs2 2 4 2 open/syncd /admin
lg_dumplv sysdump 18 18 1 open/syncd N/A
livedump jfs2 4 8 2 open/syncd /var/adm/ras/livedump
roothomelv jfs2 88 176 2 open/syncd /root
corelv jfs2 16 32 2 open/syncd /var/core
fslv01 jfs2 8 16 2 open/syncd /tftpboot
lg_dumplv2 sysdump 18 18 1 open/syncd N/A
nimvg:
LV NAME TYPE LPs PPs PVs LV STATE MOUNT POINT
loglv00 jfs2log 1 1 1 open/syncd N/A
mksysblv jfs2 6160 6160 5 open/syncd /export/mksysb
aix71lv jfs2 1680 1680 3 open/syncd /export/aix71
powerlinuxlv jfs2 80 80 1 closed/syncd /export/powerlinux
softlv jfs2 2761 2761 4 open/syncd /export/softs
==== Filesystem ====
A Logical Volume 'll have a mount point accessible in the unix tree, called a filesystem.