I create certain files using \"dd\" and \"echo\" as follows: dd if =/dev/zero of
ID: 3580774 • Letter: I
Question
I create certain files using "dd" and "echo" as follows: dd if =/dev/zero of=myfile bs=l seek=1024M count= 1 echo 'This is a small file!' >another Next I do a "1s - 1a" to see the files: total 16 -rw-rw-r-- 1 bmahoney bmahoney 22 2013-12-11 16:08 another -rw-rw-r-- 1 bmahoney bmahoney 1073741825 2013-12-11 16:07 myfile And finally I take a look to see how many blocks are allocated, by typing:du *": 4 another 12 myfi1e Which tells me that "another" has four blocks of data but "myfile" has 12. Wait! How can it be that "myfile" is only three times the number of disk blocks when it is 48806446 times larger? Please explain.Explanation / Answer
The details given by ls command for memory occupancy of a file is in the terms of kilobytes(KB) or megabytes (MB) .
When we use du command it shows the no of disk blocks used by each file.
A data block is the unit by which a disk stores data .
The disk block size varies depending on the file size.
Since a file is a continuous flow of data under single name the file system of UNIX OS tries to reduces the number of data blocks used to store data to make the access easier and reduce the number of inodes for each file .
Hence the no of blocks for my file may be adjusted to 22 blocks with large data block size.
The data block size may vary from a minimum of 0.5KB upto the total empty disk size in power of 2
I.e 512bytes,1KB,2kb,4kb,8kb,16kb,32kb,etc and so on
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.