Results 1 to 6 of 6

Thread: zeroing out with the dd-command - some insights

  1. #1

    Default 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/quest...-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 4096*4096=16MB and last 512*4096=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 ...
    dilbert ;-)
    Wordpress-development - a Toolset: wpgear.org

  2. #2
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,345
    Blog Entries
    3

    Default Re: zeroing out with the dd-command - some insights

    Quote Originally Posted by dilbertone View Post
    i get back:


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


    why do i get this error?

    That looks like a typing error -- "/def/zero" where it should be "/dev/zero".
    openSUSE Leap 15.1; KDE Plasma 5;

  3. #3

    Default Re: zeroing out with the dd-command - some insights

    good day dear nrickert


    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
    dilbert ;-)
    Wordpress-development - a Toolset: wpgear.org

  4. #4

    Default Re: zeroing out with the dd-command - some insights

    dear nrickert


    i gave this command like so

    Code:
    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
    dilbert ;-)
    Wordpress-development - a Toolset: wpgear.org

  5. #5
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,345
    Blog Entries
    3

    Default Re: zeroing out with the dd-command - some insights

    Quote Originally Posted by dilbertone View Post
    i gave this command like so

    Code:
    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.
    openSUSE Leap 15.1; KDE Plasma 5;

  6. #6
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,644
    Blog Entries
    14

    Default Re: zeroing out with the dd-command - some insights

    Quote Originally Posted by nrickert View Post
    Hard to say. You used "dev/sda" rather than "/dev/sda". So what happened depended on the current directory.
    Not so hard . It will create a 16 MB file called sda in a directory called dev, won't it?
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •