zeroing out with the dd-command - some insights

hi there - good day dear exüerts

background: i have a iinux in a notebook - running as a live-dvd - before installation i want to zero out the

root@ /home/demo# dd if=/dev/zero of=/dev/sda bs=4096 count=4096

i get back:

dd: failed to open ‘/def/zero/’ : No such file or directory

why do i get this error?

dd if=/dev/zero of=/dev/sda bs=512 count=4096 seek=$(expr blockdev --getsz /dev/sda - 4096)

Q: What exactly does this do?

https://unix.stackexchange.com/questions/275243/what-does-dd-if-dev-zero-of-dev-sda-do/275260

background: i have a mx-linux in a notebook - running as a live-dvd - before installation i want to zero out the

root@mx1: /home/demo# dd if=/dev/zero of=/dev/sda bs=4096 count=4096

i get back:

dd: failed to open ‘/def/zero/’ : No such file or directory

why do i get this error?

Well i allways thougth that this will zero out the first 16 MiB of the drive. 16 MiB is probably more than enough to nuke any “start of disk” structures
while being small enough that it won’t take very long.

dd if=/dev/zero of=/dev/sda bs=512 count=4096 seek=$(expr blockdev --getsz /dev/sda - 4096)

Q: What does this exactly?

blockdev --getsz gets the size of the block device in “512 byte sectors”.
So this command looks like it was intended to zero out the last 2 MiB of the drive.

Unfortunately this command is broken syntax wise. I expect the command was originally intended to be

dd if=/dev/zero of=/dev/sda bs=512 count=4096 seek=$(expr blockdev --getsz /dev/sda - 4096)
and the backticks got lost somewhere along the line of people copy/pasting it between different environments.

Old partition tables, LVM metadata, raid metadata etc can cause problems when reusing a drive.
Zeroing out sections at the start and end of the drive will generally avoid these problems while being much faster than zeroing out the whole drive.

This will erase the first 40964096=16MB and last 5124096=2MB of your hard drive, which contain important structures useful for recovery. I assume this code was posted maliciously.

I’ve never encounter a situation where explicitly specifying a count other than 1 was useful. I have erased the first block if I wanted to ensure I wasn’t leaving any traces of the MBR behind …

That looks like a typing error – “/def/zero” where it should be “/dev/zero”.

good day dear nrickert :):slight_smile:

many many thanks for the hint!! i am very glad to hear from you.

i will - later the day - try out the code.

at the momend i am not in front of the notebook.

again - many thanks. You saved my day.

greetings

dilbert :slight_smile:

dear nrickert

i gave this command like so

root@mx1:/# dd if=/dev/zero of=dev/sda bs=4096 count=4096 
4096+0 records in
4096+0 records out
16777216 bytes (17 MB, 16 MiB) copied, 0.0192144 s, 873 MB/s
root@mx1:/# 

well i wonder / what happens now with this

Hard to say. You used “dev/sda” rather than “/dev/sda”. So what happened depended on the current directory.

Not so hard :D. It will create a 16 MB file called sda in a directory called dev, won’t it?