Prepare physical volume (where diskname = sda, sdb, sdc,…)
- dd if=/dev/zero of=/dev/diskname bs=1k count=1 (NOTE: this is destructive to all data on this disk)
- blockdev –rereadpt /dev/diskname
- pvcreate /dev/diskname
Prepare Volume Group
-
vgcreate –s 1g my_vol_group /dev/diskname
- you can modify the extent size during vg creation
Create Logical Volume
Defined Size
- lvcreate –Lsize-in-MB –n lv-name my_vol_group
oracle es: lvcreate –L 8g –n olp2_u01xplv olp2_archxpvg
Defined Size with Stripes
- lvcreate –istripe-count –Istripe-size –lsize-in-extents –nlv-name my_vol_group
oracle stripe ex: lvcreate –i 3 –I 8 –l 10 –n olp2_u07xplv olp2_u07xpvg
natcat stripe es: lvcreate –i 5 –I 8 –L 175g –n olp2_u37xplv olp2_data37xpvg
Full Physical volume
- vgdisplay my_vol_group |grep “Total PE”
- lvcreate -l count-from-above my_vol_group –nlv-name
Create a file system
mkfs -t ext3 /dev/vg00/<volume name>
oracle stripe ex: mkfs –t ext3 –b 4096 –R stride=2 device (rhel3)
oracle stripe ex: mkfs –t ext3 –b 4096 –E stride=2 –T largefile device(rhel4)
NOTE: only specify –T largefile on /u02-/u09 file systems for oracle, allow default every where else
Modify a file system
Use tune2fs tp change the defaults of fsck every 30 mounts or 180 days
Activate Volume Group
- after a reboot or vgchange –an you will need to active the volume group
- vgchange –a y my_vol_group
Remove a volume group
- make the volume group inactive
- vgchange –a n my_vol_group
- remove the group
- vgremove my_vol_group
Adding Physical Device to Volume Group
- vgextend my_vol_group /dev/diskname
Removing Physical Device from Volume Group
- vgreduce my_vol_groupe /dev/diskname
Remove Logical Volume
- umount /file/sysmtem
- lvremove /dev/my_vol_group/lv-name
Extend a volume
Extend to defined size
- lvextend –L12G /dev/my_vol_group/lv-name
Extend by specific amount
- lvextend –L+1G /dev/my_vol_group/lv-name
Extend a filesystem
- resize2fs /dev/my_vol_group/lv-name
Extend volume and filesystem (1 command; not valid in 3.0 for online resize)
- e2fsadm –L+1G /dev/my_vol_group/lv-name
Extend a RHEL 4.0 file systems
- ext2online /mount-point will extend FS to end of the volume
Reduce a filesystem
- umount /filesystem
- resize2fs /dev/my_vol_group/lv-name size-in-blocks
Reduce a volume
- must be done umounted and after filesystem reduction
- lvreduce –L-1G /dev/my_vol_group/lv-name
Reduce both volume and fileystem (1 command; not valid 3.0)
- umount /filesystem
- e2fsadm –L-1G /dev/my_vol_group/lv-name
- mount /filesystem
Review summary of physical devices (4.0 only)
- pvs will show summary of physical device and volume groups
Review summary of volume group(4.0 only)
- vgs will show summary of volume group
Review summary of logical volume(4.0 only)
1. lvs will show summary of volume information
fdisk
- fdisk disk
- n to add a new disk
- choose your sizes
- t to change type
- w to write
swap space
- mkswap /dev/diskname
- swapon /dev/diskname
- fstab: /dev/diskname swap swap defaults 0 0
Decided mdadm would not do the job for you?
mdadm --create -f -lmp -n2 -x1 /dev/md0 /dev/<channela> /dev/<channelb>
This works in fail over mode by explicitly telling md to treat one as a spare.
Helpful Volume Management Commands
- To get a full list of all volume groups in 3.0: vgdisplay –s
- to get a full list of all logical volumes in 3.0: lvscan
Example volume creation
I did this:
dd if=/dev/zero of=/dev/sda bs=1k count=1
pvcreate /dev/sda
vgcreate -s 8M vg_oralp01_u01 /dev/sda
lvcreate -L 13.74G -n lvu01 vg_oralp01_u01
vgchange -a y vg_oralp01_u01
mkfs -t ext3 /dev/vg_oralp01_u01/lvu01
Example volume extension
Note: RHEL3 does not support online resizing of ext3 filesystems, RHEL4 does
dd if=/dev/zero of=/dev/sdj bs=1k count=1
blockdev –rereadpt /dev/sdj
pvcreate /dev/sdj
vgextend vg_oralp01_u01 /dev/sdj
vgdisplay vg_oralp01_u01|grep Free
umount /u01
e2fsadm -L+size_from_above /dev/vg_oralp01_u01/lvu01
mount /u01
Business Copy Procedures
- following a split, the volume group showed up and seemed valid
- the logical volume showed up but was flagged as inactive
- ran vgchange –ay <vgname>
- now volume is live and mounted
- looking good to go
- testing how to export/import volume group
- vgchange –an <vgname>
- vgexport <vgname>
- vgimport <vgname>
- vgchange –ay <vgname>