Results 1 to 5 of 5

Thread: undo dd command?

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Beans
    19

    Question undo dd command?

    I just ran:
    dd if=/dev/zero of=/swapfile bs=1024 count=8388608
    And pressed ctrl+c in the middle of it. Got output:
    742213+0 records in
    742213+0 records out
    760026112 bytes (760 MB) copied, 9.10778 s, 83.4 MB/s
    There are not many beginner-friendly documentations out there for dd command, so even though I know what dd does, i don't know what it would do in this case:
    /swapfile partition doesn't exist by default
    /dev/zero is not a real partition (or at least I don't know what it really is...)
    Can someone tell me what exactly happened here or how can I undo this?

  2. #2
    Join Date
    Mar 2013
    Location
    Czech Republic
    Beans
    188
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: undo dd command?

    I don't think you can undo this command, because there is no backup for that.

  3. #3
    Join Date
    Mar 2013
    Beans
    19

    Re: undo dd command?

    but what happened here? Did I just create a new partition? was any data lost?

  4. #4
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    5,746
    Distro
    Xubuntu 15.04 Vivid Vervet

    Re: undo dd command?

    dd is a utility for reading/writing data, often direct to disk hardware but also regular files. But I guess you knew that.

    /dev/zero is being used as the input file. But in fact, /dev/zero is a dummy device driver that simply yields zero bytes for as long as you keep reading from it.

    /swapfile would be a regular file located in the root directory. It's not normal to have such a file, so you would have created it.

    The overall effect of the command is to create a file called /swapfile which contains 83 megabytes of zeros. I guess you are thinking of using it as swap space rather than using a normal swap partition.

    P.S. this command would undo it:
    Code:
    sudo rm /swapfile
    P.P.S:
    For anyone else reading:
    NEVER use a dd command without understanding what it will do. It is most commonly used for directly writing to hard disks and this cannot be undone. This case is unusual in merely creating a regular file which can be deleted again.
    Last edited by The Cog; March 31st, 2013 at 10:16 AM.

  5. #5
    Join Date
    Mar 2013
    Beans
    19

    Re: undo dd command?

    Hello The Cog,
    Just wanted to say thanks for the help. Ubuntu Forums is just such a warm and welcoming place!

Bookmarks

Posting Permissions

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