LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-03-2012, 09:26 AM   #1
sluge
Member
 
Registered: Dec 2006
Location: Russia,52
Posts: 116

Rep: Reputation: 6
Question How to treat iostat?


Hello
I wanted to zero my USB key drive and I type folloing command:

Code:
# dd if=/dev/zero of=/dev/sdd
So, after a while I call iostat

Code:
iostat  -m sdd
Linux 2.6.32.x86_64     08/01/2012      _x86_64_        (16 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.05    0.02    0.35    1.31    0.00   98.27

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sdj             175.25         0.66         0.66       3432       3430
I found that MB_read is 3412 but MB_wrtn is 3430.
Why MB_read is not zero? I write to device but not read from it

Last edited by sluge; 08-03-2012 at 09:27 AM.
 
Old 08-03-2012, 10:48 AM   #2
Beatriz85
LQ Newbie
 
Registered: Aug 2012
Posts: 1

Rep: Reputation: Disabled
No answer?
C'mon guys! I also need this info, some help please!
I have only started my work with Linux, so I really need assistance
 
Old 08-04-2012, 05:53 PM   #3
deadeyes
Member
 
Registered: Aug 2006
Posts: 609

Rep: Reputation: 79
Quote:
Originally Posted by sluge View Post
Hello
I wanted to zero my USB key drive and I type folloing command:

Code:
# dd if=/dev/zero of=/dev/sdd
So, after a while I call iostat

Code:
iostat  -m sdd
Linux 2.6.32.x86_64     08/01/2012      _x86_64_        (16 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.05    0.02    0.35    1.31    0.00   98.27

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sdj             175.25         0.66         0.66       3432       3430
I found that MB_read is 3412 but MB_wrtn is 3430.
Why MB_read is not zero? I write to device but not read from it
Not sure if this is a typo in your output: iostat -m sdd and device: sdj.

So 2 different devices.
 
Old 08-06-2012, 01:49 AM   #4
sluge
Member
 
Registered: Dec 2006
Location: Russia,52
Posts: 116

Original Poster
Rep: Reputation: 6
Quote:
Originally Posted by deadeyes View Post
Not sure if this is a typo in your output: iostat -m sdd and device: sdj.

So 2 different devices.
Sorry, it's cut-paste error, but question is still actual
 
Old 08-06-2012, 02:48 AM   #5
deadeyes
Member
 
Registered: Aug 2006
Posts: 609

Rep: Reputation: 79
Quote:
Originally Posted by sluge View Post
Sorry, it's cut-paste error, but question is still actual
I have to say this is a great find I am really interested in the cause

The following is what dd does:
Code:
$ strace dd if=/dev/zero of=/dev/mapper/local-test
...

open("/dev/mapper/local-test", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
dup2(3, 1)                              = 1
close(3)                                = 0
rt_sigaction(SIGUSR1, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGUSR1, {0x401c90, [INT USR1], SA_RESTORER, 0x7f3bef8d09e0}, NULL, 8) = 0
rt_sigaction(SIGINT, {0x401c80, [INT USR1], SA_RESTORER|SA_NODEFER|SA_RESETHAND, 0x7f3bef8d09e0}, NULL, 8) = 0
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 512) = 512
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 512) = 512
close(0)                                = 0
close(1)
As you can see /dev/mapper/local-test is opened write only. So nothing can be read from it (at least not by dd at that moment).
/dev/zero is opened read-only (not listed).

Note that I could only test this with an LVM volume.

I wonder if this is an issue with IOstat.

From what I can see you are using a device directly so LVM doesn't seem to be the cause as well.

Then there is only one option left: the kernel. No idea why it would actually do this.
 
Old 08-06-2012, 10:10 AM   #6
deadeyes
Member
 
Registered: Aug 2006
Posts: 609

Rep: Reputation: 79
I found it

This has to do with improper block sizes.

Try to use the bs argument with 4k/512bytes.
dd if=/dev/zero of=/dev/sdd bs=512 count=1

Code:
lvcreate -L 1G -n test local
iostat
dd bs=4k if=/dev/zero of=/dev/mapper/local-test count=1
iostat
dm-9 0.00 0.00 0.00 544 16
dm-9 0.00 0.00 0.00 544 24

24-16 = 8
8*512 = 4k

Hopes this helps you
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What do you do when people treat you bad? colinstu General 17 04-17-2006 03:24 PM
Linux case sensitive does not treat! mehjabin_25 Linux - Newbie 4 01-04-2006 08:53 AM
How to treat *.tar.gz files hanasi Linux - Newbie 3 08-17-2005 03:08 PM
A very tasty little treat.... onelung02 Linux - General 1 11-17-2004 08:38 PM
Treat multiple drives as one Whitman Linux - Software 5 04-06-2004 06:21 PM


All times are GMT -5. The time now is 11:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration