无法从克隆硬盘启动

无法从克隆硬盘启动

我的笔记本电脑的硬盘很快就会出现故障(根据 SMART 的说法),因此我决定将整个驱动器克隆到另一个驱动器:

sudo sh -c 'cat /dev/sda >/dev/sdc'

使用新硬盘后,笔记本电脑显示以下错误:

Failed to start File System Check on /dev/.../78c...b86
Dependency failed for /home
Dependency failed for Load File System
...
Cannot open access to console, the root account is locked

两个驱动器上的 UUID 看起来相同:

> lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
sda                                                      
├─sda1 ntfs   XP    D6A46388A46369C7                     
├─sda3                                                   
├─sda5 ext4         f02a6d59-8411-4018-85da-bb6a521d91d0 /
├─sda6 swap         70bc8fb3-77e5-47e8-953f-63da54226679 [SWAP]
└─sda7 ext4         78c3867d-4382-4dff-ac7d-ed69c788db86 /home
sdc                                                      
├─sdc1 ntfs   XP    D6A46388A46369C7                     
├─sdc3                                                   
├─sdc5 ext4         f02a6d59-8411-4018-85da-bb6a521d91d0 
├─sdc6 swap         70bc8fb3-77e5-47e8-953f-63da54226679 
└─sdc7 ext4         78c3867d-4382-4dff-ac7d-ed69c788db86 

驱动器具有不同的大小和不同的物理扇区大小。但是,我无法证明这是本案中的一个问题。

> sudo fdisk -l
Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 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: 0xd961d961

Device     Boot    Start       End   Sectors  Size Id Type
/dev/sda1  *          63  43015687  43015625 20.5G  7 HPFS/NTFS/exFAT
/dev/sda3       43016190 215076863 172060674   82G  5 Extended
/dev/sda5       43016192  62545919  19529728  9.3G 83 Linux
/dev/sda6       62547968  68737023   6189056    3G 82 Linux swap / Solaris
/dev/sda7       68739072 215076863 146337792 69.8G 83 Linux

Disk /dev/sdc: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0xd961d961

Device     Boot    Start       End   Sectors  Size Id Type
/dev/sdc1  *          63  43015687  43015625 20.5G  7 HPFS/NTFS/exFAT
/dev/sdc3       43016190 215076863 172060674   82G  5 Extended
/dev/sdc5       43016192  62545919  19529728  9.3G 83 Linux
/dev/sdc6       62547968  68737023   6189056    3G 82 Linux swap / Solaris
/dev/sdc7       68739072 215076863 146337792 69.8G 83 Linux

Partition 1 does not start on physical sector boundary.
Partition 3 does not start on physical sector boundary.

这些文件/etc/fstab也是相等的。

笔记本电脑的屏幕坏了,我使用外接显示器。这对可以使用的工具施加了一些限制,例如Clonezilla“Live CD 不显示输出”。

在这种情况下可以做什么?

更新1:尝试用 来完成任务dd bs=1M if=/dev/sda of=/dev/sdc。遇到同样的错误。不得不说,Windows 可以通过catdd方法从其分区正确启动。

更新2:源硬盘上的所有坏块都位于该/home分区中/dev/sda7。第一个LBA号是127221317。我发现大约300个坏块,最后一个LBA号是146938319,然后就停止了。看来还有很多。

答案1

/etc/fstab我通过更改安装点的文件解决了该问题/home,如下所示:

不起作用(不知道为什么):

UUID=78c3867d-4382-4dff-ac7d-ed69c788db86 /home ext4 defaults,errors=remount-ro 0 1

作品:

/dev/sda7 /home ext4 defaults,errors=remount-ro 0 1

答案2

您是否在正在使用的分区上运行了克隆操作?也就是说,它是由进行克隆的操作系统使用的吗?

如果是这样,那么它将被损坏,请从 Live CD/USB 存储设备启动,然后重试。

答案3

学到了一些新东西, cat 和 dd 确实与 ctrl-alt-delor 所说的相同/二进制透明。当我第一次尝试 cat 克隆磁盘时,我一定做错了什么,或者其他地方出了问题,甚至可能是 CD 驱动器,因此我错误地认为 cat 不是适合这项工作的工具,因为我习惯于 dd我已经回去使用它了。

  • 我保留我就上述问题本身发表的关于不在已安装的驱动器上执行克隆操作的评论。

  • 我备用将主目录复制到新磁盘上的全新安装的方法,作为从制作的副本迁移的解决方案,如我原来的帖子中所述。

    "Or you could just copy the home directory on the drive you created to a 
    fresh install with all the same packages installed and all should be well."
    

    喜欢:这里

  • 我备用此信息(知道 cat 也会做同样的事情):

    dd would have made it appear as if the drive was the exact same. All that 
    would have been needed would be to expand the partitions to fit, with gparted.
    Doing so would have also adjusted the partition table that was written while
    cloning with dd. So there would have been no need for messing with grub.
    dd copies every byte.
    
  • 我在下面撤回之前的错误信息:

    Cat only copies the contents of files/known data structures on the drive. 
    

是什么让我有这样的想法:

  • 我之前在将 CD 复制到 USB 时注意到过猫的这种行为。 dd 使 USB 显示为实际的 CD,而 cat 使文件结构看起来相同,但对于操作系统而言,它看起来不像实际的 CD。 (发生在几年前,所以不知道我到底做错了什么:()

我现在所知道的:

  • cat 的行为与 dd 相同,而且看起来也更快。

相关内容