Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Thursday, 13 March 2014

Logical Volume in Linux : Interview Questions

Logical Volume in LVM: Interview Questions


Display:

#lvdisplay -v lvname

#lvs

To view mirror volumes

#lvs -a -o +devices
#lvs -a -o +seg_pe_ranges --segments

lvs attributes are:

1. volume type: (m)irrored, (M)irrored without initail sync, (o)rigin, (p)vmove, (s)napshot, invalid (S)napshot, (v)irtual, mirror (i)mage
                      mirror (I)mage out-of-sync, under (c)onversion
2. permissions: (w)rite, (r)ead-only
3. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
4. fixed (m)inor
5. state: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid (S)uspended snapshot, mapped (d)evice present with-out tables,
             mapped device present with (i)nactive table
6. device (o)pen (mounted in other words) 

Scan: 

#lvscan -v
#lvmdiskscan




Create / Extend / Reduce / Remove:

Create a Lvol

#lvcreate -L 10M -n lvol1 VGNAME  // To create plain lvol

#lvcreate -i 3 -I 32 -L 24M -n lvol1 vg01  //To create striped lvol

#lvcreate -L 10M -m1 -n lvol1 vg01  // To Create mirror lvol

Extend a Lvol 

#lvextend -L 20M /dev/VolData00/lvol01 

#fsadm resize /dev/VolData01/data01
#resize2fs -p /dev/mapper/VolData01-data01 [size] 

Reduce Lvol

#lvreduce -L 5M /dev/VolData00/lvol01 (or)
#lvresize -L 5M /dev/VolData00/lvol01

#fsadm resize /dev/VolData01/data01 [size]
#resize2fs -p /dev/mapper/VolData01-data01 [size] 


Rename / Snapshot / change attribute 


# lvrename /dev/VolData00/vol_old /dev/VolData00/vol_new    //Rename

# lvcreate --size 100M --snapshot -name snap /dev/vg01/data01    //Snapshot

#lvchange -a n /dev/VolData00/vol01   //Changing attribute

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