dd

From Initq
Jump to: navigation, search

dd is the best to copy bit by bit. To copy a whole drive you can do

Let's say we have two drives, sda is our orginal drive and sdb is the new drive.

  • dd if=/dev/sda of=sda.boot bs=512 count=1
copy the boot sector from sda
  • dd if=/dev/sda of=sda.iso
copy the whole sda drive to a file
  • dd if=sda.boot of=/dev/sdb bs=512 count=1
copy the boot sector to new drive
  • dd if=sda.iso of=/dev/sdb
copy the info from sda.iso to the new drive

Status of dd

When you are copying with dd you might want to get the status of what dd is doing.

$ pgrep -l '^dd$'
6074 dd
 
lexiana:~# ps -eaf | grep dd
root         2     0  0 18:52 ?        00:00:00 [kthreadd]
root      6074  5942 11 20:37 pts/0    00:02:52 dd if /dev/sda of sda.iso
root      6321  5851  0 21:02 pts/1    00:00:00 grep dd
 
$ kill -USR1  6074
 
60345193+0 records in
60345193+0 records out
30896738816 bytes (31 GB) copied, 1597.27 s, 19.3 MB/s
 
$ watch -n 10 kill -USR1 6074
Personal tools