Различия
Здесь показаны различия между двумя версиями данной страницы.
| Следующая версия | Предыдущая версия | ||
|
dev:ubuntu:clonedisk [2013/04/18 15:57] jamis7005 создано |
dev:ubuntu:clonedisk [2013/04/19 19:01] (текущий) jamis7005 |
||
|---|---|---|---|
| Строка 1: | Строка 1: | ||
| ====== Clone HDD or flash disks ====== | ====== Clone HDD or flash disks ====== | ||
| - | ===== Copying one partition ===== | + | ===== Whole disk ===== |
| - | + | dd if=/dev/sda of=hdd.img | |
| - | The image created may be too large for your hard drive:\\ | + | dd if=hdd.img of=/dev/sda |
| - | ''dd if=/dev/sda of=hdd.img'' | + | |
| - | + | ||
| - | Clone the image back onto another drive:\\ | + | |
| - | ''dd if=hdd.img of=/dev/sda'' | + | |
| | | ||
| + | ===== One partition ===== | ||
| + | dd if=/dev/sda1 of=hdd.img | ||
| + | dd if=hdd.img of=/dev/sda1 | ||
| | | ||
| + | ===== One partition ===== | ||
| + | dd if=/dev/sda1 of=hdd.img | ||
| + | dd if=hdd.img of=/dev/sda1 | ||
| + | | ||
| + | ===== CD ===== | ||
| + | dd if=/dev/cdrom of=/mnt/cdbackup.iso | ||
| + | dd if=/mnt/cdbackup.iso of=/dev/cdrom | ||
| + | |||
| + | ===== Over network ===== | ||
| + | Clone drives over a network:\\ | ||
| + | dd if=/dev/sda | ssh username@host "dd of=/dev/sda" | ||
| + | |||
| + | Dump an image over a network:\\ | ||
| + | dd if=/dev/sda | ssh username@host "dd of=/mnt/hdd.img" | ||
| + | |||
| + | Clone a networked drive onto yours:\\ | ||
| + | ssh username@host "dd if=/dev/sda" | dd of=/dev/sda | ||
| + | |||
| + | Clone a networked image onto yours:\\ | ||
| + | ssh username@host "dd if=/mnt/hdd.img" | dd of=/dev/sda | ||
| ===== Copying MBR ===== | ===== Copying MBR ===== | ||
| + | [[http://www.cyberciti.biz/faq/howto-copy-mbr|src]]\\ | ||
| MBR Total Size = 446 + 64 + 2 = 512 | MBR Total Size = 446 + 64 + 2 = 512 | ||
| * 446 bytes - Bootstrap. | * 446 bytes - Bootstrap. | ||
| Строка 23: | Строка 43: | ||
| **dd command to copy MBR (identically sized partitions only)** | **dd command to copy MBR (identically sized partitions only)** | ||
| - | Type dd command as follows: | + | Type dd command as follows:\\ |
| - | ''dd if=/dev/sda of=/dev/sdb bs=512 count=1'' | + | dd if=/dev/sda of=/dev/sdb bs=512 count=1 |
| Above command will copy 512 bytes (MBR) from sda to sdb disk. This will only work if both discs have identically sized partitions. | Above command will copy 512 bytes (MBR) from sda to sdb disk. This will only work if both discs have identically sized partitions. | ||
| Строка 30: | Строка 50: | ||
| **dd command for two discs with different size partitions** | **dd command for two discs with different size partitions** | ||
| - | ''dd if=/dev/sda of=/tmp/mbrsda.bak bs=512 count=1'' | + | dd if=/dev/sda of=/tmp/mbrsda.bak bs=512 count=1 |
| + | |||
| + | Now to restore the image to any sdb:\\ | ||
| + | dd if=/tmp/mbrsda.bak of=/dev/sdb bs=446 count=1 | ||
| + | |||
| + | ** example: 32Gb to 8Gb**\\ | ||
| + | Given: | ||
| + | * sdc: 32Gb with sdc1=4Gb, sdc2=4Gb, and 23Gb of free space. | ||
| + | * sdd: 8Gb | ||
| + | |||
| + | Count number of blocks to copy: | ||
| + | 8015282176/512 = 15654848 | ||
| + | |||
| + | Create image file: | ||
| + | sudo dd if=/dev/sdc of=jr1.img count=15654848 | ||
| + | |||
| + | Write image file: | ||
| + | sudo dd if=jr1.img of=/dev/sdd | ||
| + | ===== Watching Progress ===== | ||
| + | |||
| + | First, find out the process id of the dd process by running the following in the new virtual terminal. | ||
| + | $ pgrep -l '^dd$' | ||
| + | 8789 dd | ||
| + | |||
| + | |||
| + | To send the USR1 signal to the dd prcoess: | ||
| + | $ kill -USR1 8789 | ||
| + | $ | ||
| + | |||
| + | |||
| + | Note that as soon as the USR1 signal is detected, dd will print out the current statistics to its STDERR. | ||
| + | $ dd if=/dev/random of=/dev/null bs=1K count=100 | ||
| + | 0+14 records in | ||
| + | 0+14 records out | ||
| + | 204 bytes (204 B) copied, 24.92 seconds, 0.0 kB/s | ||
| - | Now to restore the image to any sdb: | ||
| - | ''dd if=/tmp/mbrsda.bak of=/dev/sdb bs=446 count=1'' | ||