Fast HDD or FLASH cloning in linux

written by Admin


Posted on 2013-02-19


Problem

What about a fast cloning method for a compact flash/usb memory/external or internal hard-disk drive using a single linux shell command?

Solution

Don't simply use:
#dd if=/dev/IN_DEVICE of=/dir/file.img

Try instead:
#dd if=/dev/IN_DEVICE bs=1M iflag=direct | dd of=/dir/file.img bs=1M oflag=direct


It is remarcably faster because:

- using two processes, reading and writing are asyncronous,
- using large block transfers you can reach the maximum throughput,
- the direct I/O may speed up the process a lot if you are using a fast machine,
- you can also rise your drive readahead:
#blockdev --setra 1024 /dev/IN_DEVICE

Use, in another shell:
#watch -n 10 killall -USR1 dd
...to watch progess.

Feedback


Comments

Leave a Comment:

Search

Welcome

We need collaboration and a real boost from our community: write us an email for every trick you find!

This website is a sysadmin swiss-knife for every-day Windows, Linux and Mac administration and troubleshooting

Our database grows if YOU send us your tips and trick as soon as you find them every day!