For this recipe, the setup has three SCSI disks that will be put into a logical volume using LVM. The disks are at /dev/sda, /dev/sdb, and /dev/sdc.
It is not currently possible to add a disk to a striped logical volume in LVM 1. Use LVM 2 with the lvm 2 format metadata if you wish to be able to do so able to do so.
Before you can use a disk in a volume group you will have to prepare it:
The following will destroy any data on /dev/sda, /dev/sdb, and /dev/sdc
Run pvcreate on the disks:
# pvcreate /dev/sda # pvcreate /dev/sdb # pvcreate /dev/sdc
Create a volume group
# vgcreate my_volume_group /dev/sda /dev/sdb /dev/sdc
Run vgdisplay to verify volume group
# vgdisplay --- Volume Group --- VG Name my_volume_group VG Access read/write VG Status available/resizable VG # 1 MAX LV 256 Cur LV 0 Open LV 0 MAX LV Size 255.99 GB Max PV 256 Cur PV 3 Act PV 3 VG Size 1.45 GB PE Size 4 MB Total PE 372 Alloc PE / Size 0 / 0 Free PE / Size 372/ 1.45 GB VG UUID nP2PY5-5TOS-hLx0-FDu0-2a6N-f37x-0BME0Y
If the volume group looks correct, it is time to create a logical volume on top of the volume group.
You can make the logical volume any size you like (up to the size of the VG you are creating it on; it is similar to a partition on a non LVM setup). For this example we will create just a single logical volume of size 1GB on the volume group. The logical volume will be a striped set using for the 4k stripe size. This should increase the performance of the logical volume.
# lvcreate -i3 -I4 -L1G -nmy_logical_volume my_volume_group lvcreate -- rounding 1048576 KB to stripe boundary size 1056768 KB / 258 PE lvcreate -- doing automatic backup of "my_volume_group" lvcreate -- logical volume "/dev/my_volume_group/my_logical_volume" successfully created
If you create the logical volume with a '-i2' you will only use two of the disks in your volume group. This is useful if you want to create two logical volumes out of the same physical volume, but we will not touch that in this recipe.
Create an ext2 file system on the logical volume
# mke2fs /dev/my_volume_group/my_logical_volume mke2fs 1.19, 13-Jul-2000 for EXT2 FS 0.5b, 95/08/09 Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 132192 inodes, 264192 blocks 13209 blocks (5.00%) reserved for the super user First data block=0 9 block groups 32768 blocks per group, 32768 fragments per group 14688 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Writing inode tables: done Writing superblocks and filesystem accounting information: done
Mount the file system on the logical volume
# mount /dev/my_volume_group/my_logical_volume /mnt
# df Filesystem 1k-blocks Used Available Use% Mounted on /dev/hda1 1311552 628824 616104 51% / /dev/my_volume_group/my_logical_volume 1040132 20 987276 0% /mnt
Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:58:11