VMware Cloud Community
curiousmind999
Contributor
Contributor
Jump to solution

Expand Space without Rebooting VM

Hi, is there a way that I can expand virtual disk space without rebooting VM.

I know that there is a command to recognize the device, but the device is already recognized (such as /dev/sdc), But now I need the OS (Linux) to recognize the additional space without rebooting.

thanks

Re-scan the SCSI Bus to Add a SCSI Device Without rebooting the VM using the following command

echo "- - -" > /sys/class/scsi_host/host#/scan  
1 Solution

Accepted Solutions
vuzzini
Enthusiast
Enthusiast
Jump to solution

Hello Curiousmind999,

Once you've changed the disk's size in VMware and did not reboot your server, rescan your SCSI devices as such.

First, check the name(s) of your scsi devices.

$ ls /sys/class/scsi_device/

Then rescan the scsi bus. Below you can replace the '0\:0\:0\:0′ with the actual scsi bus name found with the previous command. Each colon is prefixed with a slash, which is what makes it look weird.

~$ echo 1 > /sys/class/scsi_device/0\:0\:0\:0/device/rescan

That will rescan the current scsi bus and the disk size that has changed will show up.

If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Sandeep Vuzzini Sr. DevOps Engineer

View solution in original post

7 Replies
XavierEstevez
Contributor
Contributor
Jump to solution

Fair warning:

-You should definitely back up this VM before proceeding.

-It's best to practice this on a testing VM with the same OS to verify it'll work.

-You might end up having to reboot anyway.

Check out http://blog.pluralsight.com/resize-vmware-linux-drives assuming you're using RHEL.

One thing I've found is that sometimes fdisk does not correctly report the increased size of the disk, but cfdisk will. So if you did this to SDC, try:

sudo cfdisk /dev/sdc

and see if your extra space shows up there.

Good luck!

curiousmind999
Contributor
Contributor
Jump to solution

Thanks!

The article helped!


Reply
0 Kudos
vuzzini
Enthusiast
Enthusiast
Jump to solution

Hello Curiousmind999,

Once you've changed the disk's size in VMware and did not reboot your server, rescan your SCSI devices as such.

First, check the name(s) of your scsi devices.

$ ls /sys/class/scsi_device/

Then rescan the scsi bus. Below you can replace the '0\:0\:0\:0′ with the actual scsi bus name found with the previous command. Each colon is prefixed with a slash, which is what makes it look weird.

~$ echo 1 > /sys/class/scsi_device/0\:0\:0\:0/device/rescan

That will rescan the current scsi bus and the disk size that has changed will show up.

If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Sandeep Vuzzini Sr. DevOps Engineer
KpuCko
Contributor
Contributor
Jump to solution

@

root@debiantestlvm:~# echo "- - -" > /sys/class/scsi_host/host0/scan

root@debiantestlvm:~# echo "- - -" > /sys/class/scsi_host/host1/scan

root@debiantestlvm:~# echo "- - -" > /sys/class/scsi_host/host2/scan

Reply
0 Kudos
blentzz
Contributor
Contributor
Jump to solution

Sorry for posting on a thread that's so old, but this is the destination for many a google search, I suspect. And you've asked a valid question that deserves an explanation.

There's a difference between rescanning for new disks at the adapter level and rescanning for update size information at the disk level.

Sending "- - -" to /sys/class/scsi_host/host[012]/scan is telling the SCSI host adapter to look for new disks on every channel "(-)", every target "(-)", and every lun "(-)". - this is the right thing to do if you add a new disk to the system while it's powered on.

Sending a "1" to /sys/class/block/sdc/device/rescan is telling the SCSI block device to refresh it's information about where it's ending boundary is (among other things) to give the kernel information about it's updated size. - this is the right thing to do if you change the size of an existing disk while it's powered on.

HTH

vkenneth
Contributor
Contributor
Jump to solution

This an old thread but is the first hit when you search for this task.

blentzz  has provided the correct answered and helped me resolve this issue.

Thanks!

Reply
0 Kudos
jhs_hdat
Contributor
Contributor
Jump to solution

Hi all.

Another idea, especially if we are not clear on which scsi interface we have included the new disk:

$ for i in /sys/class/scsi_host/* ; do echo "- - - -" > $i/scan ; done

Running lsblk before and after executing the above loop will allow us to check that the new disk is already visible to the O.S.

Greetings.

Reply
0 Kudos