2

I have an install of Ubuntu 20.04 VM in VMware. I have expanded the HD from 40 GB to 60 GB. I would like to get the system to recognize the additional space without a reboot. I tried running:

echo 1 > /sys/block/sda/device/rescan

which results in a permission denied. Tried it with sudo, same results.

I would like to not have to reboot the server for it to see the new space.What command or format would accomplish this task?

  • 3
    It's not clear what you're asking. Please use the exact terms, commands, outputs, etc. Don't paraphrase in your own words or we won't be able to follow you. Avoid summarizing so much that you leave out sufficient context to understand what you're trying to do. Make sure we can understand what is your goal, what exactly are you doing, what exactly did you expect, and what exactly was the real result. Also include any actions you've already take to fix this on your own as well as the details of your attempts. – Nmath Apr 24 '23 at 20:22
  • So I have added additional space to the drive for the Ubuntu virtual machine from 60G to 100G. What I want is for the system to scan and detect the new space without having to reboot the system. I have tried running echo 1 > /sys/block/sda/device/rescan which results in a permission denied response. I have tried adding like "sudo echo 1 > /sys/block/sda/device/rescan" with the same results. I am not a heavy Linux administrator as we only have about 6 out of 600 servers that are Ubuntu based. The current version I am working with is Ubuntu 20.04. Is there better command? – pcgeek2009 Apr 26 '23 at 14:26
  • So Ubuntu is installed to a virtual machine? And you're trying to increase the size of your virtual disk? Sorry... But it's still not very clear what's going on... What virtualization software are you using? Where are you coming up with these commands? Are you following some other research? Please share your research as well as any other guides you are following. Please do not "add comment". Please edit your question to keep it up-to-date. Comments are for us to ask clarification. Don't add details to comments. They don't let you use formatting tools and the character limit is restrictive. – Nmath Apr 26 '23 at 17:42
  • Yes. It is a virtual machine on VMware. I am trying to increase the size of the disk. I have expanded it in VMware, but the new space is not detected. I did this at another site and had to reboot the server before it saw it since I kept getting "permission denied" trying to run a scan command. I am wanting to detect the new free space without rebooting the server. The command I found is cho 1 > /sys/block/sda/device/rescan but that results in a "Permission denied" when I try to run it. – pcgeek2009 Apr 27 '23 at 18:45

1 Answers1

1

You can't use redirection with sudo - this is a known limitation.

Instead, pass the entire command (including redirection) to a subshell.

sudo bash -c 'echo 1 > /sys/block/sda/device/rescan'

Or use tee to do the redirection:

echo 1 | sudo tee /sys/block/sda/device/rescan
Artur Meinild
  • 26,018