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
HPUX LVM notes
Quite dumb to start this with HPUX, but anyway, there it goes:
# Create a LVM VG (HPUX)
# add disk masking & zoning (storage & SAN switch)
ioscan -fnNCdisk
# check for new disks
# you'll need the disk device '/dev/disk/diskNNN' ex: /dev/disk/disk175
pvcreate /dev/rdisk/disk175
# note that on pvcreate we use the raw (character) disk device
# if needed create additional physical disks
# a volume group is made of one or more physical disks
vgcreate -e 64000 -l 64 -s 256 -g PVGSTO vgname /dev/disk/disk175
# this creates a volume group with 64000 maximum extents of 256 MB and 64 logical volumes
# physical volume group will be named PVGSTO (this is useful when multiple storage tiers
# are used in the same volume group
# additional disks physical disks may be specified
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
newfs -F vxfs -o largefiles /dev/vgname/rlvol0
# to format logical volume /dev/vgname/lvol0 with vxfs - note 'rvol0': the character
# device should be specified
/dev/vgname/lvol0 /mountdir vxfs delaylog 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 vxfs /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 -g PVGSTO /dev/vgname /dev/disk/disk176
# 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
lvextend -l 800 /dev/vgname/lvol0 /dev/PVGSTO1
# extends /dev/vgname/lvol0 to 20GB using physical volume group 'PVGSTO1'
fsadm -b 20480M /mountdir
# resizes the filesystem mounted on /mountdir to 20 GB
Enjoy!
Subscribe to:
Comments (Atom)