How to make disk image with dd on Linux or Unix
admin
2023-03-07 00:41:51
0

How to clone an entire hard disk

The syntax is:
dd if=/dev/input/DEVICE-HERE of=/dev/OUTPUT/DEVICE-HERE bs=64K conv=noerror,sync
To clone /dev/sdc (250G) to /dev/sdd (250G) in Linux, enter:
# dd if=/dev/sdc of=/dev/sdd bs=64K conv=noerror,sync
To clone /dev/ada0 (250G) to /dev/adb0 (250G) in FreeBSD, enter:
# dd if=/dev/ada0 of=/dev/adb0 bs=64K conv=noerror,sync
Where,

  1. if=/dev/file : Input device/file.

  2. of=/dev/file : Output device/file.

  3. bs=64k : Sets the block size to 64k. You can use 128k or any other value.

  4. conv=noerror : Tell dd to continue operation, ignoring all read errors.

  5. sync : Add input blocks with zeroes if there were any read errors, so data offsets stay in sync.

How to clone a partition

To clone /dev/sdc1 to /dev/sdd1, enter:
# dd if=/dev/sdc1 of=/dev/sdd1 bs=128K conv=noerror,sync
Sample outputs:

15874+0 records in
15873+0 records out
1040252928 bytes transferred in 3.805977 secs (273320858 bytes/sec)

dd make disk image

You can boot from a live cd. Once booted, make sure no partitions are mounted from the source hard drive disk. You can store disk image on an external USB disk. The syntax is as follows
dd if=/dev/INPUT/DEVICE-NAME-HERE conv=sync,noerror bs=64K | gzip -c > /path/to/my-disk.image.gz
In this example, create disk image for /dev/da0 i.e. cloning /dev/da0 and save in the current directory:
# dd if=/dev/da0 conv=sync,noerror bs=128K | gzip -c > centos-core-7.gz
Sample outputs:

How to make disk image with dd on Linux or UnixFig.01: dd command in action
The above command just cloned the entire hard disk, including the MBR, bootloader, all partitions, UUIDs, and data.


How to restore system (dd image)

The syntax is:
# gunzip -c IMAGE.HERE-GZ | dd of=/dev/OUTPUT/DEVICE-HERE
For example:
# gunzip -c centos-core-7.gz | dd of=/dev/da0

Tip #1: Not enough disk space locally? Use remote box

You can send the image through ssh and save it on the remove box called server1.cyberciti.biz:
# dd if=/dev/da0 conv=sync,noerror bs=128K | gzip -c | ssh vivek@server1.cyberciti.biz dd of=centos-core-7.gz

Tip #2: See progress while making an image with dd

You need to use GNU dd with coreutils version 8.24 as follows (pass the status=progress to the dd):
# dd if=/dev/sdc1 of=/dev/sdd1 bs=128K conv=noerror,sync status=progress
Sample outputs:

How to make disk image with dd on Linux or Unixgdd (GNU DD) in action with progress bar running on MacOS X


Tip #3: Save extra information

  • See how to save and restore MBR only.

  • Not a fan of dd? See top 6 open source disk cloning and imaging softwares.

  • Want to deal with corrupted disk? Try ddrescue command.


相关内容

热门资讯

今日重磅消息“卡农炸金花.可以... 网上科普关于“卡农炸金花有没有挂”话题很是火热,小编也是针对卡农炸金花作*弊开挂的方法以及开挂对应的...
终于懂了“掌中乐游戏中心.真的... 家人们!今天小编来为大家解答掌中乐游戏中心透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪...
【第一财经】“经典联盟炸金花.... 您好:经典联盟炸金花这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这...
重磅消息“白金岛歪胡子.有挂吗... 家人们!今天小编来为大家解答白金岛歪胡子透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里...
今日重大消息“葫芦娃哥们.到底... 家人们!今天小编来为大家解答葫芦娃哥们透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪里买...
重磅消息“微乐福建麻将.真的有... 您好:微乐福建麻将这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这款...
终于了解“先锋大厅.有没有挂?... 终于了解“先锋大厅.有没有挂?”果然有透视挂您好,先锋大厅这个游戏其实有挂的,确实是有挂的,需要了解...
集体公告!百亿富豪被警方采取刑... “祥源系”实控人俞发祥,已被警方采取刑事强制措施。12月22日晚,祥源文旅、交建股份、海昌海洋公园同...
终于了解“兴动棋牌麻将.可以开... 网上科普关于“兴动棋牌麻将有没有挂”话题很是火热,小编也是针对兴动棋牌麻将作*弊开挂的方法以及开挂对...
今日重磅消息“新老夫子炸金花.... 家人们!今天小编来为大家解答新老夫子炸金花透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪...