Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have dozens of Ubuntu nodes where I have to resize the hard disk drive to different sizes. Currently I’m doing all of the following steps manually:

  1. Increase the size of each node’s virtual hard disk in VMware vCenter.
  2. Change the configuration of the DVD drive, mount a GParted ISO, boot from BIOS, and change the boot order.
  3. Boot into GParted, manually increase /dev/sda2 and /dev/sda5.
  4. Stop the VM, disable the DVD drive, and start the VM.
  5. Use lvextend -r /dev/ubuntu/root /dev/sda5 to extend the LVM and resize the partition to its maximum possible size.
  6. Optional: Check with df -h if everything’s OK.

I would love to automate this process, in a best case to provide a list of node names and corresponding sizes and let the tool do its job. In the case where there is no automated solution available I would love to hear about micro-optimizing every of these steps to make my tedious job easier.

We’re already automatically provisioning our nodes with Chef, and a VM template with a hard disk size of 16 GB.

Any smart ideas?

share|improve this question
    
Can you just mount additional filesystems where necessary? LVM and VMDKs is a bit redundant. –  ewwhite Jul 31 at 15:43

1 Answer 1

This can be done without a reboot or the nasty DVD step...

First, expand the disk at the vCenter/vSphere level. You know how to do that. It can also be automated or scripted.

Show your current block device size...

# fdisk -l 

Rescan the SCSI bus within the VM to realize the new drive size.

# echo 1 > /sys/class/scsi_disk/0:0:0:0/device/rescan

(Note: The disk identifiers may vary, but tend to correspond with the VM's SCSI device nodes. You'll likely see 0:0:0:0 for the root volume you're dealing with.)

Verify this with dmesg | tail or another fdisk -l

Continue with your LVM magic...

That should take care of everything.

share|improve this answer
    
The problem is that I would still have to start the VM from a live ISO, because you can’t resize the root partition while the OS is running. –  Rafael Aug 21 at 17:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.