1---2title: "ArchLinux 系统迁移"3date: 2020-04-13T00:00:00+08:004---56>此文用来迁移 Arch Linux 至新硬盘,可能同时适用于其他系统,请自行尝试。7>本文使用 uefi 启动8910## 1. 准备11一张刻好 Arch LiveUSB 系统的 u盘,如不作说明,以下操作皆在 Arch LiveUSB 系统上完成。涉及危险操作,做好备份12<!-- More -->1314## 2. 初始化新硬盘15将新硬盘预先分好区。1617## 3. 挂载18将新旧硬盘的分区按照**系统的目录层次**挂载好。笔者将旧硬盘挂载到 /mnt/old,新硬盘挂载到 /mnt/new1920## 4. 使用 rsync 转移数据21```22rsync -qaHAXS /mnt/old/ /mnt/new23```2425## 5. 重新写入分区表2627```28genfstab /mnt/new -U > /mnt/new/etc/fstab2930cat /mnt/new/etc/fstab #有必要检查一下分区表是否正确31```3233## 6. 更换启动项 (GRUB)34```35arch-chroot /mnt/new # 进入新硬盘的系统3637grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB-NEW38# esp 为新硬盘上的 efi 挂载点, bootloader-id 参数可自定义。39# 此命令会自动生成启动项,新硬盘上的旧启动文件可删除。4041grub-mkconfig -o /boot/grub/grub.cfg # 更新 grub 配置文件42```4344## 7. 确认启动顺序45```46efibootmgr47```48查看默认启动是否为新的。如果不是,使用49```50efibootmgr -o id1,id2...51```52更换启动顺序。5354## 8. 重启55如果需要,重新制作 swap 分区并写入分区表565758### 9. 参考:59[将 Arch Linux 转移到新硬盘上](https://rapiz.me/2020/migrate-arch/)60[Arch Wiki](https://wiki.archlinux.org/index.php/Migrate_installation_to_new_hardware#Copy_the_system_to_a_new_drive)