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
3
votes
1 answer

What does the conv-fdatasync do in dd command in linux?

I am very new to Linux. I was reading this article on using the dd command to burn ISOs to USB drives. I didn't understand this section on fdatasync. https://www.howtogeek.com/414574/how-to-burn-an-iso-file-to-a-usb-drive-in-linux/ conv=fdatasync:…
bababooey2
  • 33
  • 1
  • 4
3
votes
0 answers

How to prevent windows from accessing and detecting new volumes while writing a raw image file to PhysicalDrive?

After lots and lots of try and error I am now able to flash/write a raw image file (containing multiple partitions) to \\.\PhysicalDriveN (SD-Card in my case) by just using Windows Api calls (see below). But as soon as I have some explorer windows…
maf-soft
  • 2,335
  • 3
  • 26
  • 49
3
votes
0 answers

running command C# Mono using pipe

I'm creating an application running on a debian OS using C# and Mono. My aim is to unpack an imagefile and transfer it to a target folder on a different harddrive. I'm trying to pass the command "gunzip -c imagefile.img.gz | dd of=/dev/sda" to the…
Salex
  • 31
  • 2
3
votes
3 answers

Is there a fast way to read alternate bytes in dd

I'm trying to read out every other pair of bytes in a binary file using dd in a loop, but it is unusably slow. I have a binary file on a BusyBox embedded device containing data in rgb565 format. Each pixel is 2 bytes and I'm trying to read out every…
3
votes
2 answers

Understanding RAM speed using malloc, memtest and dd

Playing around with new hardware, I wrote a piece of C code to test RAM speed and disk speed. Essentially it's 3 lines that write 5 GB in RAM and write it to a file, around which I set some timers: long long int AMOUNT = 5*1024*1024*1024l; FILE…
Niels
  • 537
  • 5
  • 22
3
votes
2 answers

Read output of dd into a shell script variable

Being very new to shell scripts, I have pieced together the following to search /dev/sdd1, sector by sector, to find a string. How do I get the sector data into the $HAYSTACK…
3
votes
1 answer

How can I rebuild core utils for arm (Android)?

I'm working on a project, where I need to modify dd for Android, but I can't figure out how to build it. I've tried a simple way using arm-linux-gnueabi-gcc dd.c -o dd, but of course that wouldn't work. And I also can't find a makefile. Is it…
drZaius
  • 129
  • 2
  • 13
3
votes
2 answers

reading the output from dd command

I'm testing my network speed with a script and for it to calculate average speed I need to read the speed for each run. command: dd if=InputFile of=OutputFile bs=4096k output: 64+0 records in 64+0 records out 268435456 bytes (268 MB) copied, 1.8519…
Itay Sela
  • 942
  • 9
  • 26
3
votes
1 answer

dd block size optimisation?

For a long time, I always thought that the bs and count parameters for dd were merely for human convenience; as dd would just multiply them and use the byte value. A month ago, when installing Ubuntu for my mother, I shrunk a partition to the right…
Delan Azabani
  • 79,602
  • 28
  • 170
  • 210
3
votes
2 answers

How to use PipeViewer(pv) on Mac OS with dd

I'm trying to copy a .img of Ubuntu 14.04.1 to my bootable usb using the command sudo dd if=~/Documents/targetUbuntu.img of=/dev/rdisk1 bs=1m but it's taking long and I can't see the progress. So i'm trying to use pv using this command sudo dd…
shreyashirday
  • 892
  • 1
  • 10
  • 34
3
votes
0 answers

Checking data integrity for cloned drive

I have n disk clones that need to be checked against the source. I am looking for an efficient way to do this. Already tried md5sum and sha256sum but these take several minutes on a multi-gig drive and wont produce the intended result with drives…
user3738926
  • 1,178
  • 1
  • 10
  • 17
3
votes
3 answers

Bash shell scripting: How to replace characters at specific byte offsets

I'm looking to replace characters at specific byte offsets. Here's what is provided: An input file that is simple ASCII text. An array within a Bash shell script, each element of the array is a numerical byte-offset value. The goal: Take the input…
stotrami
  • 159
  • 1
  • 1
  • 11
2
votes
2 answers

python subprocess dd and stdout

I am using subprocess to create a random file from /dev/random using unix dd. Now, if i want the data output of dd to be written to a file instead of stdout. so here's the code am using, import subprocess out_fd = open('test_file','w') def…
Software Mechanic
  • 974
  • 2
  • 9
  • 25
2
votes
2 answers

How to Write Block of Random Data to File using Bash

I need to write a 5MB block of data obtained from /dev/urandom to a partition, at a specific location in the partition. I then need to check that the write executed correctly. I was previously successfully doing this in C++, but now I would like to…
2
votes
1 answer

Swap or replace bytes in a binary file from command line

There already is a beautiful trick in this thread to write bytes to binary file at desired address with dd ,is there any way to swap bytes(e.g swap 0x00 and 0xFF), or replace bytes with common tools (such as dd)?
janjin
  • 33
  • 3