New answers tagged

3

Some quick answers: first, you didn't create a sparse file. Try these extra commands dd if=/tmp/BIL of=/tmp/sparse seek=1000 ls -ls /tmp/sparse You will see the size is 512003 bytes, but only takes 8 blocks. The null bytes have to occupy a whole block, and be on a block boundary for them to be possibly sparse in the filesystem. Why does the second ...


0

If you want to overwrite the start of big-file with the content of small-file without affecting the rest, you can just do with any Bourne-like shell: cat small-file 1<> big-file The <> redirection operator opens the file in read+write mode without truncation. That would be equivalent to using dd's conv=notrunc but without all the problems and ...


0

Example: printf '\xa1' | dd conv=notrunc of=Yourfile bs=1 seek=$((0xoffset))


2

Because you'd invoked ntfsfix on the restored volume, the Windows did checked it. From ntfsfix manual page: NAME ntfsfix - fix common errors and force Windows to check NTFS


8

Restore You can restore the image back to your replacement HDD with something along the lines of: # dd if=backup.img of=/dev/sd? You will end up with a clone of your original disk including all partitions and data. The downside to this is that the partitions won't be resized by dd so your replacement disk must be identical to or larger in capacity than ...


16

1) Borrowing from don_crissti's answer using tee, without dd or bashisms: sudo tee /dev/disk2 /dev/disk3 > /dev/disk4 < masi.img 2) Using pee from Debian's moreutils package: sudo dd if=masi.img | \ pee "dd of=/dev/disk2" "dd of=/dev/disk3" "dd of=/dev/disk4" With either method the number of output disks can be extended indefinitely.


13

You could try dcfldd It's an enhanced version of gnu dd and it can output to multiple files or disks at the same time: dcfldd if=masi.img of=/dev/disk2 of=/dev/disk3 of=/dev/disk4


1

dd in your example does full system image backup, byte to byte mirroring /dev/sda to /dev/sdb. However you must be sure that /dev/sdb if equal or larger size disk. Modern systems do not permit plain copying like that because they embed some other unique identity information like UUIDs into volumes; there maybe issues with LVM setups, on-disk cryptography ...


-1

dd just copies its input to its output. If the input is a disk image, the output is a disk image of the same size. You can't copy a disk to a smaller disk. Instead, you need to create smaller partitions on the target disk, create smaller filesystems on those partitions, and copy the files. Here the simplest method would be to shrink the /home filesystem, ...


2

I find myself quite often in a situation when pv image_file | dd of=/dev/slow_usb_stick shows that first few hundred megabytes just fly (to the buffer), then the transfer slows down badly. When dd exits there is entire buffer to flush. I then sync in order to remove the stick and I have to wait few more minutes because the buffer is large and the device is ...


-2

Your command is trying to copy the entire disk (if=/dev/sdX) to the external drive. I would guess that your Linux install is on a separate partition from your Windows installation. Therefore you need to specify that partition. For example if=/dev/sda1. You likely do not need to specify a partition for your external disk so of=/dev/sdY should be ok. To find ...


8

Bear in mind that dd is a raw interface to the read(), write() and lseek() system call. You can only use it reliably to extract chunks of data off regular files, block devices and some character devices (like /dev/urandom), that is files for which read(buf, size) is guaranteed to return size as long as the end of the file is not reached. For pipes, sockets ...


3

With a bashism, and a functionally "useless use of cat", but closest to the syntax the OP uses: cat <(dd if=file1 bs=1M count=99 skip=1) \ <(dd if=file2 bs=1M count=10) \ > final_output (That being said, Stephen Kitt's answer seems to be the most efficient possible method.)


18

dd can write to stdout too. ( dd if=file1 bs=1M count=99 skip=1 dd if=file2 bs=1M count=10 ) > final_output


10

I don't think you can easily read multiple files in a single dd invocation, but you can append to build the output file in several steps: dd if=file1 bs=1M count=99 skip=1 of=final_output dd if=file2 bs=1M count=10 of=final_output oflag=append conv=notrunc You need to specify both conv=notrunc and oflag=append. The first avoids truncating the output, the ...



Top 50 recent answers are included