Ubuntu20.04+Windows10 dual system migration new hard disk and solve the whole process of boot damage summary


Due to work needs, I want to migrate the Ubuntu system to a new SSD. This article provides solutions to a series of problems that arise after the system migration.

Original software and hardware environment:
OS1: Ubuntu20.04 (nvme0, PM981 512GB)
OS2: Windows10 (nvme1, SN850X 1TB)

There is a brand new SSD 7100Plus 2TB, the task is to replace the PM981, and migrate the Ubuntu system and the original environment to the new 2TB hard drive.

1. Back up the original system

1.1 Compress the / directory of the original system

sudo tar -cvpzf ubuntu_backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/home --exclude=/boot --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/run /

Several unwanted folders are excluded here:

proc stores the process files of the system, dynamically changes tmp according to the process running in the current system
stores the system cache file
home because the home directory is mounted on a separate partition, so
root will be packaged separately later because the root directory is mounted on a partition alone, so lost+found will be packaged separately later when the system fails,
try to restore media according to the contents of this folder when inserting an external storage device
such as a USB disk.

2. Install the new system

First use the USB flash drive to make an ubuntu installation disk. The software for making the installation disk can choose 启动盘创建器the software that comes with ubuntu, or ultraISO, rufus and the like. Start the computer, enter the bios setting, set the priority to start as a usb device, and then enter the installation disk system. The partition is set according to the size of the hard disk, such as a 2TB SSD:

200M , unformatted, 无
20G , ext4, /boot
250G , ext4, /
16G, linux_swap, 无
剩下的全部, ext4, /home

3. Migration system

Then decompress the previously packed compressed package to the corresponding partition in the new hard disk:

tar -xzvpf ubuntu_backup.tar.gz -C  <`新硬盘中被划分为/的分区位置`>

4. Boot Repair

4.1 Ubuntu Boot Repair

After the decompression is completed, the original system already exists in the new hard disk, but it cannot be booted normally at this time. Use the USB boot disk to enter the installation interface, select it, and then enter the system to download boot-repair for automatic repair (the essence is to install the grub program to the bios_grub partition at the head of the hard disk, and then modify the UUID corresponding to the / directory and /boot directory in the /boot/grub/grub.cfg file) Try Ubuntu:

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair
boot-repair

Click Execute to repair. After the repair is completed, you can enter the Ubuntu system.

4.2 Win10 Boot Repair

Download and install PE, use UEFI to boot in BIOS, and use dism++ to boot and repair. After the repair is completed, restart to enter WIn10.

4.3 Dual system grub repair

Confirm that the BIOS is booted in UEFI mode, and then use the USB boot disk to enter the installation interface, select it Try Ubuntu, and perform boot-repair again. After the repair is complete, grub can be restored, and you can choose to enter any system.

Guess you like

Origin blog.csdn.net/m0_46339652/article/details/130246168