大网数据广告活动
服务器运维问答

Initramfs error after image restore using dd

· 52CE 我爱测

I need to create backups of a Ubuntu system in a way that I can easily restore the data and system as it is exactly in a ready to go state. So, I decided to go with dd to create a whole HHD images. I created the image as follows:…

问题原文

原帖链接 · CuriousGuy · CC BY-SA 3.0

I need to create backups of a Ubuntu system in a way that I can easily restore the data and system as it is exactly in a ready to go state. So, I decided to go with dd to create a whole HHD images.

I created the image as follows:

dd if=/dev/current_drive of=/dev/backup_drive/backup.img conv=sync status=progress

The image was done without errors. After that I decided to restore the image to a test new drive:

dd if=/backup_drive/backup.img of=/dev/new_drive conv=sync status=progress

So far, so good. The image restore went without errors. But when I tried to boot from the new hard which got the image restored on, I encountered initramfs errors:

So after manual fsck the errors were cleaned and I was able to boot from the new HDD. But I tried couple of times the procedure of restoring the image to the drive and each time I got problems with booting. My original system drive and the new one are absolutely identical according to

sudo fdisk -l:

/dev/sda/ is the new hard drive.

/dev/sdb/ is the original one from which the image was created.

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 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
Disklabel type: dos
Disk identifier: 0xf11c2eb5

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048 455024639 455022592  217G 83 Linux
/dev/sda2       455026686 488396799  33370114 15.9G  5 Extended
/dev/sda5       455026688 488396799  33370112 15.9G 82 Linux swap / Solaris


Disk /dev/sdb: 232.9 GiB, 250059350016 bytes, 488397168 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
Disklabel type: dos
Disk identifier: 0xf11c2eb5

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sdb1  *         2048 455024639 455022592  217G 83 Linux
/dev/sdb2       455026686 488396799  33370114 15.9G  5 Extended
/dev/sdb5       455026688 488396799  33370112 15.9G 82 Linux swap / Solaris

So, any ideas what I am doing wrong and why I get boot errors after image restore? I don't want in a real situation to have to fix the eventual new hard drive in case of failure of the original one.

Btw, the original drive is SSD, while the new one is HDD if this matters.

已采纳解答

原帖链接 · kubanczyk · CC BY-SA 3.0

Yes dd cannot make a coherent image of a living system. The bytes copied at the beginning of your image are from a different moment in time than the ending bytes. In other words, it's not a snapshot. That's why fsck complains.

I see use-the-simplest-tool tactic here, which is good because you can better predict the outcome. I suggest to prepare identical filesystems and copy file-by-file with rsync -aHAXE --delete-during source destination

It's also not a snapshot, but at least the fsck won't complain.

To maintain bootability with rsync, you grub-install a new disk, enforcing a new root location. Roughly speaking it will link the new boot sector with the contents of new /boot/

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-02-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。