[HOWTO] frugal (hd) install without modifying Windows loader
Posted: 28 Sep 2012, 14:29
In this HOWTO, we will use grub (legacy) to boot Porteus from a hard drive, while leaving an existing Windows (XP Pro) install untouched.
My desktop system has a BIOS that makes booting from USB drives cumbersome. The only way I have found to make it work is to plug in the USB drive, power on the computer, press 'delete' to enter BIOS, change the hard drive boot priority to raise the flash drive (which is detected as a hard drive) to the top, then save and reboot. Once I remove the flash drive, BIOS forgets about it, so I have to go through this process on every boot. While I can easily boot from a CD, I would like to add modules and don't like waiting for all of the files to load from the CD while the system is booting and running. Thus, I have decided on a frugal installation (i.e. running Porteus from the compressed modules, with the files on a hard drive instead of a flash drive or CD).
I also have Windows XP Pro installed on this machine, and in the past my own mistakes in playing with Linux bootloaders have broken my Windows installations, so I want to avoid tampering with the normal course of business (I don't want to put grub on my first hard drive's MBR and use it to boot Windows). The solution I have derived is a little convoluted, but gives me the flexibility I want while leaving little room to bork Windows.
Here's an overview of how this setup works:
I set my BIOS to boot from CD first, and the first hard drive (dedicated to Windows) after that. I then insert a grub boot CD, with a menu.lst that chainloads to Windows by default (so Windows always starts if I take no action at boot time -- thus the Windows users in my household don't wind up in Linux if I accidentally leave the CD in the drive), with a second option that chainloads to my second hard drive (dedicated to Linux). I have left my Windows bootloader alone, and installed grub to the same partition on my second hard drive where my Porteus files are located. When I select Linux from the CD's bootloader menu, I get a second menu that gives me several options to boot Porteus.
If you're familiar with grub, you might be wondering why I am chainloading to an additional grub installation on my second hard drive, rather than simply booting Porteus from grub on the CD. While this is certainly possible and would avoid the need to install grub on any hard drive partitions (I'll give an example of a menu.lst entry for this method below), I chose to chainload so that I don't have to burn a new boot CD every time I make a change to my linux install that would require modifications to the menu.lst. In other words, by chainloading to a second grub install, I have a second menu.lst that is on writeable media.
Steps to implement:
First, I downloaded the Porteus ISO images (I want to have both 32 and 64 bit editions installed) and extracted the contents to my target drive (/mnt/sdb3/32/ and /mnt/sdb3/64/).
Then, following the instructions from this page: http://porteus.org/info/docs/37-install ... drive.html, I installed the grub txz package (while in Porteus booted from a CD), copied the grub files to my target Porteus partition (/mnt/sdb3/boot/grub), and installed the grub bootloader to that partition with the following commands:
Keep in mind the fact that grub starts numbering drives and partitions from 0, while the Linux kernel numbers them from "a" and "1", so grub's "hd1,2" is equivalent to "/dev/sdb3". It's useful to note that if you enter the first part of either of the above commands, for example: 'root (hd' and press the TAB key, grub will attempt to autocomplete the statement just like bash does. You can use this to see which devices are present and which partitions are on each device, to make sure you are installing grub to the appropriate partition (you don't want to install grub to your Windows partition, unless you want grub to handle booting into Windows, which is outside the scope of this document).
I then generated a menu.lst for the grub install on my Porteus partition, at /mnt/sdb3/boot/grub/menu.lst:
As you can see, I'm using the from_dev and from_dir cheatcodes to sort out two different Porteus installations on the same hard drive. I am not saving changes, but that could be done simply by adding, for example "changes=/dev/sdb3/32/32bit_changes" (sdb3 is formatted in ext4, so I can save changes directly to a folder instead of needing a save.dat).
With grub now installed and configured and the Porteus files in place, all that was left was to build the grub boot CD. For this, I followed the instructions found in the legacy grub manual, here: http://www.gnu.org/software/grub/manual ... CD_002dROM
Prior to generating the iso, I inserted the following menu.lst to the iso files:
As you can see, this has a three second delay before proceeding to chainload the first hard drive/partition (which is where Windows lives), but if I press the down button, I can select Linux, and it will chainload to the grub installation on sdb3. This opens a new grub menu and I can select between 32-bit and 64-bit linux, and I can also make modifications to my cheatcodes in the menu.lst on sdb3 without having to reburn the CD.
Some other useful menu.lst entries:
Boot Porteus files that are placed in a folder on the Windows partition (C:\portdata -- first drive, first partition), from a grub CD:
Boot Windows from a flash drive, when the flash drive gets recognized as a hard drive by BIOS. In this case, BIOS reports the flash drive as the first hard drive to grub (hd0), which causes Windows to choke because it expects to be on the first hard drive:
This makes grub remap the drives so Windows sees itself in the first position.
I've played with grub a little bit now...if others have questions or would like to see more examples, let me know and I'll see what I can add in.
My desktop system has a BIOS that makes booting from USB drives cumbersome. The only way I have found to make it work is to plug in the USB drive, power on the computer, press 'delete' to enter BIOS, change the hard drive boot priority to raise the flash drive (which is detected as a hard drive) to the top, then save and reboot. Once I remove the flash drive, BIOS forgets about it, so I have to go through this process on every boot. While I can easily boot from a CD, I would like to add modules and don't like waiting for all of the files to load from the CD while the system is booting and running. Thus, I have decided on a frugal installation (i.e. running Porteus from the compressed modules, with the files on a hard drive instead of a flash drive or CD).
I also have Windows XP Pro installed on this machine, and in the past my own mistakes in playing with Linux bootloaders have broken my Windows installations, so I want to avoid tampering with the normal course of business (I don't want to put grub on my first hard drive's MBR and use it to boot Windows). The solution I have derived is a little convoluted, but gives me the flexibility I want while leaving little room to bork Windows.
Here's an overview of how this setup works:
I set my BIOS to boot from CD first, and the first hard drive (dedicated to Windows) after that. I then insert a grub boot CD, with a menu.lst that chainloads to Windows by default (so Windows always starts if I take no action at boot time -- thus the Windows users in my household don't wind up in Linux if I accidentally leave the CD in the drive), with a second option that chainloads to my second hard drive (dedicated to Linux). I have left my Windows bootloader alone, and installed grub to the same partition on my second hard drive where my Porteus files are located. When I select Linux from the CD's bootloader menu, I get a second menu that gives me several options to boot Porteus.
If you're familiar with grub, you might be wondering why I am chainloading to an additional grub installation on my second hard drive, rather than simply booting Porteus from grub on the CD. While this is certainly possible and would avoid the need to install grub on any hard drive partitions (I'll give an example of a menu.lst entry for this method below), I chose to chainload so that I don't have to burn a new boot CD every time I make a change to my linux install that would require modifications to the menu.lst. In other words, by chainloading to a second grub install, I have a second menu.lst that is on writeable media.
Steps to implement:
First, I downloaded the Porteus ISO images (I want to have both 32 and 64 bit editions installed) and extracted the contents to my target drive (/mnt/sdb3/32/ and /mnt/sdb3/64/).
Then, following the instructions from this page: http://porteus.org/info/docs/37-install ... drive.html, I installed the grub txz package (while in Porteus booted from a CD), copied the grub files to my target Porteus partition (/mnt/sdb3/boot/grub), and installed the grub bootloader to that partition with the following commands:
Code: Select all
root (hd1,2)
setup (hd1,2)
I then generated a menu.lst for the grub install on my Porteus partition, at /mnt/sdb3/boot/grub/menu.lst:
Code: Select all
# This is a sample menu.lst file. You should make some changes to it.
# The old install method of booting via the stage-files has been removed.
# Please install GRLDR boot strap code to MBR with the bootlace.com
# utility under DOS/Win9x or Linux.
color blue/green yellow/red white/magenta white/magenta
timeout 30
default /default
title Porteus xfce 32-bit
root (hd1,2)
kernel /32/boot/vmlinuz from_dev=UUID:602fc913-daa4-4314-b3cd-2764fc973289 from_dir=/32/porteus/ vga=791 toroot xfce
initrd /32/boot/initrd.xz
title Porteus xfce 64-bit
root (hd1,2)
kernel /64/boot/vmlinuz from_dev=UUID:602fc913-daa4-4314-b3cd-2764fc973289 from_dir=/64/porteus/ vga=791 toroot xfce
initrd /64/boot/initrd.xz
title first hard drive (Windows)
rootnoverify (hd0,0)
makeactive
chainloader +1
title reboot
reboot
title halt
halt
With grub now installed and configured and the Porteus files in place, all that was left was to build the grub boot CD. For this, I followed the instructions found in the legacy grub manual, here: http://www.gnu.org/software/grub/manual ... CD_002dROM
Prior to generating the iso, I inserted the following menu.lst to the iso files:
Code: Select all
# This is a sample menu.lst file. You should make some changes to it.
# The old install method of booting via the stage-files has been removed.
# Please install GRLDR boot strap code to MBR with the bootlace.com
# utility under DOS/Win9x or Linux.
color blue/green yellow/red white/magenta white/magenta
timeout 3
default /default
title Windows
root (hd0,0)
makeactive
chainloader +1
title Linux
root (hd1,2)
makeactive
chainloader +1
title reboot
reboot
Some other useful menu.lst entries:
Boot Porteus files that are placed in a folder on the Windows partition (C:\portdata -- first drive, first partition), from a grub CD:
Code: Select all
title Porteus
root (hd0,0)
kernel /portdata/boot/vmlinuz from_dir=/portdata/porteus/ vga=791
initrd /portdata/boot/initrd.xz
Code: Select all
title Windows
root (hd1,0)
map (hd1,0) (hd0,0)
map (hd0,0) (hd1,0)
makeactive
chainloader +1
I've played with grub a little bit now...if others have questions or would like to see more examples, let me know and I'll see what I can add in.