Although this post is primarily written for users of VMware Workstation 8 it is applicable for any RedHat 6 clone and adding disks with single path on the fly. Multipathing requires additional setup in dm-multipath or the vendor multipathing software which I won’t cover here. A quick hint though: you need to set disk.EnableUUID = “TRUE” in your VM’s config file for scsi_id to return a value.
The situation is common: you created a virtual machine and need more storage. Hopefully you created it using LVM which would allow you to add the new disk to an existing volume group followed by a resize operation of the logical volume which is short on space. But before you can do this you have to add a new LUN to your setup-here is how you can do this without rebooting the VM.
First I recommend you install lsscsi (for convenience, not really necessary) and the sg3_utils:
[root@server1 ~]# yum install lsscsi.x86_64 sg3_utils.x86_64 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package lsscsi.x86_64 0:0.23-2.el6 will be installed ---> Package sg3_utils.x86_64 0:1.28-4.el6 will be installed --> Processing Dependency: sg3_utils-libs = 1.28-4.el6 for package: sg3_utils-1.28-4.el6.x86_64 --> Processing Dependency: libsgutils2.so.2()(64bit) for package: sg3_utils-1.28-4.el6.x86_64 --> Running transaction check ---> Package sg3_utils-libs.x86_64 0:1.28-4.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Installing: lsscsi x86_64 0.23-2.el6 local 38 k sg3_utils x86_64 1.28-4.el6 local 470 k Installing for dependencies: sg3_utils-libs x86_64 1.28-4.el6 local 51 k Transaction Summary ======================================================================================================================================================================== Install 3 Package(s) Total download size: 559 k Installed size: 1.4 M Is this ok [y/N]: y Downloading Packages: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 25 MB/s | 559 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : sg3_utils-libs-1.28-4.el6.x86_64 1/3 Installing : sg3_utils-1.28-4.el6.x86_64 2/3 Installing : lsscsi-0.23-2.el6.x86_64 3/3 Installed: lsscsi.x86_64 0:0.23-2.el6 sg3_utils.x86_64 0:1.28-4.el6 Dependency Installed: sg3_utils-libs.x86_64 0:1.28-4.el6 Complete!
With this done it is easy to check the attached SCSI devices, and on my system I found these:
[root@server1 ~]# lsscsi [0:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda [0:0:1:0] disk VMware, VMware Virtual S 1.0 /dev/sdb [2:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0
This means there are two virtual disks and a virtual CD-ROM. Now it’s time to add the new disk. Do so using the user VMware workstation interface. Once completed, you need to rescan the scsi bus:
[root@server1 ~]# rescan-scsi-bus.sh Host adapter 0 (mptspi) found. Host adapter 1 (ata_piix) found. Host adapter 2 (ata_piix) found. Scanning SCSI subsystem for new devices Scanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 0 0 0 0 ... OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Scanning for device 0 0 1 0 ... OLD: Host: scsi0 Channel: 00 Id: 01 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Scanning for device 0 0 2 0 ... NEW: Host: scsi0 Channel: 00 Id: 02 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Scanning for device 0 0 2 0 ... OLD: Host: scsi0 Channel: 00 Id: 02 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Scanning host 1 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 2 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 2 0 0 0 ... OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00 Type: CD-ROM ANSI SCSI revision: 05 0 new device(s) found. 0 device(s) removed.
A new disk has been found, as shown by lscsi:
[root@server1 ~]# lsscsi [0:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda [0:0:1:0] disk VMware, VMware Virtual S 1.0 /dev/sdb [0:0:2:0] disk VMware, VMware Virtual S 1.0 /dev/sdc [2:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0 [root@server1 ~]#
Very nice-from there on it’s just another disk you can format using parted or fdisk. And you are done.
Interesting post Martin.
I personally never bother using a LVM (just another layer?) – I just put ext3/ext4 straight on top of the device. If I need to add space (not uncommon since I’m quite mean with my precious SSD) I increase it in VMware, use cfdisk to delete then recreate the partition to the maximum size (seems a bit scary I know!) and then extend the filesystem with resize2fs. Now admittedly I do usually seem to need a reboot before the extra space is visible (e.g. with df) though I’m not sure that is supposed to be the case.
Of course this is talking about test/lab VMs – you wouldn’t want to do this in production as it would probably be easy to make a mistake and trash the filesystem…
Hi Simon,
it does indeed sound a little scary, so just want to repeat the warning “do not do this in production” :) Is that technique applicable for ESXi or Workstation or both?
Martin
I will mostly have used this cfdisk technique on ESXi 4/5 but will have probably used it with Workstation 8 too. I used to boot the VM from a live CD ISO (e.g. like GParted Live) but don’t bother anymore (though that approach would still be useful for Windows VMs).
Pingback: Log Buffer #298, A Carnival of the Vanities for DBAs | The Pythian Blog
FYI, you can do this without any additional RPMs
ls /sys/class/scsi_host
should return host0, if so issue
echo “- – -” > /sys/class/scsi_host/host0/scan
fdisk -l should now show the new disk