[Solved] Install Grub4dos to PBR from Linux

You have a problem with Salix? Post here and we'll do what we can to help.
mobius
Posts: 47
Joined: 12. Nov 2016, 23:11
Location: Canada

[Solved] Install Grub4dos to PBR from Linux

Post by mobius »

Hi. New Linux user, but not afraid of command line. Have installed Salix (Xfce and Mate). Had some issues, which I was able to resolve through searches. But this question I simply haven't been able to answer, even after hours and hours of searching and testing (and strictly speaking, it is more of a Grub4dos question than a Linux/Salix one).

Using an old machine (E5200 CPU on an Asus P5QSE; 4GB RAM; 500GB HDD); I have the following partitions:

Code: Select all

sda1  64GB  FAT32  Recover
sda2  24GB  ext4   Salix Xfce
sda3  Extended
sda4  Empty partition table entry
sda5  24GB  ext4   Salix Mate
sda6  12GB  swap
LILO is installed in the MBR, and it boots both Salix partitions without issue.

What I want to do is, install Grub4dos to the sda1 partition boot record, using only Linux tools (no Windows), and then boot it from LILO. On another machine (all Windows), I've installed Grub4dos both to MBR of USB stick, and to PBR of HDD partition, using RMPrepUSB, a Windows tool, without issue. So, I'm confident it can be done.

And as I'm sure someone will ask "Why?," it is because I wish to use the Recover partition (with Grub4dos) to boot various live CD's, such as Clonezilla, GParted, etc. And, as a local repository to store Clonezilla images of the Linux partitions, before the images get copied to NAS. All of this is working in the Windows machines.

The understanding of LILO that I've been able to accumulate so far, is that running lilo against lilo.cfg, builds the map, which is stored in /boot of whichever Linux partition is currently active, and which contains the block addresses of the kernel for each of the 'image=' entries of lilo.cfg. Then the block address of the map is written to LILO in the MBR (is this close to accurate ;) ?). But what I have not been able to find anywhere, is a description of what lilo writes into the map, for each of the "other=" entries. My assumption is that it must write the block address of the PBR; therefore the PBR must contain some boot code, which in my case I would like to be Grub4dos.

I've been able to copy grldr to root of sda1. And, I've been able to add a Recover entry to lilo.cfg, run lilo, and have the entry appear in the LILO menu at boot time. But when that entry is selected, the system either:
1. Presents message about not a bootable floppy, or
2. simply halts without any further output (the screen does not change, the cursor simply remains on the line where it was left after pressing CR on the Recover entry.

The first one happens after a fresh creation of the Recover partition using GParted. The 'floppy' message is the one that I can see is stored in the default Recover PBR that GParted put there.

The second one happens after I modify the Recover PBR during testing.

After days of searching, and testing everything I've been able to find, now it's time to ask the pros :D !

EDIT: Add [Solved] to title.
Last edited by mobius on 19. Nov 2016, 00:38, edited 2 times in total.
Real men don't systemd.

Friends don't let friends systemd.
User avatar
gapan
Salix Wizard
Posts: 6361
Joined: 6. Jun 2009, 17:40

Re: Install Grub4dos to PBR from Linux

Post by gapan »

What does your boot entry for sda1 look in lilo.conf?
Image
Image
mobius
Posts: 47
Joined: 12. Nov 2016, 23:11
Location: Canada

Re: Install Grub4dos to PBR from Linux

Post by mobius »

gapan wrote:What does your boot entry for sda1 look in lilo.conf?
It is:

Code: Select all

other = /dev/sda1
  table = /dev/sda
  label = Recover
Have tried with and without the "table=" line; as per all the examples I have been able to find for booting anything other than a Linux kernel. My understanding here is that LILO will then load/run the PBR of sda1--I'm guessing that it is loading only a single sector (512 bytes), is that correct? If so, perhaps that is the problem, since I suspect that Grub4dos requires at least several several sectors to contain all the required code to search all partitions for grldr?

And I have also tried, without success:

Code: Select all

image = /grldr
  root = /dev/sda1
  label = Recover
treating it as a kernel. If it is correct that lilo compiles (to map) the block address of the Linux kernel, then at boot time LILO loads/runs that file, why can't it do the same for grldr (or, for that matter, for Windows ntldr/bootmgr)?
Real men don't systemd.

Friends don't let friends systemd.
mobius
Posts: 47
Joined: 12. Nov 2016, 23:11
Location: Canada

Re: Install Grub4dos to PBR from Linux

Post by mobius »

As at first, the question really remains: how to install Grub4dos to PBR (or MBR) on Linux? What tools to use? What procedure to follow? Thanks.
Real men don't systemd.

Friends don't let friends systemd.
User avatar
gapan
Salix Wizard
Posts: 6361
Joined: 6. Jun 2009, 17:40

Re: Install Grub4dos to PBR from Linux

Post by gapan »

I don't think you need the table line. Otherwise your lilo.conf entry looks fine. If it doesn't work, it must be something wrong with your grub4dos installation. I thought you had that already installed. I have never used grub4dos myself and have no idea how or if it can be installed from a linux system.
Image
Image
westms
Posts: 298
Joined: 17. Mar 2013, 18:51

Re: Install Grub4dos to PBR from Linux

Post by westms »

Instead of:

Code: Select all

other = /dev/sda1
  table = /dev/sda
  label = Recover
it could be:

Code: Select all

image = /boot/grub.exe
  label = Recover
Taken from SlackBuild README file.

(edit)
mobius
Posts: 47
Joined: 12. Nov 2016, 23:11
Location: Canada

Re: [Solved] Install Grub4dos to PBR from Linux

Post by mobius »

gapan, thanks for your assistance.

So, the story is that the Grub4dos package contains several files which are claimed to be executable on both Linux and Windows, but in my testing, most of them could not be executed on Linux; a couple executed but produced absolutely no results. The one that I finally got to work is 'bootlace64.com', following the instructions in post #7 of this thread, which is copied from the README_GRUB4DOS.txt file. The latest package, containing both files, can be downloaded from the developer's page.

However, the readme in the latest packages has abbreviated the section in question, and is not as clear as the section in the reboot.pro post, which is quoted from an earlier readme. That earlier readme is on the old Grub4dos project page at diddy.boot-land.net which, unfortunately, has disappeared. But, it may still be found on the Wayback Machine.

Note that in Grub, the partition number required in the parameters is base-zero, so /dev/sda1 becomes partition 0, /dev/sda2 becomes partition 1, etc. So, the commands I needed for /dev/sda1 were:

Code: Select all

dd if=/dev/sda1 of=sda1_pbr.bin bs=512 count=16
./bootlace64.com --floppy=0 sda1_pbr.bin
dd if=sda1_pbr.bin of=/dev/sda1 bs=512 count=16
after which the lilo.conf entry:

Code: Select all

other = /dev/sda1
  table = /dev/sda
  label = Recover
worked as expected, and booted Grub4dos from /dev/sda1.

Hope this is helpful to someone else.
Real men don't systemd.

Friends don't let friends systemd.
mobius
Posts: 47
Joined: 12. Nov 2016, 23:11
Location: Canada

Re: [Solved] Install Grub4dos to PBR from Linux

Post by mobius »

westms, thanks for the suggestion. That would be good, as it wouldn't require anything in the PBR. Unfortunately, I couldn't get grub.exe to execute under Linux--have no idea why.
Real men don't systemd.

Friends don't let friends systemd.
User avatar
gapan
Salix Wizard
Posts: 6361
Joined: 6. Jun 2009, 17:40

Re: [Solved] Install Grub4dos to PBR from Linux

Post by gapan »

Isn't grub.exe a DOS/Windows executable? How would it ever work on linux?
Image
Image
westms
Posts: 298
Joined: 17. Mar 2013, 18:51

Re: [Solved] Install Grub4dos to PBR from Linux

Post by westms »

gapan wrote:Isn't grub.exe a DOS/Windows executable? How would it ever work on linux?
Correct.

Command 'file' applied to grub.exe file, says:

Code: Select all

$ file grub.exe 
grub.exe: x86 boot sector
This speaks for a bootloader and for a deficient file extension.

With file -k, one get no clear statement.

Code: Select all

$ file -k grub.exe 
grub.exe: x86 boot sector\012- Linux kernel x86 boot executable bzImage, version 2.6.13.1 (mdv@localhost) #1 Tue Sep 13 18:18:41 CST 2005, RO-rootFS, Normal VGA MS-DOS executable, MZ for MS-DOS
If one look at the beginning of the file grub.exe, one can see that it starts with the ASCII text 'MZ'. This corresponds to the magic number '4D 5A' (base 16) for executable files on DOS and Windows 9x.

There is a file grub.pif in the package, which is an information file for a Windows program grub.exe. This supports the assumption that it is a file in EXE format. If it is an EXE file, the application example in the slackbuild file and also examples in the online documentation are incorrect.

EXE format files for DOS and Windows 9x are 16-bit applications, which do not run directly on 64-bit hardware, to my knowledge.

I did not realize in the description by the questioner why grub4dos is needed as bootloader on the mentioned partition. If there is an operating system installed at all, Lilo can boot it as well.
Post Reply