Create LVM in Linux
Create LVM in Linux
Create LVM in Linux
## 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
Also Linux shell is a user interface used for executing the commands........
This article describes a basic logic behind a Linux logical volume manager by showing real examples
of configuration and usage. Although Debian Linux will be used for this tutorial, you can also apply the
same command line syntax with other Linux distributions such as Red Hat, Mandriva, SuSe Linux and
others.
Use your preferred partitioning tool to create partitions. In this example I have used cfdisk.
Partitions are ready to use.
# pvcreate /dev/sdb1
# pvcreate /dev/sdb2
The pvdisplay command displays all physical volumes on your system.
# pvdisplay
# pvdisplay /dev/sdb1
To create a logical volume, named "vol01", with a size of 400 MB from the virtual group "mynew_vg"
use the following command:
With a following example you will create a logical volume with a size of 1GB and with the name vol02:
Or
# mkfs.ext3 -m 0 /dev/mynew_vg/vol01
the -m option specifies the percentage reserved for the super-user, set this to “0” if you wish not to
waste any space, the default is 5%
Edit /etc/fstab
Add an entry for your newly created logical volume into /etc/fstab
Mount logical volumes
Before you mount do not forget to create a mount point.
# mkdir /home/foobar
Extend logical volume
The biggest advantage of logical volume manager is that you can extend your logical volumes any time
you are running out of the space. To increase the size of a logical volume by another 800 MB you can run
this command:
The command above does not actually increase the physical size of volume, to do that you need to:
# resize2fs /dev/mynew_vg/vol01
Look at the figure below to see what problems you may encounter when extending a volume:
6.How to reduce the File system size in Linux?
#resize2fs -f /dev/VolGroup00/LogVol00 3G
#lvreduce -L 5G /dev/VG1/Lvol1
Remove logical volume
The command lvremove can be used to remove logical volumes. Make sure that before you attempt to
remove logical volumes your logical volume does not have any valuable data stored on it, moreover,
make sure the volume is unmounted.
# lvdisplay
# lvremove /dev/mynew_vg/vol02
How to find server is configured with LVM RAID ?
#cat /proc/mdstat
or
# lsraid -a /dev/mdx
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.
How to check Linux server is configured with power path disks?
#/etc/init.d/PowerPath status
#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.
What is lvmdump ?
Answer: “lvmdump” is tool for LVM2 to collect the various information for diagnostic
purposes.
Assume Volume group “vg02” is already exists. How do you extend the volume group with
50GB ? Provide all the steps with commands.
Answer:
1.Get the 50GB lun from SAN team.(/dev/sdd)
2.Create physcical volume ( # pvcreate /dev/sdd )
2.Extend the volume group (# vgextend vg02 /dev/sdd)
If the vg02 has two physical volumes called /dev/sdc/ & /dev/sdd. How do you remove
/dev/sdd from vg02.
Answer: “vgreduce vg02 /dev/sdd/”