Saturday, February 26, 2011

Playing with Logical Volume Manager

Initialize disk using pvcreate
[root@rhel01 ~]# pvcreate /dev/sda1
Physical volume “/dev/sda1″ successfully created
Create volume group lab_group1
[root@rhel01 ~]# vgcreate lab_group1 /dev/sda1
Volume group “lab_group1″ successfully created
In this sample i created 10MB of logical volume mount to /mnt
[root@rhel01 ~]# lvcreate -L 10M lab_group1 -n lab01
Rounding up size to full physical extent 12.00 MiB
Logical volume “lab01″ created
[root@rhel01 ~]# mkfs.ext4 /dev/lab_group1/lab01
mke2fs 1.41.12 (17-May-2010)
[root@rhel01 ~]# mount /dev/lab_group1/lab01 /mnt
[root@rhel01 ~]# df -h /mnt
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/lab_group1-lab01
12M  1.2M   10M  11% /mnt
Extending Logical Volume using new disk
Initialize new disk
[root@rhel01 ~]# pvcreate /dev/sdb1
Wiping software RAID md superblock on /dev/sdb1
Physical volume “/dev/sdb1″ successfully created
Extend lab_group1 volume group
[root@rhel01 ~]# vgextend lab_group1 /dev/sdb1
Volume group “lab_group1″ successfully extended
[root@rhel01 ~]# vgdisplay lab_group1
— Volume group —
VG Name               lab_group1
System ID
Format                lvm2
Metadata Areas        2
Metadata Sequence No  3
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               0
Max PV                0
Cur PV                2
Act PV                2
VG Size               56.00 MiB
PE Size               4.00 MiB
Total PE              14
Alloc PE / Size       3 / 12.00 MiB
Free  PE / Size       11 / 44.00 MiB
VG UUID               o8kB09-P20F-QLFx-UmPE-5BB5-mlu9-o867qV
Extend logical volume lab01
[root@rhel01 ~]# lvextend -L +10M /dev/lab_group1/lab01
Rounding up size to full physical extent 12.00 MiB
Extending logical volume lab01 to 24.00 MiB
Logical volume lab01 successfully resized
[root@rhel01 ~]# df -h /mnt
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/lab_group1-lab01
12M  1.2M   10M  11% /mnt
[root@rhel01 ~]# resize2fs /dev/lab_group1/lab01
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/lab_group1/lab01 is mounted on /mnt; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/lab_group1/lab01 to 24576 (1k) blocks.
The filesystem on /dev/lab_group1/lab01 is now 24576 blocks long.
[root@rhel01 ~]# df -h /mnt
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/lab_group1-lab01
24M  1.2M   22M   5% /mnt

No comments:

Post a Comment