Device number in stat command output

# stat tool
  File: `tool'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 801h/2049d      Inode: 671689      Links: 3

# ls -l /dev/sda*
brw-rw---- 1 root disk 8, 0 2010-08-16 14:43 /dev/sda
brw-rw---- 1 root disk 8, 1 2010-08-16 14:43 /dev/sda1
brw-rw---- 1 root disk 8, 2 2010-08-16 14:43 /dev/sda2
brw-rw---- 1 root disk 8, 5 2010-08-16 14:43 /dev/sda5

In the example, 'tool' (801h) is in /dev/sda1 (major device number is 8, minor device number is 1). That's the first partition in /dev/sda.


It's the major and minor device number combined into one value (in hex and decimal) of the device on which the file resides.

For your example, 804h is major device 8, minor device 4. if you run df . while you're in the directory where that file is, you'll get the device name such as /dev/sda1. If you were to then do ls -al /dev/sda1, it would show you the device numbers. Here's an example:

pax$ stat newfile # note device 801h, hex 801 = 2049 decimal
  File: 'newfile'
  Size: 2097152     Blocks: 4096       IO Block: 4096   regular file
Device: 801h/2049d  Inode: 2888080     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     pax)   Gid: ( 1000/     pax)
Access: 2010-11-29 07:32:22.011271661 +0800
Modify: 2010-08-30 15:43:14.286796827 +0800
Change: 2010-08-30 15:43:14.286796827 +0800

pax$ df . # to get current device mount
Filesystem           1K-blocks Used Available Use% Mounted on
/dev/sda1            470301088 182471788 263939332  41% /

pax$ ls -al /dev/sda1 # to get major/minor = 8/1
brw-rw---- 1 root disk 8, 1 2010-11-30 07:02 /dev/sda1

Tags:

Linux