[心得] rsync備份系統以及grub重新安裝

看板Linux作者 (.)時間3年前 (2021/03/03 21:40), 3年前編輯推噓4(409)
留言13則, 4人參與, 3年前最新討論串1/1
原來的系統硬碟怪怪的,又有not start from physical sectors問題。 怕重新開機後開不了,以及想用新的分割,網路找到最佳方案似乎是用 rsync做系統移動。使用的OS是fedora21,以下是操作過程。 #Issue: some original OS SSD partitions do not start from physical sectors and encounter failing probability. This may comes from direct system backup using clonezilla from 256G SSD to 500G SSD # Original SSD has 3 primary partitions, 1 extended partition, 1 logical partition. New goal is to eliminate sector alignment issue and to re-partition SSD #Step A: partition new Disk #Step A.1: make disk label as msdos parted /dev/sdX mklabel msdos # (it seems gpt partition cannot work as bootable device) #Step A.2: partition new disk with parted. #(This step could also be done with fdisk) parted /dev/sdX mkpart primary 1M 1G # creat /boot parted /dev/sdX mkpart primary 1G 3G # creat swap parted /dev/sdX mkpart primary 3G 99% # creat / parted /dev/sdX mkpart primary 99% 100% # creat /home #Step A.3: assign bootable partition parted /dev/sdX set 1 boot on # make /dev/sdX1 bootable Step A.4: format partitions and make swap mkfs -t ext4 /dev/sdX1 mkswap /dev/sdX2 mkfs -t ext4 /dev/sdX3 mkfs -t ext4 /dev/sdX4 #Step B: Assign Old UUIDs into new Disk #Step B.1: Show All UUIDs blkid #Step B.2: Update All UUIDs in new Disk tunefs2 -U Old_bootPartion_UUID /dev/sdX1 mkswap -U Old_swapPartition_UUID /dev/sdX2 tunefs2 -U Old_rootPartition_UUID /dev/sdX3 tunefs2 -U Old_homePartition_UUID /dev/sdX4 #Step C:mount new Disk partions in /mnt mount /dev/sdX3 /mnt mount /dev/sdX1 /mnt/boot mount /dev/sdX4 /mnt/home #Step D:synchronize all system. Sometimes /boot must be synchronize seperately rsync -aAxHAX --progress / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*", "/media/*","/lost+found"} /mnt #Step E:grub install #Step E.1: grub install in new disk. Without this step, BIOS could not identify new Disk as bootable device grub2-install --boot-directory=/mnt/boot /dev/sdX #Step E.2 make grub configurations for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done chroot /mnt dracut -f #(Without this step, dracut could keep searching old disk settings in booting process) grub2-mkconfig -o /boot/grub2/grub.cfg # after chroot /mnt, system regard /mnt/boot as /boot. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 150.116.204.152 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1614778804.A.104.html

03/04 14:01, 3年前 , 1F
為什麼不止備份資料碟就好
03/04 14:01, 1F

03/04 14:01, 3年前 , 2F
還要用dracut 跟grub粉麻煩
03/04 14:01, 2F

03/04 16:29, 3年前 , 3F
其實已經有分別用dd跟rsync備兩份到資料碟了
03/04 16:29, 3F

03/04 16:31, 3年前 , 4F
dd還原是我惡搞不成後的最後手段
03/04 16:31, 4F

03/04 16:34, 3年前 , 5F
為了debug 跟bypass physical sector issue
03/04 16:34, 5F

03/04 16:34, 3年前 , 6F
clonezilla我只好捨棄不用
03/04 16:34, 6F

03/04 16:42, 3年前 , 7F
最後採取這種繞了一大圈的rsync+grub install,在原系
03/04 16:42, 7F

03/04 16:42, 3年前 , 8F
統重開機前,把系統備份到新系統碟
03/04 16:42, 8F
※ 編輯: ringballer (150.116.204.152 臺灣), 03/04/2021 21:19:06

03/04 23:03, 3年前 , 9F
bypass 是啥意思 壞掉的磁區直接改成\0ㄇ
03/04 23:03, 9F

03/05 01:57, 3年前 , 10F
在新系統碟用新partition裝舊系統而已
03/05 01:57, 10F

03/05 16:34, 3年前 , 11F
Fedora 21... 為什麼不乾脆直接用 CentOS 7 @@
03/05 16:34, 11F

03/05 16:35, 3年前 , 12F
還是那是原本的系統XD
03/05 16:35, 12F

03/20 19:58, 3年前 , 13F
這招會用,很多問題皆可解
03/20 19:58, 13F
文章代碼(AID): #1WFv6q44 (Linux)
文章代碼(AID): #1WFv6q44 (Linux)