4

I used this to give a chrooted ftp user access to another area of the filesystem:

mount --bind /var/www/dev/ /home/ftp_user/www_dev

per this website here.

And, oops, I realized I gave the ftp user access to too many files.

How do I fix that? rmdir doesn't work:

rmdir: failed to remove `www_dev': Device or resource busy

And if it did, I'm afraid it would remove the mounted files.

2 Answers 2

11

try umount -l /home/ftp_user/www_dev.

this will detach the file system immediately, and clean up any leftover references when it's no longer busy.

source: http://linux.die.net/man/8/umount

13
  • Great! thank you. This is your first ever answer on this site? I appreciate it. Commented Jan 19, 2015 at 2:29
  • yep. originally stopped by to ask an excel question, but still/currently pondering how to ask it. came across your question somehow. glad to help!
    – Erich
    Commented Jan 19, 2015 at 2:40
  • Hmm, I know some stuff about excel. What is it about? Commented Jan 19, 2015 at 3:27
  • it's programmatic, so i'm going to ask it over at stackoverflow. will link here when i've figured it out. tia
    – Erich
    Commented Jan 19, 2015 at 3:47
  • pedantic correction -- it's formulaic, not programmatic. here's my question: stackoverflow.com/questions/28018779/…
    – Erich
    Commented Jan 19, 2015 at 6:10
1

I see this question has the "unmounting" tag, which is exactly right: this looks like exactly what needs to be done.

In general, the way to unmount something that was created with the mount command is to use umount. (Not "unmount". "umount".)

umount /home/ftp_user/www_dev

That will make the /home/ftp_user/www_dev stop containing the mounted data. And /home/ftp_user/www_dev will be an empty directory. And that point, you can rmdir the empty directory /home/ftp_user/www_dev directory if you want to, as it will have nothing to do with the previously-mounted source (which appears to be the /var/www/dev/ directory in your example).

Note that none of what I said is specific to the --bind command, but is just how mounts are handled in general.

Side note: Are you really sure that you gave "access to too many files" to "the ftp user"? Maybe /var/www/dev/ has files that the ftp user should not have access to, but the ftp user might not have permissions to access those files. You might have done things just fine, and could confirm this by verifying what actions are actually possible when you're actually logged in as the ftp user. Of course, with a thorough understanding of Unix permissions, you could do this without logging in, but logging in might be the simplest way to perform a fast test without needing some of the more advanced details about how permissions work.

Side note 2: Of course, on many Unix systems, you can learn more about the command by running "man umount", which you could find by typing "apropos mount" since you had reason to suspect these effects were caused by the earlier "mount" command. If you're not familiar with mount and umount, and do something like trying to rmdir a directory, then this indicates that you haven't become familiar with some very basic things about the operating system you're using. If you're running a system that is providing services to other users, and you're in a position to be able to handle permissions, then these types of basics (like the /etc/fstab file, as another rather related example) are things that are worthwhile to know, in order to reliably oversee the system used by multiple people. You may wish to seek out a tutorial or book or some other training material related to running Unix (or Linux or something technically similar). For example, mount and umount are part of Linux Professional Institute's LPIC-1 certification (which is very related to CompTIA's Linux+ certification), so training material for those certifications will likely provide such details and lots of other things you're likely to find useful.

1
  • I gave the user access to all website files, but realized that all he really needs is access to one javascript folder. I preferred to give him the least access necessary. I actually tried running umount a few times and it told me the device was busy. Then finally it worked. I did not actually try erich's answer but it seems like it would take care of the device busy error message I was getting. Commented Jan 19, 2015 at 2:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .