Michael R. Head (suppressingfire) wrote,
Michael R. Head

Loading in a new virtual disk into a Linux virtual machine

When working with virtual machines, it's not uncommon to expand the VM's storage capacity by attaching a new virtual disk. Unfortunately, the kernel doesn't seem to support hotplugging of these items, so to begin using the new disk, either the VM needs to be rebooted or the kernel needs to be told to run a re-scan manually.

This is discussed elsewhere, but I always have a hard time locating the exact command to do this.

Here's how I'm doing it:

for HOST in /sys/class/scsi_host/host*; do 
    echo "- - -" | sudo tee $HOST/scan; 
cat /proc/partitions

If the new device was found, this should result in some syslog messages from the kernel, and a new drive (perhaps sdb) should now exist in /proc/partitions. fdisk should be run on the new drive to set up partitions and mkfs.ext3 (or some filesystem creation tool) should be run to initialize the partitions as desired.

Update (2010-05-19): Don't use fdisk -l, check /proc/partitions.
Tags: linux, virtualization
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.