How to Work with GRUB4DOS

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

How to Work with GRUB4DOS

#1 Post by rcrsn51 »

It looks like the next generation of Puppies will use GRUB4DOS as the bootloader. The Puppy Universal Installer in Quirky gives you two options during a hard drive install. If your computer already has a Linux bootloader in play, the PUI supplies the appropriate GRUB entry and leaves you to update the menu.lst file.

But if you need to install a bootloader from scratch, you must also run the GRUB4DOS setup. This program provides two choices.

1. Write the GRUB4DOS boot code onto the MBR, thus erasing the original DOS/Windows code. Then write the two support files, grldr and menu.lst, to the root of the first partition. There is no option to use a different partition.

2. Don't touch the MBR, but write the two support files to the first partition, which is probably Windows. This method assumes that you want to dual-boot with Windows and leaves you to modify the WinXP boot.ini file or the Vista BCD mechanism.

For those users who want either a Puppy-only install or a co-exist install with Windows, these choices are sufficient. But many users want the flexibility of installing GRUB into a different configuration. The following article discusses three scenarios.

A - Installing GRUB4DOS on a Different Drive

1. Write the bootloader code onto the MBR with the command

Code: Select all

bootlace.com --time-out=0 /dev/sdX
where X is the target drive.

2. Copy the file /usr/lib/grub4dos/grldr to the root of the target partition. You don't need to use the traditional /boot/grub directory structure.

3. Write your menu.lst file to the same location as grldr. GRUB4DOS recognizes the same syntax as legacy GRUB. Or you can use the code generated by the PUI and saved in /tmp/NEWGRUBTEXT.

B - Installing GRUB4DOS onto a Partition Boot Sector

The safest way to dual-boot with Windows is to not touch it at all! In this scenario, you will put all the GRUB4DOS files on a different partition. By flagging that partition as bootable, you can run a multi-OS setup without making any changes to the MBR or Windows. You can manage your boot files in a Linux environment independent of Windows.

In legacy GRUB, you could install the Stage1 code onto an MBR or a partition boot sector with identical functionality. However, this is not true with GRUB4DOS, so a slighly different approach is needed.

1. Download and install the attached grubinst-1.1.pet. It contains one program, grubinst, which is saved in /usr/sbin.

2. Run Gparted. You must allocate one of your primary partitions to act as a dedicated boot partition. Make it small (100 MB) and format it as ext2. Flag this partition as bootable.

3. Copy the file /usr/lib/grub4dos/grldr into your new boot partition.

4. Put your menu.lst file in the boot partition.

As usual, you can launch Windows with the entry

Code: Select all

title Windows
rootnoverify (hd0,0)
chainloader +1
5. Open a terminal window and type

Code: Select all

grubinst -p=X /dev/sda
where X is the number of the boot partition counting from zero. This writes the GRUB4DOS boot code into the partition boot sector instead of the drive's MBR. For example, if you have Windows in the first partition, your boot files in the second partition and Puppy in the third partition, you would use

Code: Select all

grubinst -p=1 /dev/sda
6. Perform a final sanity check.
a. You have the standard DOS/Win boot code on your MBR.
b. You have flagged your boot partition as bootable.
c. You have copied grldr and menu.lst into the boot partition.
d. You have installed the GRUB4DOS boot code to its boot sector.

C - Using GRUB4DOS to Boot a Flash Drive

The standard bootloader for USB devices is syslinux. But using GRUB4DOS instead lets you work with the familiar menu.lst syntax.

1. Use the method from Part A where the device is probably /dev/sdb.

2. Make a menu.lst file like the following

Code: Select all

timeout 0
default 0
#
title Puppy 4.3.1 on USB
find --set-root --ignore-floppies /pup-431.sfs
kernel /vmlinuz pmedia=usbflash
initrd /initrd.gz
Attachments
grubinst-1.1.pet
(22.43 KiB) Downloaded 925 times

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Re: How to Work with GRUB4DOS

#2 Post by shinobar »

Thanks rcrsn51 for the article. but i don't get it why you do not use the GUI, grub4dosconfig for A and C.
rcrsn51 wrote:A - Installing GRUB4DOS on a Different Drive
C - Using GRUB4DOS to Boot a Flash Drive
Just select the drive at the top window of the Grub4DosConfig.
Tik on 'Search within only this drive' if you like for C.

If you have not the grub4dosconfig install it. Grub4DosConfig
Attachments
grub4dos_en.png
(5.91 KiB) Downloaded 4406 times

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Installing bootloader for GRUB4DOS on Partition superblock

#3 Post by shinobar »

Code: Select all

grubinst -p=X /dev/sda
I am trying this.
I got success with vfat/ntfs partitions but it seems not work for ext2/3. :cry:
Has someone got success with ext2/3 partitions?
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Re: Installing bootloader for GRUB4DOS on PBS

#4 Post by shinobar »

shinobar wrote:

Code: Select all

grubinst -p=X /dev/sda
I am trying this.
I got success with vfat/ntfs partitions but it seems not work for ext2/3. :
bootlace.com for ext2 partition worked, but it seems access always hd0.
It doesn't work if the partition is on hd1... :cry:
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

emil
Posts: 633
Joined: Tue 10 Nov 2009, 08:36
Location: Austria
Contact:

test results

#5 Post by emil »

I tested it in a n ext2 partition with bootflag set.

Code: Select all

grubinst -v -p=4 /dev/sda
Part FS: 0B (FAT32)
Part Leng: 4192965
Start sector: 0x......
Image type: FAT32
Install mode
Somhow it thinks its FAT32

It couldn't boot from that, although after boot I get blank screen with "E2", so filesystem should be ext2.

I also tried instructions on the grub4dos homepage, but somehow it is not working as it should.
emil

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Re: test results

#6 Post by shinobar »

emil wrote:I tested it in a n ext2 partition with bootflag set.

Code: Select all

grubinst -v -p=4 /dev/sda
Part FS: 0B (FAT32)
Part Leng: 4192965
Start sector: 0x......
Image type: FAT32
Install mode
Somhow it thinks its FAT32
grubinst has the command:

Code: Select all

grubinst -l /dev/sda
Maybe shows same id as:

Code: Select all

fdisk -l /dev/sda
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

grubinst on ext2 partition

#7 Post by shinobar »

I am testing USB flash with partition fresh created by gparted.

Code: Select all

# grubinst -v -p=0 /dev/sdb
Part Fs: 83 (Ext2)
Part Leng: 2104452
Start sector: 0x3F
Image type: EXT2/EXT3
Install mode
# hexdump -n 512 /dev/sdb1
shows something written.
But get 'I/O error' at boot from the PBS.
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#8 Post by rcrsn51 »

The only way I could get GRUB4DOS to work like this was to use a SMALL ext2 partition as a separate boot partition.

It's because of this problem that legacy GRUB continues to be useful.

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

PBS of vfat

#9 Post by shinobar »

rcrsn51 wrote:The only way I could get GRUB4DOS to work like this was to use a SMALL ext2 partition as a separate boot partition.
PBS way should work if the second partition is vfat(or ntfs).
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

bootlace.com for ext2 PBS

#10 Post by shinobar »

bootlace.com can write the bootloader on ext2 parrtition boot sectors:

Code: Select all

bootlace.com --floppy=0 --sectors-per-track=63 --heads=255 --start-sector=63 --total-sectors=1052226 /dev/sdb1
Each numbers can get from 'fdisk' command:

Code: Select all

# fdisk -ul /dev/sdb

Disk /dev/sdb: 4043 MB, 4043309056 bytes
255 heads, 63 sectors/track, 491 cylinders, total 7897088 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63     2104514     1052226   83  Linux
It works if the partition is on (hd0), the boot disk.
But it needs swaping map if the partition is on another disk than the boot disk.
EDIT: It seems reasonable. Because basically, the boot disk is selected by BIOS, partition selected by MBR and the PBS sees only the partition...

It also works with ext3, but does not for ext4.
Last edited by shinobar on Fri 24 Dec 2010, 11:42, edited 3 times in total.
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

emil
Posts: 633
Joined: Tue 10 Nov 2009, 08:36
Location: Austria
Contact:

something peculiar - difference in drive numbering

#11 Post by emil »

I have to report something that puzzled me and I needed some time to figure that out. Until now I always had used the labels of the drive icons in my puppy install in anything releated with grub without problem.

Probably this is a well known fact and ignorant as I am I just missed it until now, but maybe if somebody reads this it can spare some time.

Today I noticed that I had used the wrong drive when I did shinobars

Code: Select all

grubinst -l /dev/sda
command.
I got the following partition-list
# id base leng
0 07 3F EA60903 (120001M)
1 83 1BDBE226 140249A (10245M)
2 83 EE60407 CF5DE1F (106172M)
3 0B EA60942 3FFAC5 (2047M)

Ok here I noticed that something is wrong, because on my desktop the last partition is the 10 GB ext 2 partition, where as the 2nd partition is the 2 GB FAT partition.

I checked it in GParted and voila:
Image
/dev/sdaX numbering and Icon numbering do NOT match!
I then repeated to install the grubloader to the partition with

Code: Select all

grubinst -p=1 /dev/sda
and some other variations, but still it was not possible to boot from the Linux partition. The grub4dos failure of handling linux partitions is surly a bug, I wonder if the devs are aware of the problem?

I also noticed that still there is the script
grub-install, as well as grub in the directory /usr/sbin. I suppose this is "legacy" grub and this is used by universal installer etc...

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Re: something peculiar - difference in drive numbering

#12 Post by shinobar »

emil wrote:/dev/sdaX numbering and Icon numbering do NOT match!
Interesting. I see such a case sometimes.
You can check the order also by 'fdisk' command.

Code: Select all

fdisk -l /dev/sda
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

User avatar
NeverThere
Posts: 18
Joined: Wed 24 Nov 2010, 12:48

#13 Post by NeverThere »

Assuming that it wasn't already posted somewhere, here is a very well put together tutorial for Grub4Dos.

Grub4dos Guide

-

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#14 Post by Burn_IT »

I make things easy for myself.
All the machines I use at home have a boot selection from the BIOS and all happen to have a version of Windows (but that actually doesn't matter because Hiren's boot CD will boot into XP/DOS/WIN98/Linux in ram)
I use the supplied with 0.4.4 grubinst_gui.exe from Windows and it gives a nice easy window with all needed options in it- disk and partitions are drop down box lists.
I have used it to install to several disks in a partition mbr and to many USB sticks and disks (both partitioned and superfloppy).
I haven't tried EXTn partitions as all my Puppies are frugal and co-exist with portable apps and data which need to be used by Windows and Wine.
Some of my older PC don't natively support booting from USB and that can be got round by using the PLoP boot manager instead (an option available on Hiren's CD) which WILL reboot??/simulate boot from USB.
PLoP is even more powerful than Grub4DOS and has its own install, but is quite complicated so I tend to only use it from Hiren's to get a boot from USB when not natively available.
"Just think of it as leaving early to avoid the rush" - T Pratchett

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Grub4DosConfig PBS install support

#15 Post by shinobar »

Now the grub4dos-0.4.4.v1.6.9.1 (Update: 21 Jan 2011) supports partition boot sector install.
http://www.murga-linux.com/puppy/viewtopic.php?t=51697

Note: PBS of reiserfs is not supported. PBS of ext4 support requires extlinux and chan.c32 of version 4.0 and later.
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#16 Post by amigo »

grub will not always see the drives in the same order as the BIOS -particularly if the BIOS has the option to change the boot-order. fdisk will almost never see the drives in the right order -blkid may do better... There is also the 'fbinst' utility for installing grub/grub4dos which may provide useful (but also sometimes misleading) info. Also, the grub *CLI program* will not alway see the drives in the same order as the stage1 (or grldr) sees them. Quite commonly, the grub program will see drives which the stage1 cannot see -since the program has access to the linux kernels' view of the hard-drives and the kernel is able to see things which the BIOS does *not*.

In short, there seems to be *no* way of accurately determining the BIOS boot-order.

I recently ran across a utility developed for ubuntu called boot_info_script which does a pretty complete analysis of all MBR'S found and even points out the location of the menu.lst and stage2 of any stage1 found. I've been hacking on it -or better said, incorporating some of the tricks into a similar script I've been working on for a long while.

Post Reply