Tuesday, December 04, 2007

Introduction to LVM with RHEL, Fedora or Centos Linux

This is the first part of an overview of Logical Volume Management. LVM was written originally by Heinz Mauelshagen in 1988. LVM has the advantages:
* Resizing of logical groups
* Resizing of logical volumes

* Snapshots from Read/Write volumes (in lvm2)

* Raid 0 of Logical Volumes.
In this example i will create physical volumes (in /dev/sdb), a logical group and then a logical volume inside the logical group.


Creating two Physical Volumes
[root@benancio ~]# dd if=/dev/zero of=/dev/sdb1 bs=1k count=1
1+0 records in 1+0 records out 1024 bytes (1.0 kB) copied, 0.00155322 seconds, 659 kB/s
[root@benancio ~]# dd if=/dev/zero of=/dev/sdb2 bs=1k count=1
1+0 records in 1+0 records out 1024 bytes (1.0 kB) copied, 0.000948061 seconds, 1.1 MB/s
[root@benancio ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created

[root@benancio ~]# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created

Create one Logical Group that will contain a logical Volume, which will be created in the next step
[root@benancio ~]# vgcreate users /dev/sdb1 /dev/sdb2
Volume group "users" successfully created

Create the Logical Volume.
[root@benancio ~]# lvcreate -L30M -n lv1_users users
Rounding up size to full physical extent 32.00 MB
Logical volume "lv1_users" created

Note:

-L LogicalVolumeSize[KMG]
-n Name of the new logical volume (lv1_users)
users is the name of the Logical Volume.


Now, create the filesystem over the logical volume created
[root@benancio ~]# mkfs.ext3 /dev/users/lv1_users
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux Block size=1024 (log=0)
Fragment size=1024 (log=0)
8192 inodes, 32768 blocks
1638 blocks (5.00%) reserved for the super user
First data block=1 Maximum filesystem blocks=33554432
4 block groups 8192 blocks per group, 8192
fragments per group

2048 inodes per group
Superblock backups stored on blocks:
8193, 24577

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or 180 days, whichever comes first. Use xtune2fs -c or -i to override.

To finish this introduction, you can mount the volume in a directory
[root@benancio ~]# mkdir /mnt/users
[root@benancio ~]# mount -t ext3 /dev/users/lv1_users /mnt/users

0 comentarios: