尝试对ubuntu进行全盘备份与恢复。参见教程:https://www.zybuluo.com/ghosert/note/3408
拷贝到目标磁盘后,按照教程安装boot-repair,然后修复:
第一次将磁盘改为了GTP格式,所以提示要预留1M以上未格式化空间, 标签为boot_grub,最后没有弄出来,所以直接由改了磁盘格式,这个问题暂时不处理。
改为msdos8后,出现的如下问题:
Please enable a repository containing the [grub2] packages in the software sources of Ubuntu 18.04.3 LTS(sda3).Then try again.
字面理解没什么问题,理论上目前的源缺少grub2这个包,加上就好了。
系统本身会弹出一个列表的源,用来添加,全部添加上去,依旧提示错误,也尝试从其他电脑直接拷贝过来,没有效果。但是直接apt install grub2都是成功的。
最终google出了解决方法:
https://askubuntu.com/questions/867621/boot-repair-enable-a-repository-containing-grub2-packages
运行下面命令后,可以启动
sudo mount /dev/sda3 /tmp/root/
sudo mount --bind /dev /tmp/root/dev/
sudo mount --bind /dev/pts /tmp/root/dev/pts
sudo mount --bind /proc /tmp/root/proc
sudo mount --bind /sys /tmp/root/sys
sudo chroot /tmp/root/
grub-install /dev/sda
grub-install --recheck /dev/sda
update-grub
exit
sudo umount /tmp/root/sys
sudo umount /tmp/root/proc
sudo umount /tmp/root/dev/pts
还存在的问题:因为测试时,在/dev/sdb也安装了一个ubuntu,系统启动后默认用户名时新装ubunu的,登陆界面无法登陆,切换到非图形界面后,可以登陆原用户,但是home目录忘了迁移,所以startx无法启动,显示timeout in locking authority file ***/.Xauthority
root用户可以登陆,startx成功启动图形界面,但是锁定后无法登陆。