Skip to content

Increase space in Linux Volumegroup while running linux in vmware

If you like to increase space in linux volume group, you can do it on while machine up.

Afer added harddisk on existing hard disk. you can’t identify that hard disk on machine. So in this case you need to rescan the hard disk using below command.

$echo ‘1’  > /sys/class/scsi_disk/0:0:2:0/device/rescan

Suppose to be you’re added that hard disk after shutdown the machine. No need to rescan that harddisk

My case I shutdown the machine and added that hard disk in vmware workstation ( note: I think workstation you can’t expand hard disk while machine running)

Step 1:

Check Hard disk and space

[root@localhost dev]# df -h

Filesystem Size Used Avail Use% Mounted on
23G 2.9G 19G 14% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 502M 0 502M 0% /dev/shm

Step 2:

[root@localhost dev]# fdisk sda

The number of cylinders for this disk is set to 3916.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs

Command (m for help): p

Disk sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
sda1 * 1 13 104391 83 Linux
sda2 14 2610 20860402+ 8e Linux LVM
sda3 2611 3263 5245222+ 8e Linux LVM

Step 4:

Here Note the Last Cyclinder value is 3263. So your new partition should be start from Last Cyclinder value + 1 like 3264

Command (m for help): n
Command action
e extended
p primary partition (1-4)
Selected partition 4
First cylinder (3264-3916, default 3264):
Using default value 3264
Last cylinder or +size or +sizeM or +sizeK (3264-3916, default 3916):
Using default value 3916

Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

Step 6:

No need to reboot If you use this below command

[root@localhost dev]# partprobe -s

/dev/sda: msdos partitions 1 2 3 4

Step 7:

[root@localhost dev]# vgextend VolGroup00 /dev/sda4
No physical volume label read from /dev/sda4
Physical volume “/dev/sda4” successfully created
Volume group “VolGroup00” successfully extended
[root@localhost dev]# lvextend /dev/VolGroup00/LogVol00 /dev/sda4
Extending logical volume LogVol00 to 27.91 GB
Logical volume LogVol00 successfully resized
[root@localhost dev]# 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 7315456 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 7315456 blocks long.

Step 8: Check the hard disk size now

[root@localhost dev]# df -h
Filesystem Size Used Avail Use% Mounted on
28G 2.9G 23G 12% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 502M 0 502M 0% /dev/shm

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: