[HOWTO] frugal (hd) install without modifying Windows loader

Here you can post about non-standard installation methods
(for example when using grub4dos).
User avatar
Iapetus
White ninja
White ninja
Posts: 18
Joined: 13 Aug 2012, 16:46
Location: USA

[HOWTO] frugal (hd) install without modifying Windows loader

Post#1 by Iapetus » 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:

Code: Select all

root (hd1,2)
setup (hd1,2)
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:

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
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:

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
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:

Code: Select all

title Porteus
root (hd0,0)
kernel /portdata/boot/vmlinuz from_dir=/portdata/porteus/ vga=791
initrd /portdata/boot/initrd.xz
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:

Code: Select all

title Windows
root (hd1,0)
map (hd1,0) (hd0,0)
map (hd0,0) (hd1,0)
makeactive
chainloader +1
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.

User avatar
Sagittarius
Black ninja
Black ninja
Posts: 46
Joined: 18 Jul 2012, 18:31
Distribution: LXDE 3.0/MATE 3.1/XFCE 3.1
Location: Spain
Contact:

Re: [HOWTO] frugal (hd) install without modifying Windows lo

Post#2 by Sagittarius » 28 Sep 2012, 18:32

I too have Windows XP Pro on one machine and Windows 98 on another and am dual booting both from a Porteus folder (after extracting the iso) on my C: drive following the instructions of the Lin 'N' Win Project - great for newbies to Linux like me :) I was then able to find on the internet a menu.lst to copy and adapt with cheat codes. This sounds basically what you are doing I imagine, but I found the Lin N Win step-by-step instructions really simple and helpful for beginners. By the way, I really like Porteus!

User avatar
Iapetus
White ninja
White ninja
Posts: 18
Joined: 13 Aug 2012, 16:46
Location: USA

Re: [HOWTO] frugal (hd) install without modifying Windows lo

Post#3 by Iapetus » 28 Sep 2012, 19:18

Thanks, Sagittarius! Is this the Lin 'N Win project you mentioned?

http://www.icpug.org.uk/national/linnwi ... innwin.htm

If so, it looks like they are doing something similar, but they are still modifying the windows boot process (though not installing grub to the MBR -- they have the windows bootloader give a menu between linux and windows). That setup would probably be faster to boot (since it doesn't load to the CD first) and wouldn't involve swapping the boot CD in/out. That said, I feel the method above might still be a little "safer" in that Windows is left entirely untouched so long as the user doesn't mistakenly setup grub on the windows partition.

Would you mind posting a copy of the menu.lst you have on your systems? More examples would be good for folks to draw from :)

User avatar
Sagittarius
Black ninja
Black ninja
Posts: 46
Joined: 18 Jul 2012, 18:31
Distribution: LXDE 3.0/MATE 3.1/XFCE 3.1
Location: Spain
Contact:

Re: [HOWTO] frugal (hd) install without modifying Windows lo

Post#4 by Sagittarius » 28 Sep 2012, 19:49

Yes, your link is the one where I found the instructions.

My menu.lst on this machine (WinXP) is as follows (as you see I boot LupuLibre and Mofo Linux too). The Lin N Win project gives you a menu.lst for Puppy but I copied the other titles elsewhere.

######################################################
# GvR Sept 30th 2004
color black/cyan yellow/cyan
timeout=5
default=0

title Default Boot on HD 0
rootnoverify (hd0,0)
chainloader +1
boot

title Porteus v1.2 XFCE
kernel (hd0,0)/porteus12/boot/vmlinuz from_dev=/dev/sda1 from_dir=porteus12/porteus noswap max_loop=150 kmap=es toroot
initrd=(hd0,0)/porteus12/boot/initrd.xz
boot
title LupuLibre 528.005-2 with LibO 3.5.2
kernel (hd0,0)/lupulibre528/vmlinuz PMEDIA=idehd PDEV1=sda1 psubdir=lupulibre528 video=640x480
initrd (hd0,0)/lupulibre528/initrd.gz
boot
title Mofo Linux 1.1 (Porteus-based)
kernel (hd0,0)/mofolinux11/boot/vmlinuz from_dev=/dev/sda1 from_dir=mofolinux11/porteus noswap max_loop=150 autoexec=xconf;startx kmap=es
initrd=(hd0,0)/mofolinux11/boot/initrd.xz
boot
######################################################

User avatar
Iapetus
White ninja
White ninja
Posts: 18
Joined: 13 Aug 2012, 16:46
Location: USA

Re: [HOWTO] frugal (hd) install without modifying Windows lo

Post#5 by Iapetus » 28 Sep 2012, 20:00

great, thanks!

Based on some of the differences between my menu.lst and yours, I'm guessing one can either set the root partition in grub and then give kernel/initrd in reference to that partition or specify the device and partition in the kernel and initrd lines. Very nice :)

Post Reply