[ncolug] Re: My LVM/RAID Presentation

  • From: "M. Knisely" <charon79m@xxxxxxxxx>
  • To: ncolug@xxxxxxxxxxxxx
  • Date: Fri, 04 Aug 2006 19:03:57 -0400

Chuck,

It was a great presentation. I agree totally, I'm using LVM from now on. I always thought of LVM as simply spanning a volume across multiple physical drives. I never even considered all the other benefits of it.

Wonderful presentation.  Thanks!

Mike K.

Chuck Stickelman wrote:
Here's the text file I put together for tonight's presentation.
I hope many found the presentation useful. I have certainly come to the conclusion that most Desktop/Laptop systems should be using LVM. As we saw tonight, supporting RAID is fairly trivial, once you learn the ins and outs of msadm.


Chuck

------------------------------------------------------------------------

Here are the steps needed to create LVM on a single device:
I am using /dev/sde (a USB flash drive) for this example.
More information can be found in /usr/share/doc/HOWTO/en-txt/LVM-HOWTO.gz

Steps:
1. Create any needed partitions on the drive (ex. /dev/sde1).
   Note: A drive can support both traditional and LVM partitions simultaneously.
   Note: You can use any partitioning utility to partition the device(s).

2. Create the Physical Volumes (PV) on the device. Run:
   (The documentation strongly recommends that only one Physical Volume (PV) 
exist on a single spindle.)
   Note: Run `man pvcreate` for more information.
        # pvcreate /dev/sde1

3. Create the Volume Groups (VG) on the PV. Run:
   Note: Run `man vgcreate` for more information.
        # vgcreate VG_NAME /dev/sde1

4. Create one or more Logical Volumes (LV), adding them to the VG created 
above. Run:
   Note: Run `man lvcreate` for more information.
        # lvcreate -L64M -ndemoLV1 VG01
        # lvcreate -L100M -ndemoLV2 VG01

5. Check the existence of the VG and the associated LVs. Run:
        # ls -l /dev/VG01/
        total 0
        lrwxrwxrwx 1 root root 24 2006-08-03 14:40 demoLV1 -> 
/dev/mapper/VG01-demoLV1
        lrwxrwxrwx 1 root root 24 2006-08-03 14:42 demoLV2 -> 
/dev/mapper/VG01-demoLV2

        # ls -l /dev/mapper/
        total 0
        crw-rw---- 1 root root  10, 63 2006-08-03 13:45 control
        brw-rw---- 1 root disk 253,  0 2006-08-03 14:52 VG01-demoLV1
        brw-rw---- 1 root disk 253,  1 2006-08-03 14:53 VG01-demoLV2

6. Create file-systems (FS) on the LVs. Run:
   Note: Run `man mke2fs` for more information.
        # mke2fs /dev/VG01/demoLV1
        # mke2fs /dev/VG01/demoLV2

7. Mount the FSs as you would any other block device. Run:
        # mount /dev/VG01/demoLV1 /media/usb1
        # mount /dev/VG01/demoLV2 /media/usb2

8. Check the stats of the mounted FSs. Run:
        # mount
        /dev/hda6 on / type ext3 (rw,errors=remount-ro)
        proc on /proc type proc (rw)
        sysfs on /sys type sysfs (rw)
        usbfs on /proc/bus/usb type usbfs (rw)
        tmpfs on /dev/shm type tmpfs (rw)
        devpts on /dev/pts type devpts (rw,gid=5,mode=620)
        /dev/hda3 on /boot type ext3 (rw)
        tmpfs on /dev type tmpfs (rw,size=10M,mode=0755)
        /dev/mapper/VG01-demoLV1 on /media/usb1 type ext2 (rw)
        /dev/mapper/VG01-demoLV2 on /media/usb2 type ext2 (rw)

        # df -h
        Filesystem                      Size    Used    Avail   Use%    Mounted 
on
        /dev/hda6                       21G     5.7G    14G     29%     /
        tmpfs                           347M    0       347M    0%      /dev/shm
        /dev/hda3                       964M    43M     869M    5%      /boot
        tmpfs                           10M     160K    9.9M    2%      /dev
        /dev/mapper/VG01-demoLV1        62M     13K     59M     1%      
/media/usb1
        /dev/mapper/VG01-demoLV2        97M     13K     92M     1%      
/media/usb2

9. Use e2fsadm to shrink or grow the file-systems and their underlying LVs.
   Note: You can only grow a mounted FS/LV. You must unmount the FS in order to 
shrink the FS and LV.
   Note: Run `man e2fsadm` for more information.

For setting up LVM on a RAID system, the RAID must be built first.

1. Create the RAID.  Here I am using RAID Level 5, with 4 devices and no spares.
   Note: I'm using the first partition on each of 4 USB Flash drives: /dev/sda, 
/dev/sdb, /dev/sdc, and /dev/sdd.
   Run:
        # mdadm --create --chunk=32 --level=5 --raid-devices=4 
--parity=left-symmetric \
--auto=yes --spare-devices=0 --name=usbRAID /dev/md0 /dev/sda1 /dev/sdb1 
/dev/sdc1 /dev/sdd1

2. Checking the RAID device. Run:
        # ls -l /dev/md0        
        brw-rw---- 1 root disk 9, 0 2006-08-03 16:18 /dev/md0

3. Follow the above steps for creating the LVM volumes as above.



To unsubscribe send to ncolug-request@xxxxxxxxxxxxx with 'unsubscribe' in the 
Subject field.

Other related posts: