0

I have a computer with a hard drive mounted read-only. I am running a script from a flash drive. I would like the script to be able to unmount the flash drive, but this can't be performed as the script is still open for reading.

If I had another writable drive, I would copy the script to there and run it, but I don't see any place to put it. Is there some way to load a script into memory so that it can be run from there and the original script file can be closed?

0

Depending on your distribution, there might be several filesystems that are actually held in storage: mount | grep tmpfs might give you an idea.

In particular, at least my CentOS boxes have /run/user/(your UID) for every logged-in user, that would be a possible location. (I'm assuming here that your script is fairly small compared to main memory.) Your circumstances sounds like some sort of rescue mission, so you're probably root, so it would even always¹ be /run/user/0.

¹ in all practical cases

0

At the end you can send a command in the background,that will umount .

bash -c " ( sleep 10 ; echo umount /..../my-usb ) </dev/null >> /tmp/umount.log 2>&1 & "

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.