I have a dual boot system with this partition layout:
# fdisk -l Disk /dev/sda: 596.2 GiB, 640135028736 bytes, 1250263728 sectors Disk model: SAMSUNG HM640JJ Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x08c427b9 Device Boot Start End Sectors Size Id Type /dev/sda1 80325 30800324 30720000 14.7G 7 HPFS/NTFS/exFAT /dev/sda2 30800325 440400559 409600235 195.3G 7 HPFS/NTFS/exFAT /dev/sda3 440403966 1132820479 692416514 330.2G f W95 Ext'd (LBA) /dev/sda4 * 1132820480 1250263039 117442560 56G 83 Linux /dev/sda5 440403968 1116043263 675639296 322.2G 7 HPFS/NTFS/exFAT /dev/sda6 1116045312 1132820479 16775168 8G 82 Linux swap / Solaris Partition table entries are not in disk order. and it's MBR according to parted and gdisk. After I installed linux I never booted to windows again and regularly backup the entire 60G partition of linux and first 63 sectors of HDD using dd to an external HDD while I boot from a live linux image.
dd if=/dev/sda4 of=linux.img bs=4096 conv=fdatasync dd if=/dev/sda of=boot.img bs=512 count=63 conv=fdatasync after my linux broke (for the first time) I attempted to restore it using the inverse above boot from live then
dd if=linux.img of=/dev/sda4 bs=4096 conv=fdatasync dd if=boot.img of=/dev/sda bs=512 conv=fdatasync dd didn't report any errors and linux partition recovered as intended. however I was unable to boot (system was keeping reboot as there was something wrong with Grub, a blinking cursor then sudden restart over and over). Finally booted again using live then chroot and grub-install. after this I was able to boot again normally.
I backup the first 63 sectors because Grub uses there for the core image (if I'm not wrong). and the first thing I did after booting was dumping there to a newboot.img file, then:
diff boot.img newboot.img returned nothing, which means even after re-installing grub, that area is the same.
- What's the root cause of not being able to boot in this case?
- How should I do the backup (avoiding 3rd parties)?
To best of my knowledge, no partition changes, no UUIDs... both images created together. Can grub code continues somewhere after sector 63? where and how long?
Thank you.