This is a discussion on using dd to use available space within the Linux General forums, part of the Linux Forums category; I would like to use 'dd' to write a file to a filesystem, leaving the least amount of free space ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I would like to use 'dd' to write a file to a filesystem, leaving the
least amount of free space available (preferably filling it up completely). I'm having difficulty calculating the correct 'count=' parameter to use based upon the output of 'df'. I feel that I'm missing something obvious, and hope that someone on this list can point me in the right direction. The following is the output of what I am running. The error reports that I am attempting to write beyond the available space, and the data is being truncated. Despite the error, 'ls -s' reports that the size of the created file is different than the output record count! cusa:~# df /dvd-stage Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vg-dvd--stage 4515496 8952 4506544 1% /dvd-stage cusa:~# dd if=/dev/zero of=/dvd-stage/test bs=1k count=4506544 dd: writing `/dvd-stage/test': No space left on device 4502133+0 records in 4502132+0 records out 4610183168 bytes (4.6 GB) copied, 161.554 seconds, 28.5 MB/s cusa:~# ls -s --block-size=1k /dvd-stage/ total 4506560 16 lost+found 4506544 test I have played with the 'bs=' value, setting it to the same as the block size of the filesystem (4k), but received the same result. It seems that some of the available space is being used for "header" information as more data is written to the file, but can't put my finger on it. Would anyone please drop me a hint to help predict the maximum 'count=' to fill the filesystem? Thanks a lot for any help, Adam |
|
|||
|
In article <228edacf-e04a-4add-bf37-acec848d02c2@f63g2000hsf.googlegroups.com>,
<adam.j.henry@gmail.com> wrote: > I would like to use 'dd' to write a file to a filesystem, leaving the > least amount of free space available (preferably filling it up > completely). I'm having difficulty calculating the correct 'count=' > parameter to use based upon the output of 'df'. I feel that I'm > missing something obvious, and hope that someone on this list can > point me in the right direction. When they went over inodes, they went roughly like this: [----------------] \ [----------------] | ... | n direct slots [----------------] | [----------------] / [----------------] indirect pointer [----------------] doubly indirect pointer [----------------] triply indirect pointer disk block addresses --^ (I forget how big n is, but probably (n+3) * address_size = 1 disk_block. If disk_block = 1 K and address_size = 8 B, n = 125, which seems way high.) The indirect pointer points to a similar structure full of disk block pointers. The doubly indirect pointer points to a block full of indirect pointers, and the triply indirect pointer points to a block full of doubly indirect pointers. So a file can get crazy big before the structure fills up, and the disk space taken up is decidedly non-linear WRT filesize. But, you don't have to tell dd how many blocks to write, you can tell it "write until the disk fills up", which is probably easier for you. -- -eben QebWenE01R@vTerYizUonI.nOetP http://royalty.mine.nu:81 Are you confident that you appear to be professional in your electronic communication? Consider this: A: No Q: Can I top post? from nick@xx.co.uk |