Копирование системного раздела Linux на другой накопитель

Raspberry Pi

sfdisk -d /dev/mmcblk0 | sfdisk /dev/sda
dd if=/dev/mmcblk0p1 of=/dev/sda1
mkfs.ext4 /dev/sda2
mount /dev/sda2 /mnt/
mkdir /mnt/boot/
mount /dev/sda1 /mnt/boot/
rsync -axhPHAX / /mnt/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
blkid
sed -i 's/PARTUUID_old/PARTUUID_new/g' /mnt/etc/fstab
sed -i 's/PARTUUID_old/PARTUUID_new/g' /mnt/boot/cmdline.txt
umount /mnt/boot/
umount /mnt

Debian 11

sfdisk -d /dev/sda | sfdisk /dev/sdb
mkfs.ext4 /dev/sdb1
mount /dev/sdb1 /mnt/
rsync -axhPHAX / /mnt/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
blkid
sed -i 's/UUID_old/UUID_new/g' /mnt/etc/fstab
sed -i 's/UUID_old/UUID_new/g' /mnt/boot/grub/grub.cfg
# sed -i 's/UUID_old/UUID_new/g' /mnt/boot/EFI/debian/grub.cfg
for i in /dev /dev/pts /proc /sys /run; do mount -B $i /mnt$i; done
chroot /mnt/
grub-install --recheck /dev/sdb
# grub-install --efi-directory=/boot --recheck /dev/sdb
# update-grub
for i in /dev/pts /dev /proc /sys /run; do umount /mnt/$i; done

Orange Pi

sed -i 's/UUID_old/UUID_new/g' /mnt/boot/orangepiEnv.txt

rsync options

-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-x, --one-file-system don't cross filesystem boundaries
-h, --human-readable output numbers in a human-readable format
-P same as --partial --progress
-H, --hard-links preserve hard links
-A, --acls preserve ACLs (implies -p)
-X, --xattrs preserve extended attributes

Добавить комментарий