22

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

15

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
  • 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
26

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>
  • 1
    Exactly the answer! – trusktr Mar 31 '13 at 9:21
2

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
    Thanks, I reversed the order too – user3804598 Oct 27 '19 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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