3

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?

  • You can see difference between two files by using diff command, by the way. – MatthewRock Aug 26 '15 at 13:05
  • @ MatthewRock did u understand my question ? – shas Aug 27 '15 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. – MatthewRock Aug 27 '15 at 12:14
  • 1
    @ MatthewRock Better look at the answer. don't comment anything without understanding. i know diff command ok. – shas Aug 27 '15 at 12:18
  • I've looked at the answer. If you didn't want to compare files contents, you shouldn't have used cat. If you show that you used cat to see contents of both files, it indicates your intention to compare their contents, in which case diff is more effective. However, because I knew that your question was referring to something else, I didn't post it as the answer(because it clearly isn't), I just commented on your action showing that it can be done more effectively. Honestly I can't see a problem with that. – MatthewRock Aug 27 '15 at 12:26
9

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 11 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

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

  • Am agree with your ans. – shas Aug 26 '15 at 13:01
  • Can you please tel me how do i find block device name in different machine? – shas Aug 26 '15 at 13:02
  • Well, you can look at the names of directories in /sys/block. – larsks Aug 26 '15 at 13:03
  • Also, find /dev -type b. – Toby Speight Aug 26 '15 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 '15 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

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

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.