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
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityOn 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>
/etc/fstab
. If in doubt, us ln -s
- it's easier, more flexible, doesn't require root, will tell you where the actualy directory is, etc. You generally don't need a binds.
Jul 15, 2021 at 0:14
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
ln -s /olddir /newdir
I end up with /newdir/olddir@ which links to /olddir. How do I make it do what you said?
/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?
ℹ️ your HDD/SDD is a block storage device
sudo blkid
/dev/sda5: UUID="a6aa3891-1dc2-439a-b449-b9b1848db028" TYPE="ext4" PARTUUID="e4887e0f-05"
/dev/sda1: LABEL="System" UUID="C6F4E92AF4E91E05" TYPE="ntfs" PARTUUID="e4887e0f-01"
/dev/sda2: LABEL="Windows" UUID="4ABAF478BAF461BD" TYPE="ntfs" PARTUUID="e4887e0f-02"
/dev/sda2
mount
command arguments to get the "is not a block device" complaint
mkdir Windows
sudo mount Windows /dev/sda2
mount: /dev/sda2: /home/casey/Windows is not a block device.
mount
works like a boss when you list the arguments in the right order!
sudo mount /dev/sda2 Windows
cd Windows
ls
Config.Msi hiberfil.sys Intel pagefile.sys ProgramData 'Program Files (x86)' '$Recycle.Bin' 'System Volume Information' WCH.CN
'Documents and Settings' home msdia80.dll PerfLogs 'Program Files' Recovery swapfile.sys Users Windows
When use mount shareddir newdir
, I get the same, then I appoint the nfs server host to mount, it turns ok. The command like:
mount host:shareddir newdir