Tuesday, May 31, 2011

VMware Virtual Disk Hot Add for Linux guests



With VMware ESX 3.0 it is possible to hot add a new virtual disk to a running guest. I want to show what to do to use it with a linux guest without a reboot:
  1. add a new disk to the running guest via VI-Client
  2. scan for new hard disk in the guest
3.    echo "- - -" > /sys/class/scsi_host/host0/scan
for reference the output of
cat /proc/scsi/scsi
before
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 02
and after the scan
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 02
Attached devices:
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI SCSI revision: 02
  1. find out the device of the new hard disk (/dev/sdb in the example above)
  2. check if there is really no partition on the device
6.    fdisk -l /dev/sdb
7.     
8.    Disk /dev/sdb: 1073 MB, 1073741824 bytes
9.    255 heads, 63 sectors/track, 130 cylinders
10. Units = cylinders of 16065 * 512 = 8225280 bytes
11.  
12. Disk /dev/sdb doesn't contain a valid partition table
  1. create new partition on the device (with fdisk)
  2. create new filesystem on the partition created above
15. mkfs.ext3 /dev/sdb1
  1. add line to /etc/fstab to automount partition after next reboot
17. /dev/sdb1       /mountpoint       ext3    defaults        0       2

No comments:

Post a Comment