Tag Archives: linux debian vmware virtual hard disk space partition

Adding disk space Debian Linux on VMWare

This is for an installation of Debian Linux (Lenny) that is run as a VMWare virtual machine on ESX server. The Debian install is also using LVM Logical Volume Manager. Refs: Overview at WikiPedia and the detailed How-To at tldp.org.

We had to increase the physical drive space on the debian system and while I verified some of what I planned to do with other sites I found a number of steps missing if I wanted to be ‘sure’ of being able to repeat the exercise.

Once the VMWare virtual disk had been allocated/increased I could start with the work inside Debian so it could use the space.

The first step was to install parted to manage the partitions as it makes it easy.

[php]# apt-get install parted[/php]

Next, because I want to run in single user mode I cannot use my favourite tool, PuTTy to connect as the SSH daemon will not be loaded. So I use VMWare client vSphere to connect and open a console.

[php]# telinit 1 [/php]

will restart in single user mode – you will need the root password for the server.

Start parted
[php]#parted[/php]

and use the command print free to list your drive(s) / partitions.
[php](parted)print free[/php]

which should display a screen similar to my completed example below. Once you can see the details of the free space you can use the resize command to increase the size of the extended volume. In this example my original part #2 was 21.2GB in size and this process increased it to the 107GB that was now allocated. The following steps will need to be adjusted for the specific system details.

[php](parted)resize
(parted)Partition number?2
(parted)Start? [255MB]?255MB
(parted)End? [21.2G]?107GB
(parted)print free[/php]

For my change the result of line #2 in this is correct as the partition is now approx 107GB in size rather than 21.2GB. In the next step I setup so that the logical volume #6 will be added.

Parted console after completing the addition of sda6 space

Once the extended partition is configured the server will need to be restarted.

[php]#shutdown -r now[/php]

Still using the VMWare console, as the startup screen appears the option to select single user mode will come up. If you miss it and start up in multi-user mode just use the telinit 1 command that we used earlier to return as single user mode.

Use cfdisk to view the disk setup.

[php]#cfdisk[/php]

This screen shows the completed sda6 logical drive.

Screenshot of cfdisk with updated partitions.

To allocate the free space arrow down to the free space and press the letter T for type. Select the type of drive that is required. In this example I selected 8E from the second page of types to use with Linux LVM.

Select Write from the command menu and yes to write the allocation table information for the new volume. In this case it is allocated as sda6.

Quit out of cfdisk.

At this stage if you are not using LVM on the server you will need to format the drive and add it into fstab, etc., however this server is using LVM and these are the next steps.

There are three levels Physical Volume, Volume Group, and Logical Volume. Using the lvm shell (good with help screens) or commands direct at the prompt (if you know what you are doing).

[php]#pvcreate /dev/sda6
#vgcreate new_volume_group_label /dev/sda6
#pvdisplay[/php]

Adds the Physical Volume (pv) into LVM while the vgcreate adds a new Volume Group (rather than extending the existing VG) and pvdisplay just presents the confirmation that its all worked.

[php]#lvcreate -L -n
#lvscan[/php]

Once created the logical volumes then need to be formatted or have their file system created.

[php]mke2fs /dev/lvname[/php]

Which creates the file system and then to add the journal setup

[php]tune2fs -j /dev/lvname[/php]

After this add the new drive into /etc/fstab with the relevant entries and directory(s) added.

One last reboot (or two if its wrong!) to check that it will all start up in single user mode and then a full restart and test in multi-user.