Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

All, I'm seeing disk read IO on a pure write call, and was wondering why. This is on an embedded system with no other background processes running that could be interfering. Filesystem is on an SSD, fstab options:

/dev/sda /mnt/storage0 ext4 rw,noatime,barrier=1,data=ordered,discard 0 0

Actual IO data:

# time dd if=/dev/zero of=/mnt/storage0/test bs=16k count=2048k & vmstat 3 10000
0
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 2  0      0   4384   1008 501088    0    0  3900 11969 2826  833  0 42 54  3
 2  2      0   3232   1488 501312    0    0  8608 120048 1056 2188  1 96  0  3
 1  2      0   4912   1440 499312    0    0 13040 78411 1225 2971  2 64  0 34
 2  2      0   3184   1408 501456    0    0 13179 107317 1252 3032  2 71  0 27
 2  2      0   3168   1456 501456    0    0 10037 82240 1027 2409  1 59  0 40
 3  0      0   4544   1440 500224    0    0  6901 62811  755 1708  1 45  0 54
 1  3      0   2928   1424 501824    0    0  8608 91200  909 2156  1 58  0 41
 0  2      0   4944   1456 499008    0    0  9173 75200  901 2155  1 50  0 49
 1  1      0   4944   1456 499760    0    0  8795 70880  907 2061  1 50  0 49
 1  1      0   5184   1472 499328    0    0 11237 106267 1141 2682  1 69  0 30
 3  2      0   3216   1456 501296    0    0 10373 96485 1055 2499  2 63  0 35
 0  2      0   4368   1488 499632    0    0  7488 72459  809 1857  1 48  0 51
 0  2      0   4480   1504 499536    0    0 11717 71445 1082 2653  1 57  0 42
share|improve this question
add comment

2 Answers

The operating system will be reading the disk in order to do the writing. It will need to read such things as the file header to update it with, for example, the file size. It will need to read the block allocation tables to know where it's safe to write to on the disk, etc.

There's more to writing to a disk than just blasting data at it.

share|improve this answer
    
It's only writing one file, and this is ext4 using extents and delayed allocation on a completely empty filesystem, so allocating a block should be instantaneous. I'm not concerned that it reads some data back, but it's reading ~10MB/s. I would expect to see some initial read IO, but this is well into the write, not at the beginning. –  Mike Mar 7 '11 at 12:51
    
Ah - ext4 - I think that's possibly the journalling you're seeing there (reading journal logs and writing the data to the live filesystem)? –  Majenko Mar 7 '11 at 13:12
    
Are the seeks dd does (at least from what I can tell by reading opensource.apple.com/source/file_cmds/file_cmds-220.7/dd/dd.c - maybe Linux is different thouhg) counted as reads possibly? –  ultrasawblade Mar 15 at 15:50
add comment

I had a similar experience while using dd with netcat

nc -l 1234 | dd of=/dev/sda bs=4M

To my surprise dd was reading (a lot) from sda, which should only be written to.

Turned out using obs (output block size) instead of bs (sets in and out block size) made the reads go away.

nc -l 1234 | dd of=/dev/sda obs=4M 

… worked like I expected it to without reads (and a lot faster).

I don't exactly know why dd is reading from the disk, but there is no file system involved, so I assume it is related to the different block sizes.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.