Activities

August 2008
M T W T F S S
« Jul   Oct »
 123
45678910
11121314151617
18192021222324
25262728293031

How to increase the root partion using LVM without unmounting

Add new disk to existing server

a, Exicute

#fdisk -l

it shows the added disk at the end of the line and display no valid partions found on there. Now we need to partion  the disk and create the  primary partion type as Linux LVM (8e)

here my disk is mounted as /dev/sdb

#fdisk /dev/sdb

For creating new partion press ‘p
1, Choose create it as primary partion
2, Just ok to the last 2 questions

Now we need to create  lvm file system
3, Press ‘t‘  for choosing file system
4, Enter “8e” for creating LVM file system
5, Press ‘w‘ to write the Disk and save the changes

Now we have partioned  disk on the server #fdsik -l

[root@localhost ~]# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         650     5116702+  8e  Linux LVM
/dev/sda3             651         715      522112+  82  Linux swap / Solaris

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         391     3140676   8e  Linux LVM

Now  I am showing the my linux box LVM status

[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  2
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               1
Max PV                0
Cur PV                1
Act PV                1
VG Size               4.88 GB
PE Size               32.00 MB
Total PE              156
Alloc PE / Size       156 / 4.88 GB
Free  PE / Size       0 / 0
VG UUID               7XZTPr-VJt8-QOTu-CUlv-mmrQ-7sPg-Wz2zfH
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name                /dev/VolGroup00/LogVol00
VG Name                VolGroup00
LV UUID                hI0dbV-ZcSP-XbGY-sBlj-jl7n-3daW-XJFcRG
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                4.88 GB
Current LE             156
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           253:0

Now I am going to create physical volume of the device /dev/sdb

[root@localhost ~]# pvcreate  /dev/sdb1
Physical volume "/dev/sdb" successfully created

Checking the physical volume status

[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name               /dev/sda2
VG Name               VolGroup00
PV Size               4.88 GB / not usable 4.78 MB
Allocatable           yes (but full)
PE Size (KByte)       32768
Total PE              156
Free PE               0
Allocated PE          156
PV UUID               vrl2zH-hndd-P8Th-GYvg-vLzS-oUjH-Z0pWCX

--- NEW Physical volume ---
PV Name               /dev/sdb
VG Name
PV Size               3.00 GB
Allocatable           NO
PE Size (KByte)       0
Total PE              0
Free PE               0
Allocated PE          0
PV UUID               rmdH0G-l20O-6gut-tiEx-dHsU-pvhn-g3FltO

Here it shows 2 physical volume(/dev/sda2 and /dev/sdb1(new) created on the server.

Next I am going to extended the volume of ‘VolGroup00‘ to use /dev/sdb and check it was updated properly.

[root@localhost ~]# vgextend  VolGroup00 /dev/sdb
Volume group "VolGroup00" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name               VolGroup00
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               1
Max PV                0
Cur PV                2
Act PV                2
VG Size               7.84 GB
PE Size               32.00 MB
Total PE              251
Alloc PE / Size       156 / 4.88 GB
Free  PE / Size       95 / 2.97 GB
VG UUID               7XZTPr-VJt8-QOTu-CUlv-mmrQ-7sPg-Wz2zfH

See it was extended  to my additional 3GB. Now I am going to extend the logical volume and checking it’s status

[root@localhost ~]# lvextend -L 6G /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 6.00 GB
Logical volume LogVol00 successfully resized
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name                /dev/VolGroup00/LogVol00
VG Name                VolGroup00
LV UUID                hI0dbV-ZcSP-XbGY-sBlj-jl7n-3daW-XJFcRG
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                6.00 GB
Current LE             192
Segments               2
Allocation             inherit
Read ahead sectors     0
Block device           253:0

Wonderful!!!!!!!!!!  it is updated to 6 GB. But my fdisk -l still shows my old HDD status 🙁

Now I am going to rezise the filesystem inorder to effect the space addition without unmounting the file system.

[root@localhost ~]# resize2fs  /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 1572864 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 1572864 blocks long.

Now I want to check whether my file system has increased it’s size

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5.9G  906M  4.7G  17% /
/dev/sda1              99M   12M   83M  13% /boot
tmpfs                 125M     0  125M   0% /dev/shm

Great !!!!!!!!!!!!!  it’s increased

I am facing the issue with resizing the file system. It shows the error that the cant’ resize the partion mounted. At that point

#ext2online /dev/VolGroup00/LogVol00

This too work while resize2fs shows the error.

1 comment to How to increase the root partion using LVM without unmounting

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>