OpenWRT x86 Style Disks and Booting: Difference between revisions

wiki.TerraBase.info
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 4: Line 4:
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>


Copy the (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 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=/dev/sdX1 of=/dev/sdY1 bs=128M  conv=noerror progress=status</code>
Line 12: Line 12:
Flush any buffered information to disk: <code>sync</code>
Flush any buffered information to disk: <code>sync</code>


Notes;
Syntax Notes;


*if: Input File (or Device)
*if: Input File (or Device)
Line 20: Line 20:
*progress = status: Show the progress of the copy process (only for a certain version of DD and up)
*progress = status: Show the progress of the copy process (only for a certain version of DD and up)
*sync: Write all buffered blocks to disk (just to be safe)
*sync: Write all buffered blocks to disk (just to be safe)
Other Notes
*Copying the MBR and MBR Gap can be combined into a single step (it was done to clarify and make an explicit point that there is important code stored in the MBR Gap necessary to boot OpenWRT with GRUB): <code>dd if=/dev/sdX of=/dev/sdY bs=512 count=512</code>
*The "MBR Gap" for OpenWRT's x86 "flavor" is 511 Sectors (Sectors 2 - 511, 512 is the beginning of the first partition, AKA /boot Partition).  That's just how it is for OpenWRT because it is what they decided.  And just as a historical note, the "MBR Gap" is almost twice as big as the entire capacity of a Commodore 1541 disk (single sided is 170K).
*If conv=sync is used an out of space error will occur.
*If conv=sync is used an out of space error will occur.

Revision as of 19:58, 4 September 2023

For this experiment EXT 4 will be used (as opposed to SquashFS)

For Cloning a Drive

Copy the MBR (GRUB Stage 1 and Partition Table): dd if=/dev/sdX of=/dev/sdY bs=512 count=1

Copy the "MBR Gap" (GRUB Stage 1.5, containing the CORE.IMG file): dd if=/dev/sdX of=/dev/sdY bs=512 skip=1 count=511

Copy the First Partition (/boot Directory): dd if=/dev/sdX1 of=/dev/sdY1 bs=128M conv=noerror progress=status

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

Flush any buffered information to disk: sync

Syntax Notes;

  • if: Input File (or Device)
  • of: Output File (or Device)
  • bs: "How much to copy from one device to another at a time"
  • conv=noerror: "Don't stop, just do what I told you to do, and don't give an excuse"
  • progress = status: Show the progress of the copy process (only for a certain version of DD and up)
  • sync: Write all buffered blocks to disk (just to be safe)

Other Notes

  • Copying the MBR and MBR Gap can be combined into a single step (it was done to clarify and make an explicit point that there is important code stored in the MBR Gap necessary to boot OpenWRT with GRUB): dd if=/dev/sdX of=/dev/sdY bs=512 count=512
  • The "MBR Gap" for OpenWRT's x86 "flavor" is 511 Sectors (Sectors 2 - 511, 512 is the beginning of the first partition, AKA /boot Partition). That's just how it is for OpenWRT because it is what they decided. And just as a historical note, the "MBR Gap" is almost twice as big as the entire capacity of a Commodore 1541 disk (single sided is 170K).
  • If conv=sync is used an out of space error will occur.