Score:0

Permission denied trying to run a rescan of disk in Ubuntu 20.04

tc flag

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?

Nmath avatar
ng flag
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.
pcgeek2009 avatar
tc flag
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?
Nmath avatar
ng flag
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.
pcgeek2009 avatar
tc flag
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.
Score:0
vn flag

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
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.