1

I am finding that I can't mount a device, sdb.

However, I don't see it in mounts:

[root@idh1 rhs-hadoop-install-0_61]# mount | grep --color dev
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/VolGroup-lv_home on /home type ext4 (rw)

And I don't see any symlink mounts pointing to it:

[root@idh1 rhs-hadoop-install-0_61]# ls -altrh /dev/* | grep sd
brw-rw---- 1 root disk      8,  16 Feb  4 14:43 /dev/sdb
brw-rw---- 1 root disk      8,  17 Feb  4 14:43 /dev/sdb1
brw-rw---- 1 root disk      8,   0 Feb  4 14:43 /dev/sda
brw-rw---- 1 root disk      8,   2 Feb  4 14:43 /dev/sda2
brw-rw---- 1 root disk      8,   1 Feb  4 14:43 /dev/sda1
lrwxrwxrwx  1 root root    6 Feb  4 14:43 8:16 -> ../sdb
lrwxrwxrwx  1 root root    7 Feb  4 14:43 8:17 -> ../sdb1
lrwxrwxrwx  1 root root    6 Feb  4 14:43 8:0 -> ../sda
lrwxrwxrwx  1 root root    7 Feb  4 14:43 8:2 -> ../sda2
lrwxrwxrwx  1 root root    7 Feb  4 14:43 8:1 -> ../sda1

What are these magic "arrows" which point to ../sdb? It appears maybe they are making sdb "busy", such that I can't format it.

1

2 Answers 2

2

The issue here is that you're using a wildcard, together with what the grep command hides from you.

The shell expands the wildcard for you, so the ls sees the command as ls /dev/autofs /dev/block /dev/bsg and so on for every file and directory that you have in your /dev/. You can demonstrate what ls sees by doing echo /dev/* to just see how the shell expands the wildcard.

As a side effect of this, all files in all folders in /dev/ are also listed. Since your ls command (after the shell has expanded the wildcard) contains a bunch of directories, each directory will have its own heading. So the actual output looks something like:

brw-rw---- 1 root disk      8,  16 Feb  4 14:43 /dev/sdb
brw-rw---- 1 root disk      8,  17 Feb  4 14:43 /dev/sdb1
brw-rw---- 1 root disk      8,   0 Feb  4 14:43 /dev/sda
brw-rw---- 1 root disk      8,   2 Feb  4 14:43 /dev/sda2
brw-rw---- 1 root disk      8,   1 Feb  4 14:43 /dev/sda1

...

/dev/block:
total 0
lrwxrwxrwx  1 root root    6 Feb  4 14:43 8:16 -> ../sdb
lrwxrwxrwx  1 root root    7 Feb  4 14:43 8:17 -> ../sdb1
lrwxrwxrwx  1 root root    6 Feb  4 14:43 8:0 -> ../sda
lrwxrwxrwx  1 root root    7 Feb  4 14:43 8:2 -> ../sda2
lrwxrwxrwx  1 root root    7 Feb  4 14:43 8:1 -> ../sda1

However, the /dev/block line is hidden by the grep command, so you don't see it. Try without the grep and maybe using less to see clearly what ls is outputting.

To confuse thing more, the 8:16 in 8:16 -> ../sdb is a file name and not a timestamp or anything else. /dev/block/8:16 is the name of a block device, which is symlinked to ../sdb, or /dev/sdb as it were.

You can stop ls from expanding subdirectories by specifying the d flag.

ls -altrhd /dev/* | grep sd

Or of course, by not putting a wildcard after /dev/:

ls -altrh /dev/ | grep sd
1

First of all, you don't want to mount sdb but the partition that is on the device, sdb1. That's why you can't mount it.

As for the magic arrows, they're not magic or arrows, the file name is actually the number after the time:

lrwxrwxrwx  1 root root    6 Feb  4 14:43 8:16 -> ../sdb
                                          ----
                                            |-> File name   

The arrows themselves are standard notation for symbolic links. The general format is:

link_name -> /path/to/target

These are not actually in /dev but in /dev/block and are correctly pointing to /dev/sdb which is ../sdb from /dev/block (.. is the parent directory). The reason they were listed is becayuse you ran ls /dev/* instead of ls /dev/ so the contents of all subdirectories were also listed.

You can check all this by running:

$ ls -lath /dev/sd*
brw-rw---- 1 root disk      8,  16 Feb  4 14:43 /dev/sdb
brw-rw---- 1 root disk      8,  17 Feb  4 14:43 /dev/sdb1
brw-rw---- 1 root disk      8,   0 Feb  4 14:43 /dev/sda
brw-rw---- 1 root disk      8,   2 Feb  4 14:43 /dev/sda2
brw-rw---- 1 root disk      8,   1 Feb  4 14:43 /dev/sda1

$ ls -lath /dev/block/sd*
lrwxrwxrwx  1 root root    6 Feb  4 14:43 8:16 -> ../sdb
lrwxrwxrwx  1 root root    7 Feb  4 14:43 8:17 -> ../sdb1
lrwxrwxrwx  1 root root    6 Feb  4 14:43 8:0 -> ../sda
lrwxrwxrwx  1 root root    7 Feb  4 14:43 8:2 -> ../sda2
lrwxrwxrwx  1 root root    7 Feb  4 14:43 8:1 -> ../sda1
2
  • "You ran ls with the -r, recursive, flag." Incorrect. -r means reverse sort order. My answer explains why these files were actually listed.
    – nitro2k01
    Feb 4, 2014 at 20:32
  • @nitro2k01 Damn, my bad. I know, that's why I have the correct command in my answer. Brain short circuited there, thanks for pointing it out.
    – terdon
    Feb 4, 2014 at 20:34

You must log in to answer this question.

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