Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
linux:lvm [2006/06/09 00:15] a created |
linux:lvm [2009/05/25 00:35] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| * [[http:// | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | ===== Example usage ===== | ||
| + | |||
| + | Start by looking at our existing disks | ||
| + | |||
| + | cat /proc/scsi/ | ||
| + | dmesg |grep sd | ||
| + | |||
| + | |||
| + | Next, partition the new disks using fdisk | ||
| + | |||
| + | fdisk /dev/sdb | ||
| + | |||
| + | |||
| + | * **p** to Print the existing table (should be blank) | ||
| + | * **n** to create a new partition | ||
| + | * **t** to change partition system ID to 8e (Linux LVM) | ||
| + | * **w** to write new table to disk | ||
| + | |||
| + | |||
| + | Repeat for /dev/sdc | ||
| + | Create the physical volumes | ||
| + | |||
| + | pvcreate /dev/sdb1 | ||
| + | pvcreate /dev/sdc1 | ||
| + | |||
| + | |||
| + | |||
| + | //NOTE: You can create multiple PVs on a single disk, but it is not recommended. Show existing Physical Volumes// | ||
| + | |||
| + | pvscan | ||
| + | |||
| + | |||
| + | Show Volume Groups | ||
| + | |||
| + | vgscan (should return nothing) | ||
| + | |||
| + | |||
| + | Create a Volume Group from the Physical Volumes | ||
| + | |||
| + | vgcreate opt_vg /dev/sdb1 /dev/sdc1 | ||
| + | |||
| + | |||
| + | //NOTE: You can specify PE size in vgcreate. Default is 4M. You'd use larger PE sizes for LVs greater than 256G. 65K PEs per LV.// | ||
| + | |||
| + | Show Volume Groups | ||
| + | |||
| + | vgscan (now shows the VG we created) | ||
| + | |||
| + | |||
| + | Display information about the VG | ||
| + | |||
| + | vgdisplay | ||
| + | |||
| + | |||
| + | Create a Logical Volume within the VG | ||
| + | |||
| + | lvcreate -l num_of_extents -n opt_lv opt_vg | ||
| + | lvcreate -L 100M -n opt_lv opt_vg | ||
| + | lvcreate -L 100M -n opt_lv -i num_stripes opt_vg | ||
| + | lvcreate -L 100M -n opt_lv opt_vg [PhysicalVolumePath] | ||
| + | |||
| + | |||
| + | Display information about the LV | ||
| + | |||
| + | lvdisplay | ||
| + | lvdisplay -m (Show maps. Compare striped vs un-striped) | ||
| + | |||
| + | |||
| + | Create a mount point | ||
| + | |||
| + | mkdir /opt/foo1 | ||
| + | mkdir / | ||
| + | |||
| + | |||
| + | Create a filesystem | ||
| + | |||
| + | mkfs.ext3 / | ||
| + | mkfs.ext3 / | ||
| + | |||
| + | |||
| + | Mount the filesystems | ||
| + | |||
| + | mount / | ||
| + | df -h | ||
| + | |||
| + | |||
| + | ===== Growing a Filesystem ===== | ||
| + | ==== Grow an EXT2/3 filesystem (with unmount) ==== | ||
| + | |||
| + | Unmount the FS | ||
| + | |||
| + | umount / | ||
| + | |||
| + | |||
| + | Extend the LV | ||
| + | |||
| + | lvresize -l +50 / | ||
| + | lvresize -L +200M / | ||
| + | |||
| + | |||
| + | fsck the filesystem | ||
| + | |||
| + | e2fsck -f / | ||
| + | |||
| + | |||
| + | Resize the filesystem | ||
| + | |||
| + | resize2fs / | ||
| + | |||
| + | |||
| + | Remount the filesystem | ||
| + | |||
| + | mount -t ext3 / | ||
| + | |||
| + | ==== Grow an EXT2/3 filesystem (without unmount) ==== | ||
| + | |||
| + | Extend the LV | ||
| + | |||
| + | lvresize -l +50 / | ||
| + | lvresize -L +200M / | ||
| + | |||
| + | |||
| + | Grow the filesystem | ||
| + | |||
| + | ext2online / | ||
| + | ext2online / | ||
| + | |||
| + | |||
| + | Grow a ReiserFS filesystem | ||
| + | Create a ReiserFS on / | ||
| + | |||
| + | mkreiserfs / | ||
| + | |||
| + | |||
| + | Mount the FS | ||
| + | |||
| + | df -h | ||
| + | lvresize -L +50M / | ||
| + | resize_reiserfs -f / | ||
| + | df -h | ||
| + | |||
| + | |||
| + | Add a Physical Volume to a VG | ||
| + | |||
| + | vgextend vgname /path/to/PV | ||
| + | |||
| + | ===== Resizing crypted LVM ===== | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||

