注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Computer Science

I Pressed My Words Here. Will You Read ?

 
 
 

日志

 
 

DD 硬盘拷贝记录  

2011-10-06 09:04:43|  分类: With Ubuntu |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
最近我的笔记本的160GB的硬盘几乎装满了,需要换个更大的硬盘。我的笔记本电源支持最大的硬盘应该是在500GB,于是买了个500GB的硬盘,但是又不想重装系统,重新配置。于是选择了硬盘级的拷贝。这里用到了DD这个拷贝程序,命令如下:
will@computerscience.blog.163.com:~$ dd
^C0+0 records in
0+0 records out
0 bytes (0 B) copied, 2.14307 s, 0.0 kB/s

will@computerscience.blog.163.com:~$ dd if=/dev/sda of=/dev/sdb conv=noerror,sync bs=4k
dd: opening `/dev/sda': Permission denied
will@computerscience.blog.163.com:~$ sudo dd if=/dev/sda of=/dev/sdb conv=noerror,sync bs=4k
[sudo] password for will:
39072726+0 records in
39072726+0 records out
160041885696 bytes (160 GB) copied, 5746.82 s, 27.8 MB/s
will@computerscience.blog.163.com:~$

睡觉前执行的,一觉起来边完成了。
接下来只需要将500GB硬盘换到笔记本上,从USB上的UBUNTU启动运行GPATED分区管理软件,调整下分区大小边行了。
注:/dev/sda是我当前运行的操作系统所在的硬盘160G。/dev/sdb是我外接的移动硬盘盒中装的硬盘500G。
PS:通过 sudo fdisk -l 命令列出挂载的分区。


--------------------------------------------------------------------------------------
2013-01-18 backup mbr and sda1, sda2:
from: Disk Cloning https://wiki.archlinux.org/index.php/Disk_Cloning

Backing up the MBR

The MBR is stored in the the first 512 bytes of the disk. It consist of 3 parts:

  1. The first 446 bytes contain the boot loader.
  2. The next 64 bytes contain the partition table (4 entries of 16 bytes each, one entry for each primary partition).
  3. The last 2 bytes contain an identifier

To save the MBR into the file "mbr.img":

  # dd if=/dev/hda of=/mnt/sda1/mbr.img bs=512 count=1 

To restore (be careful : this could destroy your existing partition table and with it access to all data on the disk):

  # dd if=/mnt/sda1/mbr.img of=/dev/hda 

If you only want to restore the boot loader, but not the primary partition table entries, just restore the first 446 bytes of the MBR:

  # dd if=/mnt/sda1/mbr.img of=/dev/hda bs=446 count=1 

To restore only the partition table, one must use

  # dd if=/mnt/sda1/mbr.img of=/dev/hda bs=1 skip=446 count=64 

You can also get the MBR from a full dd disk image.

  #dd if=/path/to/disk.img of=/mnt/sda1/mbr.img bs=512 count=1 

Cloning a partition

From physical disk /dev/sda, partition 1, to physical disk /dev/sdb, partition 1.

dd if=/dev/sda1 of=/dev/sdb1 bs=4096 conv=notrunc,noerror 

My Record:
Step 1


ubuntu@ubuntu:~$ sudo fdisk -l

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x51047347

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2          206848   543547391   271670272    7  HPFS/NTFS/exFAT

Disk /dev/sdb: 3940 MB, 3940548608 bytes
122 heads, 62 sectors/track, 1017 cylinders, total 7696384 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006b646

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          62     7692587     3846263    c  W95 FAT32 (LBA)

Disk /dev/sdd: 750.2 GB, 750156372480 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149165 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfc33d124

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048  1465147116   732572534+   7  HPFS/NTFS/exFAT
ubuntu@ubuntu:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO MOUNTPOINT
loop0    7:0    0 667.1M  1 /rofs
loop1    7:1    0     3G  0
sda      8:0    0 698.7G  0
├─sda1   8:1    0   100M  0
└─sda2   8:2    0 259.1G  0
sr0     11:0    1  1024M  0
sdb      8:16   1   3.7G  0
└─sdb1   8:17   1   3.7G  0 /cdrom
sdd      8:48   0 698.7G  0
└─sdd1   8:49   0 698.7G  0
ubuntu@ubuntu:~$

Step 2

ubuntu@ubuntu:~$ sudo mkdir /mnt/sdd1
ubuntu@ubuntu:~$ sudo mount /dev/sdd1 /mnt/sdd1
ubuntu@ubuntu:~$ sudo dd if=/dev/sda1 of=/mnt/sdd1/mbr.img bs=4096 conv=notrunc,noerror
25600+0 records in
25600+0 records out
104857600 bytes (105 MB) copied, 5.19942 s, 20.2 MB/s
ubuntu@ubuntu:~$ ls -l /mnt/sdd1/
total 13188377
-rwxrwxrwx 1 root root          34 2012-02-13 18:57 autorun.inf
-rwxrwxrwx 1 root root 13383621100 2013-01-14 17:56 homewill.tar.gz
-rwxrwxrwx 1 root root   104857600 2013-01-18 00:24 mbr.img
drwxrwxrwx 1 root root           0 2013-01-14 20:35 $RECYCLE.BIN
-rwxrwxrwx 2 root root    16415068 2012-02-15 20:50 Software Offer.exe
drwxrwxrwx 1 root root           0 2013-01-14 21:47 System Volume Information
ubuntu@ubuntu:~$ sudo dd if=/dev/sda2 of=/mnt/sdd1/windows8.img bs=4096 conv=notrunc,noerror
67917568+0 records in
67917568+0 records out
278190358528 bytes (278 GB) copied, 7948.65 s, 35.0 MB/s
ubuntu@ubuntu:~$ ls -l /mnt/sdd1/
total 284858649
-rwxrwxrwx 1 root root           34 2012-02-13 18:57 autorun.inf
-rwxrwxrwx 1 root root  13383621100 2013-01-14 17:56 homewill.tar.gz
-rwxrwxrwx 1 root root    104857600 2013-01-18 00:24 mbr.img
drwxrwxrwx 1 root root            0 2013-01-14 20:35 $RECYCLE.BIN
-rwxrwxrwx 2 root root     16415068 2012-02-15 20:50 Software Offer.exe
drwxrwxrwx 1 root root            0 2013-01-14 21:47 System Volume Information
-rwxrwxrwx 1 root root 278190358528 2013-01-18 02:38 windows8.img
ubuntu@ubuntu:~$



===========================================================================
dd Nolia N9 2013-2-23 13:42:19
===============================
以同步模式链接Nokia N9 能看到一个38mb的sr1(我顺便将其mount到了/mnt/sr1)

will@ubuntu12041:~$ lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda       8:0    0 698.7G  0 disk
├─sda1    8:1    0   100M  0 part
├─sda2    8:2    0 259.1G  0 part
├─sda3    8:3    0     1K  0 part
├─sda4    8:4    0   513M  0 part
├─sda5    8:5    0     9G  0 part /tmp
├─sda6    8:6    0     9G  0 part [SWAP]
├─sda7    8:7    0    30G  0 part
├─sda8    8:8    0    30G  0 part /
├─sda9    8:9    0    30G  0 part
├─sda10   8:10   0    30G  0 part /home
├─sda11   8:11   0   100G  0 part /switch
└─sda12   8:12   0   201G  0 part /data
sr0      11:0    1  1024M  0 rom 
sdd       8:48   0 698.7G  0 disk
└─sdd1    8:49   0 698.7G  0 part /media/TOSHIBA EXT
sr1      11:1    1  36.3M  0 rom  /mnt/sr1

0 bytes (0 B) copied, 2.01991 s, 0.0 kB/swill@ubuntu12041:~$ sudo dd if=/dev/sr1 of=/media/TOSHIBA\ EXT/NokiaN9sr1.img bs=512 conv=notrunc,noerror
74384+0 records in
74384+0 records out
38084608 bytes (38 MB) copied, 7.24922 s, 5.3 MB/s
如果if是/mnt/sr1而非/dev/sr1的dd会说/mnt/sr1 is a directory.然后无法正常拷贝。

以大容量存储设备 模式链接:
will@ubuntu12041:~$ lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda       8:0    0 698.7G  0 disk
├─sda1    8:1    0   100M  0 part
├─sda2    8:2    0 259.1G  0 part
├─sda3    8:3    0     1K  0 part
├─sda4    8:4    0   513M  0 part
├─sda5    8:5    0     9G  0 part /tmp
├─sda6    8:6    0     9G  0 part [SWAP]
├─sda7    8:7    0    30G  0 part
├─sda8    8:8    0    30G  0 part /
├─sda9    8:9    0    30G  0 part
├─sda10   8:10   0    30G  0 part /home
├─sda11   8:11   0   100G  0 part /switch
└─sda12   8:12   0   201G  0 part /data
sr0      11:0    1  1024M  0 rom  
sdd       8:48   0 698.7G  0 disk
└─sdd1    8:49   0 698.7G  0 part /media/TOSHIBA EXT
sdc       8:32   1  53.7G  0 disk /media/Nokia N9
will@ubuntu12041:~$ sudo fdisk -l

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x51047347

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2          206848   543547391   271670272    7  HPFS/NTFS/exFAT
/dev/sda3       544600062  1465147391   460273665    5  Extended
Partition 3 does not start on physical sector boundary.
/dev/sda4   *   543547392   544598015      525312   83  Linux
/dev/sda5       563474432   582348799     9437184   83  Linux
/dev/sda6       544600064   563472383     9436160   82  Linux swap / Solaris
/dev/sda7       582350848   645265407    31457280   83  Linux
/dev/sda8       645267456   708182015    31457280   83  Linux
/dev/sda9       708184064   771098623    31457280   83  Linux
/dev/sda10      771100672   834015231    31457280   83  Linux
/dev/sda11      834017280  1043732479   104857600    7  HPFS/NTFS/exFAT
/dev/sda12     1043734528  1465147391   210706432   83  Linux

Partition table entries are not in disk order

Disk /dev/sdd: 750.2 GB, 750156372480 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149165 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfc33d124

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048  1465147116   732572534+   7  HPFS/NTFS/exFAT

Disk /dev/sdc: 57.7 GB, 57687932928 bytes
64 heads, 32 sectors/track, 55015 cylinders, total 112671744 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
will@ubuntu12041:~$ sudo dd if=/dev/sdc of=/media/TOSHIBA\ EXT/NokiaN9sdc.img bs=512 conv=notrunc,noerror
112671744+0 records in
112671744+0 records out
57687932928 bytes (58 GB) copied, 7304.35 s, 7.9 MB/s
will@ubuntu12041:~$

恩,这时间正好让我深入了解了下ubuntu phone的现状,决定不在N9上实验。
  评论这张
 
阅读(1879)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017