I have a 512G disk and I want to clear the last 512k bytes at the end of the disk.

I usually clear it by dd if=/dev/zero of=/dev/da0 the whole disk.

Which way is the fastest to do this operation?

link|improve this question
feedback

migrated from stackoverflow.com Apr 8 '10 at 16:16

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 4 down vote accepted

As already pointed out, dd accepts the seek=BLOCKS parameter, which skips BLOCKS blocks in the output file.

Now you need to know the exact size of the disk, if you want to write the last 512kB. On linux, you can use the blockdev --getsz DEVICE command to get the size, in units of 512B.

So the command-line becomes something like:

dd if=/dev/zero of=$YOUR_DEV bs=512 skip=$(( $(blockdev --getsz $YOUR_DEV) - 1024 )) count=1024
link|improve this answer
feedback

Use the seek predicate to go to the end of the disk.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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