Grub2 is the default bootloader for most current Linux distributions, but as I mentioned in my previous guide to saving NetBSD's bootloader, I feel Grub2 has a glut of features that make it unwieldy. I prefer to use a simpler bootloader and although Windows is most unyielding about booting from the MBR, it does provide a loader with an acceptable balance of simplicity and configurability. By saving Grub2 to a file, Windows' loader can be left as the primary and the other Operating Systems need only worry about their own startup configuration. Update: Despite initial success using this method on an older dual core AMD system, I have been unable to get it working on a newer system. It could be RAM or Disk size, but I'm not going to waste any more time on this aberration of unix tradition. Do one thing well, leave the OS functionality to Operating Systems! Install Linux into a partition and boot into it. If you have overwritten the primary loader afterwards, you would need to use a "rescue" system e.g. from installation media.
In a rescue system, you will need to "chroot" into your Linux installation as follows. Otherwise, jump straight to the section on creating a fake disk. Mount your linux system (assume Linux installed on sda2): "chroot" into your linux system (you must first prepare proc, sys and dev filesystems): # mount -o bind /proc /mnt/sda2/proc # mount -o bind /sys /mnt/sda2/sys # mount -o bind /dev /mnt/sda2/dev # chroot /mnt/sda2 Create a fake disk: # dd if=/dev/zero of=boot_linux bs=1k count=64 # losetup /dev/loop5 boot_linux # fdisk /dev/loop5 > Inside fdisk... > type 'o' to create empty msdos table > type 'n' to create new partition; default number (1) > enter '64' as the start sector; default end (last sector) > type 'a' to toggle active status to on, just to be safe > type 'w' to write table to our file > type 'q' to quit Explanation: We create an empty file that will simulate a tiny disk. Grub2 prefers to be installed at the start of the disk and needs more than the 512 bytes that is the default space reserved for boot code. Since current tools align partitions to be more compatible with ssds (among other reasons), the first sector will not be sector 1, it is usually 2048. This leaves a "gap" after the MBR that Grub2 appropriates for its large boot code. I found 64 sectors (32KB) to be enough for Grub2. The actual partition inside the file is unused. Install Grub2 to the fake disk. # grub2-install /dev/loop5 Detach the fake disk: # losetup -d /dev/loop5 Exit the chroot environment: # exit Save the Grub2 file e.g.: # cp /mnt/sda2/boot_linux /mnt/sdb1 As described in my previous guide you can now use the saved file to boot from the Windows bootloader.
Comments
|
Categories
All
Archives |