# Replacing my SSD
> 2023/6/6
## Backup
Assuming an offline backup
From https://wiki.archlinux.org/title/rsync
```
rsync -aAXHS --exclude={"/dev/*","/sys/*","/run/*"} / /path/to/backup
```
`-a` = archive mode, `-rlptgoD` (recursive, links, perms, times, group, owner, devices)
`-A` = ACL attrs
`-H` = hard links
`-S` = sparse
When it is offline your `/proc` and `/media` are normally empty. I also backup the `/tmp` because the disk space is almost free nowadays.
Some tricks:
* `--info=progress2` to show a rough progress.
* `--delete` to delete bogus files at destination. Useful when restoring to an existing system but is potentially destructive.
## Change UUIDs to original ones
You can also edit the target system's `/etc/fstab` to point to new ones.
### ext4 (via `tune2fs`)
From https://www.tecmint.com/change-uuid-of-partition-in-linux/
`tune2fs -U UUID_HERE /dev/sdbX`
> This operation requires a freshly checked filesystem. Please run `e2fsck -f` on the filesystem.
### FAT32 (via `mtools`)
https://superuser.com/a/1744103
`mlabel -N abcd1234 -i /dev/sdbX ::NEWEFI`
## Fix EFI
Assume systemd-boot+GPT+UEFI on a Debian-like system. Excerpted from https://support.system76.com/articles/bootloader/:
```bash
for i in dev dev/pts proc sys run; do sudo mount -B /$i /mnt/$i; done
sudo chroot /mnt
apt install --reinstall linux-image-generic linux-headers-generic
update-initramfs -c -k all
exit
sudo bootctl --path=/mnt/boot/efi install
```
You can review/modify the current boot order with `efibootmgr`.