OpenWRT x86 Style Disks and Booting: Difference between revisions

mNo edit summary
mNo edit summary
Line 6: Line 6:
Copy the MBR and "MBR Gap" (GRUB Stage 1, GRUB Stage 1.5 (containing the CORE.IMG file)): <code>dd if=/dev/sdX of=/dev/sdY bs=512 count=511</code>
Copy the MBR and "MBR Gap" (GRUB Stage 1, GRUB Stage 1.5 (containing the CORE.IMG file)): <code>dd if=/dev/sdX of=/dev/sdY bs=512 count=511</code>


*Breaking it down into two steps, see below (but watch out, because for some reason DD doesn't seem to do something right regardless of the order the below are done, so better to get the MBR and MBR Gap all at the same time, so just giving the below as an option / example);
*Breaking it down into two steps, see below (but watch out, because for some reason DD doesn't seem to do something right regardless of the order the below are done, so better to get the MBR and MBR Gap all at the same time, so just giving the below as an option / example); ...and figured it out for the 'writing to partition' part, syntax error, should have used seek, not skip.
**Copy the "MBR Gap" (GRUB Stage 1.5, containing the CORE.IMG file): <code>dd if=/dev/sdX of=/dev/sdY bs=512 skip=1 count=511</code>
**Copy the "MBR Gap" (GRUB Stage 1.5, containing the CORE.IMG file): <code>dd if=/dev/sdX of=/dev/sdY bs=512 skip=1 count=511</code>
**Copy the MBR (GRUB Stage 1 and Partition Table): <code>dd if=/dev/sdX of=/dev/sdY bs=512 count=1</code>
**Copy the MBR (GRUB Stage 1 and Partition Table): <code>dd if=/dev/sdX of=/dev/sdY bs=512 count=1</code>
*Example:  <code>dd if=/dev/sdb of=/mnt/sda1/MBR_and_MBR-Gap.img conv=noerror bs=512 count=511 status=progress</code>
*Example of saving to an Image File:  <code>dd if=/dev/sdb of=/mnt/sda1/MBR_and_MBR-Gap.img conv=noerror bs=512 count=511 status=progress</code>
*Example of saving to a Disk / SSD from an Image File:  <code>dd if=/run/media/root/NTFS/MBR_and_MBR-Gap.img of=/dev/sdc conv=noerror bs=512 status=progress</code>
*Why 511 sectors?  Use CFDISK (or any other Partitioning Utility) and you'll see that the first Sector of the first Partition starts at Sector 512.  That is just the arrangement the OpenWRT developers chose.  Research indicates this "MBR Gap" can vary quite a bit depending on the OS.  Even different versions of Windows have different size "Gaps".  IE, the size is arbitrary and not set in stone.  Lesson?  Use a Partition Utility to look and see how things are arranged.  Oh, one other note on the research.  It seems that the GRUB 1.5 Stage is made to fit in 32K.  So why did the OpenWRT developers that focus so much on refinement and minimization use a whopping 256K for the MBR Gap?  The answer appears to be known only to them as there is no direct way to ask them.  ChatGPT was asked and the answer was so bad, it was way worse than not knowing.
*Why 511 sectors?  Use CFDISK (or any other Partitioning Utility) and you'll see that the first Sector of the first Partition starts at Sector 512.  That is just the arrangement the OpenWRT developers chose.  Research indicates this "MBR Gap" can vary quite a bit depending on the OS.  Even different versions of Windows have different size "Gaps".  IE, the size is arbitrary and not set in stone.  Lesson?  Use a Partition Utility to look and see how things are arranged.  Oh, one other note on the research.  It seems that the GRUB 1.5 Stage is made to fit in 32K.  So why did the OpenWRT developers that focus so much on refinement and minimization use a whopping 256K for the MBR Gap?  The answer appears to be known only to them as there is no direct way to ask them.  ChatGPT was asked and the answer was so bad, it was way worse than not knowing.


Copy the First Partition (/boot Directory): <code>dd if=/dev/sdX1 of=/dev/sdY1 bs=128M conv=noerror progress=status</code>
Copy the First Partition (/boot Directory): <code>dd if=/run/media/root/NTFS/Boot.img of=/dev/sdc skip=511 conv=noerror bs=512 status=progress</code>
 
* Example of saving to a Disk / SSD from an Image File: <code>dd if=/dev/sdb of=/mnt/sda1/MBR_and_MBR-Gap.img conv=noerror bs=512 count=511 status=progress</code>


Copy the Second Partition (/root equivalent): <code>dd if=/dev/sdX2 of=/dev/sdY2 bs=128M  conv=noerror progress=status</code>
Copy the Second Partition (/root equivalent): <code>dd if=/dev/sdX2 of=/dev/sdY2 bs=128M  conv=noerror progress=status</code>