I migrated the Linux on the HDD to the SSD. It was too much trouble to reinstall the system, so I copied the entire system directly, and then rebuilt the boot recovery. The following is the record.
Two hard drives
First, replace the SSD, and connect the HDD with a hard disk box.
After booting from the U disk, partition the SSD and mount the SSD system disk and HDD system disk to a certain path, for example:
For SSD, I divide it into /dev/sda1
and /dev/sda2
. The former is used for EFI boot and the latter is the system disk.
Then use rsync to synchronize data:
rsync -av --progress /mnt/ /data/
After the synchronization is complete, go to /data/etc to edit the fstab file and replace the original path with the new one. You can use blkid or lsblk -f to view UUID.
The next step is to rebuild the boot.
If it is a hard disk, I want to change the file system, for example, I switched from btrfs to ext4, the plan is as follows:
/mnt
and save the file to /opt: cd /opt && tar cvf data.tgz /mnt
sudo umount /mnt && mkfs.ext4 /dev/<the drive letter where the btrfs file system is located, for example, mine is sda2>
/mnt
, and unzip the compressed file under /opt: tar xvf data.tgz -C /
After the decompression is complete, enter /mnt/
etc to edit the fstab file, and replace the original path with the new one. You can use blkid
or lsblk -f
to view UUID.
The next step is to rebuild the boot.
Before updating grub, you must mount something, otherwise an error will be reported:
$ sudo mount --bind /dev /data/dev
$ sudo mount --bind /sys /data/sys
$ sudo mount --bind /proc /data/proc
$ sudo mount /dev/sda1 /data/boot/efi
Then chroot in and update the EFI boot:
$ sudo chroot /data
$ sudo apt-get install --reinstall grub-efi
$ sudo grub-install /dev/sda
$ sudo update-grub
Optimize file mounting options for SSD
Because I use ext4, optimized for SSD, change fstab, add the following options discard, noatime, so it looks like this:
UUID= UUID just updated / ext4 discard, noatime, errors=remount-ro 0 1
If the startup encounters Gave up waiting for suspend/resume device
First check if there is a problem with fstab, if so, change it; then check if there is any problem with the UUID of /etc/initramfs-tools/conf.d/resume
, if so, change it.
Then execute sudo update-initramfs -u
and restart.
Get it done! This is much faster than reinstalling the system, too lazy to reinstall and reconfigure.