Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to make olddir accessible from newdir with the mount command:

mount olddir newdir

Why do I get the following error?

mount: olddir is not a block device

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

mount attaches block storage devices that contain a filesystem to a directory, which is not what you're trying to do, hence the error message. What you want is to create a link from the new directory name to the old existing name. For that you must use the ln command to create a symbolic link.

ln -s olddir newdir
share|improve this answer
    
I'm trying what you suggested, but instead of linking from olddir to newdir, it create a symlink called olddir inside newdir. So for example, after doing ln -s /olddir /newdir I end up with /newdir/olddir@ which links to /olddir. How do I make it do what you said? –  trusktr Mar 31 '13 at 9:19
    
newdir should be the name you want created that points back to olddir. newdir should not already exist. –  Kyle Jones Mar 31 '13 at 20:05
    
I totally understand what you mean, and that's what I'm trying to do, but it's doing something really odd, completely different. /olddir exists, and /newdir does not exist. Then, after I run ln -s /olddir /newdir, it is creating /newdir/olddir which links to /olddir. I don't want it to create /newdir/olddir. I want it to create /newdir only, which should link to /olddir, but that's not what happening. So instead of making /newddir, it is making /newdir/olddir. It's so weird!!! Get what I mean? –  trusktr Apr 9 '13 at 0:44
add comment

On Linux one can perform a bind mount, which will splice an existing directory to a new mount point.

mount --bind <olddir> <mountpoint>

Solaris supports an alternate syntax:

mount -F lofs <olddir> <mountpoint>

*BSD uses mount_null instead (although it does not come with OS X).

mount_null <olddir> <mountpoint>
share|improve this answer
    
Exactly the answer! –  trusktr Mar 31 '13 at 9:21
add comment

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.