Saturday, November 30, 2013
Linux LVM Notes
For doing the same in Linux. Note that I usually work with multipathing so the notes below reflect that. Both Powerpath and native Linux multi path are included on the notes.
# Create a LVM VG (Linux)
# add disk masking & zoning (storage & SAN switch)
for i in 0 1 2 3 <...>;do echo "- - -">/sys/class/scsi_host/host$i/scan;done
# check for new disks
multipath -v2
# -v2 just for additional info, and this just for multipath if you're using powerpath see below
powermt config
# this is for power path
# if you're not using powerpath or multipath proceed using the sdNN device as PV
fdisk /dev/mapper/mpathz
# create a new partition
# this isn't required, LVM will handle the lun even if it's not partitioned but then
# fdisk -l will not be so handy
# if using powerpath fdisk command will be
fdisk /dev/emcpowerz
# and for non multipathed luns:
fdisk /dev/sdz
# your PV device will be /dev/mapper/mpathzp1, /dev/emcpowerz1 or /dev/sdz1
pvcreate /dev/mapper/mpathzp1
# or
pvcreate /dev/emcpowerz1
# or
pvcreate /dev/sdz1
# if needed create additional physical disks
# a volume group is made of one or more physical disks
vgcreate vgname /dev/mapper/mpathzp1
# additional disks physical disks may be specified
# specify the PV created before
# if adding several luns specify them all
vgcreate vgname /dev/mapper/mapthzp1 /dev/mapper/mpathyp1
# now create a logical volume
lvcreate -l 400 /dev/vgname /dev/vgname/lvol0
# this creates a logical volume '/dev/vgname/lvol0' with 10GB inside volume group 'vgname'
# (provided enough space is available
lvcreate -l 400 /dev/vgname
# creates a logical volume lvolN (N is an ordinal automatically assigned) on volume group
# vgname
mkfs -t ext4 /dev/vgname/lvol0
# to format logical volume /dev/vgname/lvol0 with ext4 (RH 6, on RH5 should be ext3)
/dev/vgname/lvol0 /mountdir ext4 defaults 0 0
# add this line to /etc/fstab so that the filesystem on /dev/vgname/lvol0 will be
# mounted automatically on each reboot
mount -a
# mount all filesystems specified on /etc/fstab which aren't mounted or
mount -t ext4 /dev/vgname/lvol0 /mountdir
# to mount the new filesystem on a specified directory
# Resize a filesystem (online when extending - to shrink it should be unmounted)
vgdisplay vgname
# check lines 'PE Size' and 'Free PE', it's the space available
vgextend /dev/vgname /dev/mapper/mpathaap1s
# if needed add more physical volumes to the volume group
lvextend -l 800 /dev/vgname/lvol0
# assuming that pe size is 256MB, extend /dev/vgname/lvol0 to 20 GB
resize2fs /dev/vgname/lvol0
# resizes the filesystem mounted on /mountdir to 20 GB
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment