33

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

0

4 Answers 4

40

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>
4
  • 1
    Exactly the answer!
    – trusktr
    Mar 31, 2013 at 9:21
  • 1
    What are the differences (pros and cons) between this and a soft link? Apr 30, 2020 at 19:17
  • @sancho.sReinstateMonicaCellio mount binds are useful if the user needing the directory can't gain access to it otherwise, or if a disk doesn't support softlinks. Binds are more powerful and will work more often. Binds work because the kernel sort of 'lies' to the application and tells it a directory contains contents that is actually somewhere else. Binds don't however persist across reboots unless you add it to /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
  • This should be the accepted answer! Speacialy when dealing with legacy softwares
    – Slim Aloui
    Feb 21 at 14:27
20

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
3
  • 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, 2013 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, 2013 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, 2013 at 0:44
4

If you're trying to mount a logical HDD/SDD

  • I dual boot: Windows 10/Ubuntu
  • I found this searching for a way to mount my Windows drive in Linux

Steps Taken

  • show block devices

    ℹ️ 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"
    
  • In my case, I want to mount the device labeled "Windows" /dev/sda2

What didn't work

  • Turns out I reversed the 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.
    

What did work 🤦‍♂️️

  • 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
    
1
  • 1
    Thanks, I reversed the order too Oct 27, 2019 at 16:43
0

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

You must log in to answer this question.

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