Questions tagged [dd]

A low-level command-line tool on Unix-like operating systems to copy and convert files.

Ref

Examples:

  • Clone the drive sda onto drive sdb:

    `$ dd if=/dev/sda of=/dev/sdb`
    
  • Clone the drive hda onto an image file:

    `$ dd if=/dev/hda of=/image.img`
    
  • Copy a CD or DVD disc to a .iso image file, first unmounting the disc: sudo umount /dev/dvd-device

    dd if=/dev/dvd-device of=dvd.iso bs=2048 conv=sync,notrunc

    # dvd-device will typically be dvd for a dvd disc or cdrom for a cdrom disc.

  • Clone a hard drive to a zipped image file in 100Mb blocks:

    $ dd if=/dev/hda bs=100M | gzip -c > /image.img

  • Create a 10 KB file filled with random data (10 x 1K blocks):

    $ dd if=/dev/random of=random.bin bs=1024 count=10

  • Completely wipe the hard drive hdz by overwriting it with random data:

    $ dd if=/dev/urandom of=/dev/hdz

  • Create a boot floppy:

    $ dd if=boot.img of=/dev/fd0 bs=1440

345 questions
9
votes
2 answers

Windows C# implementation of linux dd command

I'm writing a C#.Net app to run on windows that needs to take an image of a removable disk and chuck it onto a Linux Live USB. The Live USB is the inserted into the target machine and boots, on start up it runs a script which uses the dd command…
rb_
  • 613
  • 9
  • 24
9
votes
4 answers

Tilde (~) isn't working in subprocess.Popen()

When I run in my Ubuntu terminal: sudo dd if=/dev/sda of=~/file bs=8k count=200k; rm -f ~/file it works fine. If I run it through Pythons subprocess.Popen(): output, err = subprocess.Popen(['sudo', 'dd', 'if=/dev/' + disk,…
RichArt
  • 1,534
  • 18
  • 35
8
votes
2 answers

Laravel/PHP dd() displays non-structured arrays in Chrome developer tools

I have noticed that writing in Laravel's Controller: dd($array) outputs an un-structured view of array in Chrome Developer Tools (chome 61.0.3163.91 64-bit, MAC OS). before it was something like this (at least it seems to me that it was like…
Sergej Fomin
  • 1,822
  • 3
  • 24
  • 42
7
votes
2 answers

How can I use the linux dd command on wsl2 to burn a bootable usb?

I am an avid Linux user who is being made to use Windows for work. I was given the go-ahead to install WSL2 and Ubuntu on the work computer. I would like to burn a bootable USB using dd in WSL2, but haven't been able to figure out how to get the…
Bryan Hyland
  • 153
  • 1
  • 6
7
votes
7 answers

Fast Disk Cloning

Is there a way to have Linux read ahead when cloning a disk? I use the program named "dd" to clone disks. The last time I did this it seemed as though the OS was reading then writing but never at the same time. Ideally, the destination disk would…
Mike
  • 1,760
  • 2
  • 18
  • 33
7
votes
2 answers

dd under windows for SD Card

I'm having problem to use this command under windows dd if=*file* of=/dev/sdx bs=512 seek=2 conv=fsync Using cygwin shell: $ dd if=file of=/cygdrive/f bs=512 seek=2 conv=fsync dd: failed to open ‘/cygdrive/f’: Is a directory F: is the letter…
user3428154
  • 1,174
  • 5
  • 18
  • 38
7
votes
3 answers

skip the first 32k of stdin with dd?

If I have a file on a file system I can do something like this with dd: dd if=/my/filewithaheader.bin bs=32k skip=1 | gunzip | tar tvf however if I try something like this: ./commandthatputsstuffonstdout | dd bs=32k skip=1 | gunzip | tar tvf I…
nwaltham
  • 2,067
  • 1
  • 22
  • 40
7
votes
1 answer

Can't back up SD card with dd, complains "Input/Output Error"

I have successfully backed up my SD card twice by issuing the following command sudo dd if=/dev/sdb of=/home/user/Documents/raspi/images/raspi1.v2.iso bs=1M However, now it is giving me the following error: dd: reading `/dev/sdb': Input/output…
puk
  • 16,318
  • 29
  • 119
  • 199
6
votes
2 answers

How to redirect output from dd command to /dev/null?

In shell script i need to redirect output from dd command to /dev/null - how to do that? ( dd if=/dev/zero of=1.txt count=1 ) 2>&1 /dev/null didn't work!
webminal.org
  • 44,948
  • 37
  • 94
  • 125
6
votes
4 answers

do stdout output with specific speed

For a load test of my application (under Linux), I'm looking for a tool that outputs data on stdout at a specific rate (like 100 bytes/s), so that I can pipe the output to netcat which sends it to my application. Some option for dd would be ideal,…
oliver
  • 6,204
  • 9
  • 46
  • 50
6
votes
2 answers

dd fail to write to tmpfs

I'd like to measure tmpfs performance by using dd. But it fail, like below: # dd if=/dev/zero of=/tmp/128M bs=4M count=32 oflag=direct dd: failed to open ‘/tmp/128M’: Invalid argument Any help?
user3170177
  • 61
  • 1
  • 4
5
votes
2 answers

dump mapped buffer with dd

Into /proc/PID/maps I can see memory that some buffer mapped to kernel module: 44a00000-44b00000 rwxs 00000000 00:01 XXXX /dev/my_module I know that it's logical address , and I want to dump this memory with dd? dd need to get physical memory…
MicrosoctCprog
  • 460
  • 1
  • 3
  • 23
5
votes
3 answers

Split integer into equal chunks

What is the most efficient and reliable way in Python to split sectors up like this: number: 101 (may vary of course) chunk1: 1 to 30 chunk2: 31 to 61 chunk3: 62 to 92 chunk4: 93 to 101 Flow: copy sectors 1 to 30 skip sectors in chunk 1 and copy 30…
user3323307
  • 243
  • 4
  • 13
5
votes
2 answers

Can't reach speeds of dd

I'm writing C code with some real-time constraints. I tested out the speed I can write to a disk with dd: dd if=/dev/zero of=/dev/sdb bs=32K count=32768 oflag=direct This writes 1GB of zeros to /dev/sdb in 32K block sizes I reach about 103 MB/s with…
dschatz
  • 1,188
  • 2
  • 13
  • 25
5
votes
1 answer

Why Python splits read function into multiple syscalls?

I tested this: strace python -c "fp = open('/dev/urandom', 'rb'); ans = fp.read(65600); fp.close()" With the following partial output: read(3,…
fcatho
  • 317
  • 2
  • 14
1
2
3
22 23