In this blog, we will extend a LUN presented to a Linux host from the SAN. The lun is carved into LVM so here is the process to extend the LVM volume.
- Clean up files if not required
- Mark the Physical Devices as Physical Volume
- Add the Physical Volumes to a Volume Group
- Creating Logical Volumes from the Volume Group Pool
- Format and Mount the Logical Volumes
- Make a note of all partitions and disks first
Disk Space cleanup
#Disk Space cleanup
The below command will tell you the top 10 largest files/folders in your current directory
sudo du -shx * | sort -rh | head -10
# If the disk is full is /var, you can use the below commands to perform initial cleanup.
yum clean all
# To clean up yum cache manually, remove the content in cache directory. Yum will rebuild this cache next time it checks for packages.
rm -rf /var/cache/yum/*
Checking HBA card information
# Show HBA info
lspci -nn | grep -i hba
or
ls -l /sys/class/fc_host
#To find the status of HBA ports
systool -c fc_host -v | grep port_state
more /sys/class/fc_host/host?/port_state
#To find the status of fc adapters
systool -c fc_host -v | grep port_name
cat /sys/class/fc_host/host?/port_name
Counting the number of existing disks on a system
fdisk -l 2> /dev/null | egrep '^Disk' | grep -v mapper | grep -v identifier | wc -l
Lists disks in scan
ls/sys/class/scsi_host
Mapping San Lun & Disk and FileSystem
If we wish to map out how the luns are connected to the filesystem.
[root@lnx03 ~]# for lunfind in `lsblk | grep disk | grep ^s | awk '{print $1}'`; do for mpoint in `lsblk /dev/$lunfind | grep lvm | awk '{print $NF}'`; do echo "$lunfind --> $mpoint --> $(smartctl -a /dev/$lunmap | grep "Logical Unit number WWNN" | awk -F":" '{print $2}')"; done; done
sda --> /demo-fs01 -->
sdb --> /demo-fs01 -->
Mapping San Lun & Disk and FileSystem – Alternate Approach
If we wish to map out how the luns are connected to the filesystem.
[root@lnx03 ~]# echo "DeviceName" "|" "LUN_ID"; echo "---------------------"; for lunfind in `lsblk | grep disk | grep ^s | awk '{print $1}'`; do echo -e "$lunfind \t--> $(smartctl -a /dev/$lunfind | grep "Logical Unit id" | awk -F":" '{print $2}')"; done
DeviceName | LUN_ID
---------------------
sda --> 0x60014053c7523e7faeb41f8bb8b107db
sdb --> 0x60014056d147dfeeca44034937600170
sdc --> 0x6001405a8213c3d09fb4f3992ea666fd
[root@lnx03 ~]#
Using lsscsi command to map out Lun and Hdd
If we wish to map out how the luns are connected to the filesystem.
root@lnx03 ~]# lsscsi --scsi --size
[3:0:0:0] cd/dvd NECVMWar VMware SATA CD01 1.00 /dev/sr0 - 1.07GB
[32:0:0:0] disk LIO-ORG disk01 4.0 /dev/sda 360014053c7523e7faeb41f8bb8b107db 5.69GB
[32:0:0:1] disk LIO-ORG disk02 4.0 /dev/sdc 36001405a8213c3d09fb4f3992ea666fd 5.58GB
[32:0:0:2] disk LIO-ORG disk03 4.0 /dev/sdb 360014056d147dfeeca44034937600170 5.47GB
[N:0:0:1] disk VMware Virtual NVMe Disk__1 /dev/nvme0n1 16.1GB
Scanning new disks on a system
[root@lnx03 ~]# for host in /sys/class/scsi_host/*; do echo "- - -" | sudo tee $host/scan; ls /dev/sd* ; done
- - -
/dev/sda /dev/sdb /dev/sdc
- - -
/dev/sda /dev/sdb /dev/sdc
- - -
/dev/sda /dev/sdb /dev/sdc
- - -
/dev/sda /dev/sdb /dev/sdc
- - -
/dev/sda /dev/sdb /dev/sdc
- - -
/dev/sda /dev/sdb /dev/sdc
RUN A PVSCAN TO CHECK ERRORS ON LVM
[root@lnx03 ~]#lvmdiskscan
or
[root@lnx03 ~]# pvscan
Devices file sys_wwid eui.0a9147b659350724000c296de3efb17c PVID yHDg1nLoW8Jg3iwNtMHkj3WatmRFlfwb last seen on /dev/nvme0n1p3 not found.
PV /dev/sda VG project01 lvm2 [<5.30 GiB / 0 free]
PV /dev/sdb VG project01 lvm2 [<5.10 GiB / 404.00 MiB free]
PV /dev/sdc VG project01 lvm2 [<5.20 GiB / <5.20 GiB free]
Total: 3 [<15.59 GiB] / in use: 3 [<15.59 GiB] / in no VG: 0 [0 ]
[root@lnx03 ~]#
File-s is a good way to check if the filesystem is in use or not.
root@redhat-1 ansible]# file -s /dev/mapper/project_ansible_vg-ansible_scripts
Run pvcreate to prepare a disk for lvm
[root@lnx03 ~]# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created.
[root@lnx03 ~]#
Check the volume group size and the disk constituents
root@lnx03 ~]# vgdisplay -v
Devices file sys_wwid eui.0a9147b659350724000c296de3efb17c PVID yHDg1nLoW8Jg3iwNtMHkj3WatmRFlfwb last seen on /dev/nvme0n1p3 not found.
--- Volume group ---
VG Name project01
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size <15.59 GiB
PE Size 4.00 MiB
Total PE 3991
Alloc PE / Size 2560 / 10.00 GiB
Free PE / Size 1431 / <5.59 GiB
VG UUID EWRGZq-tLd4-7xwJ-3ykG-9NMF-8rfc-YjQhQ9
--- Logical volume ---
LV Path /dev/project01/dockerdemo
LV Name dockerdemo
VG Name project01
LV UUID 3W2aec-Q943-ckLt-yI5v-5xtu-BFIn-Q0X0Mf
LV Write Access read/write
LV Creation host, time lnx03, 2023-10-26 09:52:59 +0100
LV Status available
# open 1
LV Size 10.00 GiB
Current LE 2560
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Physical volumes ---
PV Name /dev/sda
PV UUID 22yl88-9DaG-eAaK-2OIO-3i1o-NOuP-YZmyQF
PV Status allocatable
Total PE / Free PE 1356 / 0
PV Name /dev/sdb
PV UUID 2CRcdu-q9GK-73Cb-D1rD-ix9l-BZRu-02OqtP
PV Status allocatable
Total PE / Free PE 1305 / 101
PV Name /dev/sdc
PV UUID i6ie94-1eg7-ygm9-kbdq-qPST-bPlg-zqjQ5t
PV Status allocatable
Total PE / Free PE 1330 / 1330
Extend the volume group (VG ) with the above pvdisk
[root@lnx03 ~]# vgextend project01 /dev/sdd
Volume group "project01" successfully extended
Check the volume group size and the disk constituents
[root@lnx03 ~]# vgdisplay -v project01
Devices file sys_wwid eui.0a9147b659350724000c296de3efb17c PVID yHDg1nLoW8Jg3iwNtMHkj3WatmRFlfwb last seen on /dev/nvme0n1p3 not found.
--- Volume group ---
VG Name project01
System ID
Format lvm2
Metadata Areas 4
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 4
Act PV 4
VG Size <25.59 GiB
PE Size 4.00 MiB
Total PE 6550
Alloc PE / Size 2560 / 10.00 GiB
Free PE / Size 3990 / <15.59 GiB
VG UUID EWRGZq-tLd4-7xwJ-3ykG-9NMF-8rfc-YjQhQ9
--- Logical volume ---
LV Path /dev/project01/dockerdemo
LV Name dockerdemo
VG Name project01
LV UUID 3W2aec-Q943-ckLt-yI5v-5xtu-BFIn-Q0X0Mf
LV Write Access read/write
LV Creation host, time lnx03, 2023-10-26 09:52:59 +0100
LV Status available
# open 1
LV Size 10.00 GiB
Current LE 2560
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Physical volumes ---
PV Name /dev/sda
PV UUID 22yl88-9DaG-eAaK-2OIO-3i1o-NOuP-YZmyQF
PV Status allocatable
Total PE / Free PE 1356 / 0
PV Name /dev/sdb
PV UUID 2CRcdu-q9GK-73Cb-D1rD-ix9l-BZRu-02OqtP
PV Status allocatable
Total PE / Free PE 1305 / 101
PV Name /dev/sdc
PV UUID i6ie94-1eg7-ygm9-kbdq-qPST-bPlg-zqjQ5t
PV Status allocatable
Total PE / Free PE 1330 / 1330
PV Name /dev/sdd
PV UUID r85K3X-h43L-6XjT-denc-P436-lsTp-kfeNvv
PV Status allocatable
Total PE / Free PE 2559 / 2559
Check the logical volume group
root@lnx03 ~]# lvdisplay
Devices file sys_wwid eui.0a9147b659350724000c296de3efb17c PVID yHDg1nLoW8Jg3iwNtMHkj3WatmRFlfwb last seen on /dev/nvme0n1p3 not found.
--- Logical volume ---
LV Path /dev/project01/dockerdemo
LV Name dockerdemo
VG Name project01
LV UUID 3W2aec-Q943-ckLt-yI5v-5xtu-BFIn-Q0X0Mf
LV Write Access read/write
LV Creation host, time lnx03, 2023-10-26 09:52:59 +0100
LV Status available
# open 1
LV Size 10.00 GiB
Current LE 2560
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
extend and resize the logical volume by 10gb
[root@lnx03 ~]# lvextend -L +10G /dev/project01/dockerdemo --resizefs
Size of logical volume project01/dockerdemo changed from 10.00 GiB (2560 extents) to 20.00 GiB (5120 extents).
File system xfs found on project01/dockerdemo mounted at /demo-fs01.
Extending file system xfs to 20.00 GiB (21474836480 bytes) on project01/dockerdemo...
xfs_growfs /dev/project01/dockerdemo
meta-data=/dev/mapper/project01-dockerdemo isize=512 agcount=4, agsize=655360 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2621440 to 5242880
xfs_growfs done
Extended file system xfs on project01/dockerdemo.
Logical volume project01/dockerdemo successfully resized.
Check the logical volume group
[root@lnx03 ~]# lvdisplay
Devices file sys_wwid eui.0a9147b659350724000c296de3efb17c PVID yHDg1nLoW8Jg3iwNtMHkj3WatmRFlfwb last seen on /dev/nvme0n1p3 not found.
--- Logical volume ---
LV Path /dev/project01/dockerdemo
LV Name dockerdemo
VG Name project01
LV UUID 3W2aec-Q943-ckLt-yI5v-5xtu-BFIn-Q0X0Mf
LV Write Access read/write
LV Creation host, time lnx03, 2023-10-26 09:52:59 +0100
LV Status available
# open 1
LV Size 20.00 GiB
Current LE 5120
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
Extend logical volume with all space on vg
lvextend -L +100%FREE /dev/project01/dockerdemo --resizefs
or
[root@lnx03 ~]# lvextend -L +2G /dev/project01/dockerdemo --resizefs
Size of logical volume project01/dockerdemo changed from 20.00 GiB (5120 extents) to 22.00 GiB (5632 extents).
File system xfs found on project01/dockerdemo mounted at /demo-fs01.
Extending file system xfs to 22.00 GiB (23622320128 bytes) on project01/dockerdemo...
xfs_growfs /dev/project01/dockerdemo
meta-data=/dev/mapper/project01-dockerdemo isize=512 agcount=8, agsize=655360 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1
data = bsize=4096 blocks=5242880, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 5242880 to 5767168
xfs_growfs done
Extended file system xfs on project01/dockerdemo.
Logical volume project01/dockerdemo successfully resized.
Display the status of the logical volume
root@lnx03 ~]# lvdisplay -v
Devices file sys_wwid eui.0a9147b659350724000c296de3efb17c PVID yHDg1nLoW8Jg3iwNtMHkj3WatmRFlfwb last seen on /dev/nvme0n1p3 not found.
--- Logical volume ---
LV Path /dev/project01/dockerdemo
LV Name dockerdemo
VG Name project01
LV UUID 3W2aec-Q943-ckLt-yI5v-5xtu-BFIn-Q0X0Mf
LV Write Access read/write
LV Creation host, time lnx03, 2023-10-26 09:52:59 +0100
LV Status available
# open 1
LV Size 22.00 GiB
Current LE 5632
Segments 4
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
Verify if the filesystem is resized
[root@lnx03 ~]# df -H
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.2M 0 4.2M 0% /dev
tmpfs 918M 0 918M 0% /dev/shm
tmpfs 368M 8.5M 359M 3% /run
/dev/mapper/rhel_unknown-root 13G 2.9G 9.9G 23% /
/dev/nvme0n1p2 1.1G 254M 810M 24% /boot
/dev/nvme0n1p1 628M 7.4M 621M 2% /boot/efi
/dev/mapper/project01-dockerdemo 24G 199M 24G 1% /demo-fs01
tmpfs 184M 4.1k 184M 1% /run/user/0
[root@lnx03 ~]#
(Visited 67 times, 1 visits today)