Linux LVM Interview Questions : Part 2

Questions: PART 2

1.What are LVM1 and LVM2?
2.What is the maximum size of a single LV?
3.List of important LVM related files and Directories?
4.What is the steps to create LVM in Linux?
5.How to extend a File system in Linux?
6.How to reduce the File system size  in Linux?
7.How to add new LUN from storage to Linux server?
8.How to resize root file system on RHEL 6?
9.How to find server is configured with LVM RAID ? 
10.How to check Linux server is configured with power path disks?
11.How to check server is configured with Multipath disks??




Answers:

1.What are LVM1 and LVM2?

LVM1 and LVM2 are the versions of LVM. 
LVM2 uses device mapper driver contained in 2.6 kernel version.
LVM 1 was included in the 2.4 series kernels.

2.What is the maximum size of a single LV?

For 2.4 based kernels, the maximum LV size is 2TB. 
For 32-bit CPUs on 2.6 kernels, the maximum LV size is 16TB.
For 64-bit CPUs on 2.6 kernels, the maximum LV size is 8EB. 

3.List of important LVM related files and Directories?

## Directories
/etc/lvm                - default lvm directory location
/etc/lvm/backup         - where the automatic backups go
/etc/lvm/cache          - persistent filter cache
/etc/lvm/archive        - where automatic archives go after a volume group change
/var/lock/lvm             - lock files to prevent metadata corruption

# Files
/etc/lvm/lvm.conf       - main lvm configuration file
$HOME/.lvm              - lvm history 


4.What is the steps to create LVM in Linux?

Create a physical volume by using pvcreate command

consider the disk is local.

#fdisk -l 

#fdisk /dev/sda

Press "n" to create new partition. And mention the size / allocate whole disk to single partition. and assign the partition number also.

#press "t" to change the partition as LVM partition. 

#enter "8e" ( 8e - is Hex decimal code for LVM ) 

#Enter "w" to write tghe information on Disk.

#fdisk -l ( Now you will get newly created disk numbers)

#pvcreate /dev/sda2

Add physical volume to volume group by “vgcreate” command

#vgcreate VLG0 /dev/sda2

Create logical volume from volume group by “lvcreate” command.

#lvcreate -L 1G -n LVM1 VG0

Now create file system on /dev/sda2 partition by “mke2fs”  or "mkfs.ext3" command.

#mke2fs -j /dev/VG0/LVM1

or 

#mkfs.ext3 /dev/vg0/LVM1

How to mount this as file system

#mkdir /test

#mount /dev/VG0/LVM1 /test  

5.How to extend a File system in Linux?

Check the free space on vg 

#vgdisplay -v VG1

Now extend the FS

# lvextend -L+1G /dev/VG1/lvol1

# resize2fs /dev/VG1/lvol1

6.How to reduce the File system size  in Linux?

1.First we need to reduce the file system size using "resize2fs"
2.Then reduce the lvol size using "lvreduce"

#resize2fs -f /dev/VolGroup00/LogVol00 3G

#lvreduce -L 5G /dev/VG1/Lvol1


7.How to add new LUN from storage to Linux server?

Step 1: Get the list of HBA and exisiting disk details.

#ls /sys/class/fc_host

#fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l

Step 2: Scan the HBA ports (Need to scan all HBA port)

#echo "1" > /sys/class/fc_host/host??/issue_lip

# echo "- - -" > /sys/class/scsi_host/host??/scan

Do this above steps for all HBA cards

Step3 : Check the newly added Lun     

# cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l

# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l


Once found the disk then do below steps to add to VolumeGroup

#pvcreate /dev/diskpath

#vgextend /dev/vg1 /dev/diskpath

#vgs or #vgdisplay /dev/vg1


8.How to resize root file system on RHEL 6?

Here is the list of steps to reduce the  root file system (lv_root) on a RHEL 6 Linux server:

Boot the system into rescue mode. Do not mount the file systems (select the option to 'Skip' in the rescue mode and start a shell)

Bring the Volume Group online

#lvm vgchange -a -y

Run fsck on the FS

#e2fsck -f /dev/vg_myhost/lv_root

Resize the file system with new size

#resize2fs -f /dev/vg00/lv_root 20G

Reduce the Logical Volume of the FS with the new size

#lvreduce -L20G /dev/vg00/lv_root

Run fsck to make sure the FS is still ok

#e2fsck -f /dev/vg00/lv_root

Optionally mount the file system in the rescue mode

#mkdir -p /mnt/sysimage/root
#mount -t ext4 /dev/mapper/vg00-lv_root /mnt/sysimage/root
#cd /mnt/sysimage/root

Unmount the FS

#cd
#umount /mnt/sysimage/root

Exit rescue mode and boot the system from the hard disk
#exit

Select the reboot option from the recue mode

9.How to find server is configured with LVM RAID ? 

1.How to check linux LVM RAID ?

 check the RAID status in /proc/mdstat

 #cat /proc/mdstat 
 or
 # mdadm --detail /dev/mdx
  or
 # lsraid -a /dev/mdx

2.Check the Volume group disks 

 #vgdisplay -v vg01

 In disk we will get the device names like /dev/md1 , /dev/md2 . It means LVM RAID disks are configured and its added to Volume Group.


10.How to check Linux server is configured with power path disks?

1.Check power path is installed on server?

#rpm -qa |grep -i emc

2.Check the power path status on server?

#/etc/init.d/PowerPath status

#chkconfig --list PowerPath

# lsmod |grep -i emc

3.Check the Volume group disks 

 #vgdisplay -v vg01

 In disk we will get the device names like /dev/emcpowera , /dev/emcpowerb . It means powerpath disks are configured and its added to Volume Group.

4.Check the power path disk status using below command

 #powermt display dev=all


11.How to check server is configured with Multipath disks??

# ls -lrt /dev/mapper  //To View the Mapper disk paths and Lvols

#dmsetup table 

#dmsetup ls 

#dmsetup status

2.Using Multipathd Command ( Daemon ) 


#echo 'show paths' |multipathd -k

#echo 'show maps' |multipathd -k

3.Check multipath Daemon is running or not 

#ps -eaf |grep -i multipathd

4.check the VG disk paths

#vgs or vgdisplay -v vg01 

If multipath disks are added and configured with VG then we will get disk paths like /dev/mpath0 , /dev/mpath1.

5.If you want to check the disk path status u can use below command also

#multipathd -k

#multipathd> show multipaths status

#multipathd> show topology

#multipathd> show paths


Post a Comment

5 Comments

  1. All kind of IT interview questions are just one click ahead @ http://skillgun.com

    ReplyDelete
  2. very useful for freshers(entry level)

    ReplyDelete
  3. Excellent
    , Very thankful to u

    ReplyDelete
  4. I am curious about, how many people use Linux? My friend, who had the experience in using this operating system, told me, that it is very complicated.

    ReplyDelete