alternative grub 1 setup for PBR

Here you can post about non-standard installation methods
(for example when using grub4dos).
Post Reply
aus9

alternative grub 1 setup for PBR

Post#1 by aus9 » 20 Oct 2015, 14:30

Hi

This is an alternative to viewtopic.php?f=62&t=3994
Try at own risk. This tutorial uses a live cd to install grub legacy into the Partition Boot Record (PBR) of your hard drive or USB stick. It is not a tutorial on copying over all the files, as I expect you to know which files from a Porteus to copy over, with the exception of the boot stuff showing here.

The intent is to show just how easy it is to setup a PBR environment and I have set it up, without actually copying the Porteus directory as proof of concept so its not a full blown tutorial.

Materials used
1) Live cd that has grub legacy on it, I chose SystemRescueCd v 4.3.0 as I had already downloaded and burnt to cdrw.
You choose any others if you prefer. This one automatically boots in root mode so when you open a terminal no need to run
sudo su or su etc.

2) The grub package as mentioned here, converted to xzm and activated
viewtopic.php?f=62&t=946#p37857

Steps to follow if interested.

1) Ignore the cd for moment. Choose a partition that you want to try out Porteus on, I chose sda3, third partition on internal hard drive
2) On XFCE v3.1 64 bit, I as local user have write powers to create folders on all partitions. But I have another distro on partition 1 and it has grub2 in MBR and I will create a grub2 chainloader command to PBR for partition 3. Your choices may vary.
b) so using a gui file manager I created this folder= grub
and copied from the loaded grub xzm package the following files assuming you have ext2/3/4 format for target partition
e2fs_stage1_5
stage1
stage2
where to find them?
/usr/lib/grub/i386-pc/

3) Next we create a nonsense menu.lst and save it the the same folder called grub
Meaning it must exist but the contents may not match reality.
default 0
timeout 5
color light-blue/black light-cyan/blue

title labelp3
root (hd0,2)
kernel /grub/vmlinuz root=LABEL=p3 changes=/grub/porteus volume=100%
initrd /grub/initrd.xz

title dev3
root (hd0,2)
kernel /grub/vmlinuz root=/dev/sda3 changes=/porteus volume=100%
initrd /grub/initrd.xz
I prefer the LABEL style but more on that later.

4) Now to show why menu.lst is nonsense. We now reboot into live cd, without copying over any kernel, initrd or Porteus folder.
grub legacy does not care!

5) Open a terminal and ensure you are root.

Other tutorials on grub legacy will inform you that grub counts from zero so now we use the info that my target is /dev/sda3 and translate it into grub speak which is (hd0,2)

Now we embed grub legacy into PBR

Code: Select all

grub

root (hd0,2)
setup (hd0,2)
quit
TIP
grub can also do auto-completion search so root (hd ----NOW PRESS THE TAB KEY and grub will reveal how many hard drives it detects.

You will see some fail messages as I did not use a boot folder but a grub folder. (I like to have only one boot folder on my hd and its on sda1)
You will see some success messages as it will find the stage files and will embed into PBR

6) Now reboot into Porteus to check PBR has worked. Actually I do this while on live cd but we need to think how a Porteus user might do it.

Code: Select all

root@porteus:/# dd if=/dev/sda3 bs=512 count=1 | strings
1+0 records in
1+0 records out
512 bytes (512 B) copied, 9.2276e-05 s, 5.5 MB/s
ZRrI
D|f1
GRUB 
Geom
Hard Disk
Read
 Error
Do not be alarmed by seeing Error in the output above. All we have done is to say treat the PBR like a MBR and show us the contents of it without all those funny characters by using the pipe thru strings command. The clue is GRUB is showing in PBR.

7) You can now choose what flavour Porteus to try out next, copy the kernel and initrd into that grub folder, you may need to shorten the names....YMMV
and copy your Porteus folder over as well.

Yes this is a menu for an unpacked ISO not a menu to boot from an ISO


8] Assuming you want to chainload from a grub2 in MBR to this grub legacy in PBR
Reboot into the distro flavour that controls links to your MBR, for me, its the distro on /dev/sda1
Go to the 40_cusom file and create an entry that reads, with root powers
menuentry "PBR on 3" {
set root='hd0,3'
chainloader +1
}
Note that grub2 counts hd from zero but partitions count start from one....confusing no?

Now as root run

Code: Select all

update-grub
8B] However, you may have grub 1 in MBR controlled by another distro flavour say on sda1 in which case, reboot into it and manually edit the menu.lst on that parrtiion so it has new entry that reads
title PBR3
root (hd0,2)
chainloader +1
9) Later on, you can go back to that nonsense menu and change it to reflect the actual files pathways but don't change the pathway to kernel or initrd please.

good luck
Last edited by aus9 on 23 Oct 2015, 11:02, edited 6 times in total.

Bogomips
Full of knowledge
Full of knowledge
Posts: 2548
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: alternative grub 1 setup for PBR

Post#2 by Bogomips » 20 Oct 2015, 19:49

@aus9

Thanks. Interesting tutorial. :beer:
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

aus9

Re: alternative grub 1 setup for PBR

Post#3 by aus9 » 20 Oct 2015, 23:08

Cheers.

I have editted above tut.

Altho not a part of the tut, it may be worth while mentioning the weaknesses of grub 1.

1) No longer maintained
2) Does not support 64 bit systems as a native install AFAIK, I could be wrong.
3) Does not support EFI also known as UEFI bios firmware computers
----If user has no windows its safe to turn this off.
4) Does not have script support to detect other Operating Systems or Multi boot systems. Meaning you have manually edit the menu file to add new systems.

good luck

aus9

Re: alternative grub 1 setup for PBR

Post#4 by aus9 » 21 Oct 2015, 05:21

forgot to mention how to seup up LABEL, one way which can be done with a mounted partition is e2label as discussed here
viewtopic.php?f=62&t=946#p37812

########################################################
Ok so now we will attempt something for which I have zero experience with as I am new to Porteus. Secondly I am on Aussie speed internet and bandwith is capped so ....forgive me if it sounds rude....but I have no immediate plans to be a tester of this flavour.

We are going to edit that menu.lst so we can reboot into nemesis
Add a new menu please ....do NOT re-embed grub into PBR, it is not necessary OK.
title nemesis
root (hd0,2)
kernel /grub/vmlinuz root=LABEL=p3 changes=/nemesis volume=100%
initrd /grub/initrd.xz
Now you need to download that distro and I chose the non-git version
http://brokenman.porteus.org/nemesis/te ... x86_64.iso

Unpack it and grab some files, I do it at /tmp so I copied iso to /tmp and then as root did this

Code: Select all

cd /tmp
mkdir iso
mount -o loop nemesis*iso iso
The entire folder under iso called /nemesis is copied to the root of my partition3
ditto folder of config to the root of my partition3
Next I need to copy the kernel and initrd from
boot/syslinux/ and copy them to folder grub

So it looks like this......change your partition to suit

Code: Select all

cd /mnt/sda3
ls nemesis  # its a folder
base  changes  make_iso.sh  modules  nemesis-v3.1-x86_64.sgn  optional
ls grub # its a folder
e2fs_stage1_5  initrd.xz  menu.lst  stage1  stage2  vmlinuz
ls config # its a folder
modules  network  services
reboot and choose the chainloader menu in grub2
takes me to grub legacy menu which boots in 5 seconds to nemesis

good luck

Post Reply