fdisk -l #查看硬盘分区状态
使用gparted分区
sudo -i
gparted /dev/sda
按原有硬盘方式分区,然后用硬盘复制命令逐个复制硬盘
dd if=/dev/oldsataspinningdisk of=/dev/newssd bs=64K conv=noerror,sync
修改硬盘guid
修改fstab
首先查看UUID:blkid /dev/sda5
修改硬盘UUID:
uuidgen 会返回一个合法的 uuid,结合 tune2fs 可以新生成一个 uuid 并写入 ext2,3,4 分区中:
比如新建或改变 sda5 的 uuid (需要 root 权限)
uuidgen | xargs tune2fs /dev/sda5 -U
你也可以把 fstab 里找到的原 uuid 写回分区:
tune2fs -U c1b9d5a2-f162-11cf-9ece-0020afc76f16 /dev/sda5
切换到新硬盘上
# Mount root partition:
sudo mount /dev/sdXY /mnt # /dev/sdXY is your root partition, e.g. /dev/sda1
# If you have a separate boot partition you'll need to mount it also:
sudo mount /dev/sdYY /mnt/boot
# Mount your virtual filesystems:
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
# Chroot
sudo chroot /mnt
更新grub
mkdir /boot/EFI
mount /dev/sda1 /boot/EFI
grub-install --recheck --target=x86_64-efi --efi-directory=/boot/EFI /dev/sda # only in case of errors in the step before,x86_64-efi may different on your computer
update-grub