5

On my local machine, I have /sys/block/sda1/stat.
On an Amazon machine, I have /sys/block/xvda1/stat.

When I run cat /sys/block/sda1/stat or cat /sys/block/xvda1/stat both give 11 fields of output.

What is the difference between /sys/block/sda1/stat and /sys/block/xvda1/stat files?

7
  • You can see difference between two files by using diff command, by the way. Aug 26, 2015 at 13:05
  • 1
    @ MatthewRock did u understand my question ?
    – shas
    Aug 27, 2015 at 12:11
  • Yes. That's why I said "by the way". You ran cat on both files, so you probably have tried comparing them. I just said that diff might be more useful than comparing it manually. I'm not answering your question, just throwing in a comment. Aug 27, 2015 at 12:14
  • 1
    @ MatthewRock Better look at the answer. don't comment anything without understanding. i know diff command ok.
    – shas
    Aug 27, 2015 at 12:18
  • 1
    Sometimes I really want to be able to down-vote a comment.
    – mc0e
    Mar 8, 2016 at 5:37

2 Answers 2

10

The /sys directory is generally where the sysfs filestystem is mounted, which contains information about devices and other kernel information.

The files in /sys/block contain information about block devices on your system. Your local system has a block device named sda, so /sys/block/sda exists. Your Amazon instance has a device named xvda, so /sys/block/xvda exists.

The /sys/block/<dev>/stat file provides several statistics about the state of block device <dev>. It consists of a single line of text containing 15 decimal values separated by whitespace:

Name            units         description
----            -----         -----------
read I/Os       requests      number of read I/Os processed
read merges     requests      number of read I/Os merged with in-queue I/O
read sectors    sectors       number of sectors read
read ticks      milliseconds  total wait time for read requests
write I/Os      requests      number of write I/Os processed
write merges    requests      number of write I/Os merged with in-queue I/O
write sectors   sectors       number of sectors written
write ticks     milliseconds  total wait time for write requests
in_flight       requests      number of I/Os currently in flight
io_ticks        milliseconds  total time this block device has been active
time_in_queue   milliseconds  total wait time for all requests
discard I/Os    requests      number of discard I/Os processed
discard merges  requests      number of discard I/Os merged with in-queue I/O
discard sectors sectors       number of sectors discarded
discard ticks   milliseconds  total wait time for discard requests

So, each block device will have its own statistics file, hence the different values.
See kernel docs for more details.

6
  • Am agree with your ans.
    – shas
    Aug 26, 2015 at 13:01
  • Can you please tel me how do i find block device name in different machine?
    – shas
    Aug 26, 2015 at 13:02
  • Well, you can look at the names of directories in /sys/block.
    – larsks
    Aug 26, 2015 at 13:03
  • Also, find /dev -type b. Aug 26, 2015 at 13:06
  • No worries. I had left this out as an RTFM issue, but I guess it's fine to have it here.
    – larsks
    Aug 26, 2015 at 13:24
3

Both files contain the statistics of the first partition (/sys/block/sda1/stat) of the first device (/sys/block/sda1/stat) found by a particular driver or subsystem. The difference is the driver.

Your amazon VM is using the Xen driver (/sys/block/xvda1/stat).
Your local machine is using the SCSI driver (/sys/block/sda1/stat).

xvd = Xen Virtual Disk

sd = SCSI Disk

2
  • Worth noting WHY the names are different.
    – Jesse K
    Aug 26, 2015 at 17:30
  • That was, from what I understood, the question.
    – smokes2345
    Aug 26, 2015 at 21:13

You must log in to answer this question.

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