Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Imagine you accidentally use mount --bind to hide /bin so that umount (and most other binaries) is not visible any more.

How would you get out of this situation?

Is there any way except a hard reboot?

share|improve this question
    
There is at least one way out of that as long as you can still compile programs. With /bin/ gone that might be interesting but not impossible. –  Hennes Aug 24 '13 at 13:51
2  
Hypothetical situation only, right? :) –  EEAA Aug 24 '13 at 13:52
1  
Just copy umount from any available server to the root folder and execute /root/umount ... –  ALex_hha Aug 24 '13 at 13:58
    
@ALex_hha With the assumption that the /bin folders are shadowed (one to be gone is enough since Arch Linux users only have one), things like cp and scp won't be available. –  nh2 Aug 24 '13 at 19:29
    
My guess is that the fastest way would be a perl one-liner. –  ott-- Aug 24 '13 at 22:58

4 Answers 4

Fortunately /bin is actually rather small, it's only very basic utilities and shells. As long as you have a root shell still open, you should be able to use the tools in /usr/bin to download the package that would have had mount in your distribution (eg apt-get install -d mount on Debian), then extract the file from the downloaded package manually (dpkg-deb -x mount.whatever.deb /some/temp/folder) and then use ./umount in that folder.

share|improve this answer

Hah, a reboot may not even work, as that may need tools from /bin too :)

I'm guessing these will not work:

  • scp'ing to the machine (your shell does not exist, login will be denied)
  • dpkg -x / dpkg -i / rpm -i as these are very likely to need things from /bin

I'd simply reboot. There's nothing wrong with that :)

If you don't want to reboot, I would try to scp/wget a copy of /bin/umount from another machine with the same os and run that.

share|improve this answer
    
Dammit I didn't think of the fact that the shell dosn't exist either, so far I thought scping from outside would work in case you have an ssh server running. –  nh2 Aug 24 '13 at 19:31

Actually, you could probably go back to those fine backups you are keeping and restoring the appropriate areas you are missing if you do not want to reboot. (personally, I'd reboot to keep things clean).

share|improve this answer
    
How do you restore a backup without essential programs being available? –  nh2 Aug 25 '13 at 5:26
    
depends on what is missing, and of course the procedure you are using to do backups. –  mdpc Aug 25 '13 at 22:12

if you root filesystem supports snapshot, you can take a snapshot, and copy the /bin files from the snapshot which should be copied to a partition (forgot you cannot mount it).

otherwise, if you have a spare partition, you can use dd to copy the root partition there and get /bin files back that way. likely with an external usb drive.

last, if you network works, you can just copy the command back from a similar system.

share|improve this answer
    
dd is in /bin. That won't work :) –  Dennis Kaarsemaker Aug 24 '13 at 16:15
    
@DennisKaarsemaker So is cp as well, unfortunately. –  Michael Kjörling Aug 24 '13 at 16:41
    
yeah, but not scp :) –  Dennis Kaarsemaker Aug 24 '13 at 16:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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