יום שני, 13 במאי 2013

Extend an LVM root filesystem

#fdisk -l
#fdisk /dev/sdb
e8 
w

#lvdisplay
#pvcreate /dev/sdb2

#vgextend VolGroup00 /dev/sdb2
(this associates the physical volume with our volume group VolGroup00)
At this point our new partition is available in our volume group as free space.  We use the following command to confirm that and also to record the amount of free space:
#vgdisplay
From the output of this command we should see an entry called “Free PE” – this is the free physical extents (in other words our free space).  We can use this value to extend our existing logical volume LogVol00 for example (this shows 1234 free extents):
#lvextend -l +1234 /dev/VolGroup00/LogVol00
After this command completes the logical volume LogVol00 will be extended by the amount of free space our new partition has.  You can display this using the command:
#lvdisplay
You should notice the “LV size” has increased.  At this point our / filesystem still doesn’t know about the new space, so the last piece of the jigsaw is to let it know about the new space:
#resize2fs /dev/VolGroup00/LogVol00
Once this command completes our / filesystem should see our new free space.  You can confirm this using the command:
#df -h /

useful link:
http://geekswing.com/geek/unix/extending-a-linux-disk-with-lvm-extending-root-partition/


Intermission to add new disk and power on if necessary
# fdisk -l
To see the new disk size on /dev/sda which we just extended, or to see new disks we just presented (/dev/sdb, /dev/sdc, etc.)
# fdisk /dev/sda
To create new partitions for the OS to use. These new partitions will be added to the VG so we can extend the LV that the “/” partition is on. My newly created partition in the example is /dev/sda3. For new disks you would use /dev/sdb, or /dev/sdc. If you are using an extended /dev/sda like in my case, you will need to reboot for the changes to be seen
# fdisk -l
To see the new partitions
# pvdisplay
View current physical volumes a.k.a. pv
# pvcreate /dev/sda3
Allow Linux OS to use the new partition in LVM
# pvdisplay
See the new pv /dev/sda3
# vgdisplay
View the current volume groups
# vgextend vg_cents6364bit /dev/sda3
Add the new PV /dev/sda3 to the existing VG vg_cents6364bit
# vgdisplay
Now you can see the new size of the VG vg_cents6364bit. Note the new amount of free PE’s (physical extents)
# lvdisplay
View the current LV. In my example, /dev/vg_cents6364bit/lv_root which is the root partition
# lvextend -l +2559 /dev/vg_cents6364bit/lv_root
Now make the LV larger. Growing the LV /dev/vg_cents6364bit/lv_root by 2559 PEs
# lvdisplay
Now you can see the larger size of the LV
# resize2fs /dev/vg_cents6364bit/lv_root
Online resize of the actual filesystem now on that LV
# df -h
You can see the new size now using the “df” command

DONE!!

אין תגובות:

הוסף רשומת תגובה