사용자 도구

사이트 도구


os:debian:lvm:sample2

LVM 설정예제 2

Demonstration

  1. Start by looking at our existing disks
    cat /proc/scsi/
    dmesg |grep sd
  2. Next, partition the new disks using fdisk
    fdisk /dev/sdb
    1. p to Print the existing table (should be blank)
    2. n to create a new partition
    3. t to change partition system ID to 8e (Linux LVM)
    4. w to write new table to disk
  3. Repeat for /dev/sdc
  4. Create the physical volumes
    pvcreate /dev/sdb1
    pvcreate /dev/sdc1
  5. NOTE: You can create multiple PVs on a single disk, but it is not recommended. Show existing Physical Volumes
    pvscan
  6. Show Volume Groups
    vgscan (should return nothing)
  7. Create a Volume Group from the Physical Volumes
    vgcreate opt_vg /dev/sdb1 /dev/sdc1
  8. 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.
  9. Show Volume Groups
    vgscan (now shows the VG we created)
  10. Display information about the VG
    vgdisplay 
  11. 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]
  12. Display information about the LV
    lvdisplay
    lvdisplay -m (Show maps. Compare striped vs un-striped)
  13. Create a mount point
    mkdir /opt/foo1
    mkdir /opt/striped
  14. Create a filesystem
    mkfs.ext3 /dev/opt_vg/opt_lv
    mkfs.ext3 /dev/opt_vg/striped_lv
  15. Mount the filesystems
    mount /dev/opt_vg/opt_lv
    df -h 

Growing a Filesystem

Grow an EXT2/3 filesystem (with unmount)

  1. Unmount the FS
    umount /mnt/lvm_filesystem
  2. Extend the LV
    lvresize -l +50 /dev/opt_vg/opt_lv
    lvresize -L +200M /dev/opt_vg/opt_lv
    fsck the filesystem 
    e2fsck -f /dev/opt_vg/opt_lv
  3. Resize the filesystem
    resize2fs /dev/opt_vg/opt_lv
  4. Remount the filesystem
    mount -t ext3 /dev/opt_vg/opt_lv /mnt/lvm_filesystem

Grow an EXT2/3 filesystem (without unmount)

  1. Extend the LV
    lvresize -l +50 /dev/opt_vg/opt_lv
    lvresize -L +200M /dev/opt_vg/opt_lv
  2. Grow the filesystem
    ext2online /mnt/lvm_filesystem (using mount path)
    ext2online /dev/opt_vg/opt_lv (using device)

Grow a ReiserFS filesystem

  1. Create a ReiserFS on /dev/opt_vg/striped_lv
    mkreiserfs /dev/opt_vg/striped_lv
  2. Mount the FS
    df -h
    lvresize -L +50M /dev/opt_vg/striped_lv
    resize_reiserfs -f /dev/opt_vg/striped_lv
    df -h
  3. Add a Physical Volume to a VG
    vgextend vgname /path/to/PV
os/debian/lvm/sample2.txt · 마지막으로 수정됨: 2007/10/05 02:20 저자 starlits