💾 Archived View for dece.space › docs › tech › boot.gmi captured on 2023-06-16 at 16:20:22. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
This document contains my notes on how bootable systems work and how to create bootable systems.
Last update: 2022-05-12.
Booting on a system can be done roughly in 2 ways, defining the structure of your partition table:
What does this mean?
The MBR is only 512 bytes of bootloader code and partition table definition. With this legacy system you can only create up to 4 primary partitions (bootable), and extended partitions to contain several more logical partitions. The GPT removes most of the limits of the MBR system, but requires the presence of an ESP partition (EFI System Partition, usually formatted in FAT32) to work properly (say 550 MiB).
Most modern systems support the UEFI specifications for boot management. Specs are available in system setup menus, and partition table formats can be see with `parted -l`.
GRUB is a bootloader commonly used by Linux installations.
On MBR systems, GRUB can be installed either on the "boot track", a small space before the first partition, or on a partition tracking its data. It's simple but quite hacky and keeps you from the benefits of GPT systems.
On GPT systems, the UEFI may be enough for bootloading. If it's a BIOS system a special partition, the BIOS boot partition, is needed. See the docs below for instructions on how to create it. Note that the Debian Installer and the likes automatically manage these partitions (along with the ESP) in guided partitioning modes.
GNU GRUB BIOS installation instructions
To create a Linux bootable USB drive from Linux, you can use the tool named dd. Be careful to identify your drive correctly before running this command:
sudo dd if=debian.iso of=/dev/sdX bs=4M conv=fsync status=progress # bs and conv options are here to make the writing process smoother.
To create a Linux bootable USB drive from Windows, depending on the target system I used either Rufus or Win32 Disk Imager.
To create CDs or DVDs the default image burner of Windows is enough; for Linux though I don't know but I guess the default burning software on Linux is fine!
Yeah even in 2022 I still sometimes need to install a Windows somewhere…
From Windows, creating a Windows bootable USB drive is easy enough, just use the official Microsoft program.
From Linux though it is a bit more challenging but here is what I did. It worked several times in the last x years!
# Figure out USB drive letter and unmount it (here, we assume its /dev/sdb). sudo fdisk -l sudo umount /dev/sdb # Format the USB drive to exFAT with fdisk. sudo fdisk /dev/sdb # Type the following keys: # p: print current partition table # d: delete them all # n: new # p: primary # then use the defaults # t: set type... # 7: ...to exFAT # a: flags # 1: set boot flag # w: write changes # Create an NTFS partition. sudo mkfs.ntfs -f /dev/sdb1 # Download ms-sys (http://ms-sys.sourceforge.net/#Download) and compile it. # Dependencies: gcc make gettext # Use ms-sys to create a Windows 7 MBR on your USB drive. sudo ms-sys -7 /dev/sdb # Mount the NTFS partition somewhere. sudo mount /dev/sdb1 /mnt/usb # Mount the Windows ISO somewhere and copy its content to the USB partition. sudo mount -o loop /home/user/windows10.iso /mnt/iso sudo cp -av /mnt/iso/* /mnt/usb # Wait for cp to be completed by monitoring I/O, e.g. with iotop. # You can also probably use the `sync` command to wait for completion. iotop sudo umount /mnt/usb sudo umount /mnt/iso