Questions tagged [io]

I/O is an acronym for input/output, which refers to the mechanism or process for the transfer of information between one system or component and another.

620 questions
175
votes
7 answers

Can I watch the progress of a `sync` operation?

I've copied a large file to a USB disk mounted on a Linux system with async. This returns to a command prompt relatively quickly, but when I type sync, of course, it all has to go to disk, and that takes a long time. I understand that it's going to…
mattdm
  • 39,535
  • 18
  • 99
  • 133
137
votes
7 answers

Redirecting stdout to a file you don't have write permission on

When you attempt to modify a file without having write permissions on it, you get an error: > touch /tmp/foo && sudo chown root /tmp/foo > echo test > /tmp/foo zsh: permission denied: /tmp/foo Sudoing doesn't help, because it runs the command as…
Michael Mrozek
  • 91,316
  • 38
  • 238
  • 232
87
votes
7 answers

How can I read line by line from a variable in bash?

I have a variable which contains multiline output of a command. What's the most effecient way to read the output line by line from the variable? For example: jobs="$(jobs)" if [ "$jobs" ]; then # read lines from $jobs fi
Eugene Yarmash
  • 14,675
  • 14
  • 50
  • 57
83
votes
2 answers

When is dd suitable for copying data? (or, when are read() and write() partial)

Short version: In what circumstances is dd safe to use for copying data, safe meaning that there is no risk of corruption due to a partial read or write? Long version — preamble: dd is often used to copy data, especially from or to a device…
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
75
votes
5 answers

How portable are /dev/stdin, /dev/stdout and /dev/stderr?

Occasionally I need to specify a "path-equivalent" of one of the standard IO streams (stdin, stdout, stderr). Since 99% of the time I work with Linux, I just prepend /dev/ to get /dev/stdin, etc., and this "seems to do the right thing". But, for…
kjo
  • 14,779
  • 25
  • 69
  • 109
72
votes
12 answers

What's the philosophy behind delaying writing data to disk?

In Linux, a finished execution of a command such as cp or dd doesn't mean that the data has been written to the device. One has to, for example, call sync, or invoke the "Safely Remove" or "Eject" function on the drive. What's the philosophy behind…
marmistrz
  • 2,732
  • 4
  • 23
  • 30
52
votes
1 answer

Why is most the of disk IO attributed to jbd2 and not to the process that is actually using the IO?

When monitoring disk IO, most of the IO is attributed to jbd2, while the original process that caused the high IO is attributed a much lower IO percentage. Why? Here's iotop's example output (other processes with IO<1% omitted):
Sparkler
  • 1,039
  • 2
  • 13
  • 18
51
votes
5 answers

Determining Specific File Responsible for High I/O

This is a simple problem but the first time I've ever had to actually fix it: finding which specific files/inodes are the targets of the most I/O. I'd like to be able to get a general system overview, but if I have to give a PID or TID I'm alright…
Bratchley
  • 16,684
  • 13
  • 64
  • 103
50
votes
5 answers

Find out what processes are writing to hard drive

On my Lenovo T400 and Ubuntu, the light for hard drive writing keeps flashing. I was wondering if in Linux it is possible to find out what processes are doing I/O to the hard drive? Just like by top, you can find out what processes are using most…
Tim
  • 98,580
  • 191
  • 570
  • 977
43
votes
1 answer

How to get total read and total write IOPS in Linux?

How do I get read and write IOPS separately in Linux, using command line or in a programmatic way? I have installed sysstat package. Please tell me how do I calculate these separately using sysstat package commands. Or, is it possible to calculate…
shas
  • 2,578
  • 4
  • 17
  • 31
41
votes
5 answers

Measure pipe throughput in the shell

There is a shell command that allows you to measure how fast the data goes through it, so you can measure the speed of output of commands in a pipe. So instead of: $ somecommand | anothercommand you can do something like: $ somecommand | ??? |…
Alex B
  • 4,458
  • 5
  • 38
  • 41
40
votes
4 answers

How to Throttle per process I/O to a max limit?

I'm looking for a way to limit a processes disk io to a set speed limit. Ideally the program would work similar to this: $ limitio --pid 32423 --write-limit 1M Limiting process 32423 to 1 megabyte per second hard drive writing speed.
Sepero
  • 1,569
  • 3
  • 20
  • 29
40
votes
2 answers

When a process will go to 'D' state?

I'm using "Linux hostname 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18 18:40:08 UTC 2009 i686 GNU/Linux" All the client machines will use Thin-client ,I will use my laptop for working and I will mount my home directory from server to my laptop. If I…
ungalnanban
  • 511
  • 1
  • 4
  • 5
34
votes
5 answers

How to redirect stdout to a file, and stdout+stderr to another one?

How can I achieve cmd >> file1 2>&1 1>>file2 That is, the stdout and stderr should redirect to one file (file1) and only stdout (file2) should redirect to another (both in append mode)?
Swarna Gowri
  • 525
  • 4
  • 9
34
votes
4 answers

Optimizing logical sector size for physical sector size 4096 HDD

With many new hard drive disks the physical sector size is 4096. Would it be possible to make the system use a logical sector size of the same size, rather than the default logical sector size of 512? Will it speed up bulk reads and writes? Where…
Matan
  • 560
  • 1
  • 7
  • 15
1
2 3
41 42