GRUB Legacy: Difference between revisions

2,634 bytes removed ,  21 days ago
m
no edit summary
[unchecked revision][unchecked revision]
mNo edit summary
 
(36 intermediate revisions by 17 users not shown)
Line 1:
{{You}}
GRUB stands for GRand Unified Bootloader and is a [[bootloader]] and the reference implementation of the [[Multiboot|Multiboot Specification]]. GRUB can boot any Multiboot-compliant OS (e.g. Hurd, [http://grub.enbug.org/MultibootSystems among others]), however it can also boot some non-Multiboot-compliant OSes, e.g. Windows, via a chain-loading function, and some others via special support, e.g. Linux. mbchk can be used to determine if a file is Multiboot-compliant.
 
This article concentrates on GRUB Legacy. Information regarding modern [[GRUB 2]], a full rewrite, can be found in a separate article.
 
==Features==
Line 32 ⟶ 33:
Remove the boot disk from the floppy drive and insert the auxiliary disk. The files <code>stage1</code> and <code>stage2</code> from the GRUB distribution must be written to this disk, to sector 0 and sector 1+ respectively. In your shell (for Windows users, this means the [[Cygwin]] shell), type:
 
<sourcesyntaxhighlight lang="bash">
dd if=<stage1> of=/dev/fd0 bs=512 count=1
dd if=<stage2> of=/dev/fd0 bs=512 seek=1
</syntaxhighlight>
</source>
 
Now GRUB will be able to boot stage1 and stage2 from this disk. We cannot use it as our boot disk, though, since writing stage2 to sector 1 destroyed the floppy's format structure (you can't write files to the disk anymore, and any previously written <code>boot</code> directory could no longer be found). That's why we will now set up the other disk to boot GRUB and have a valid structure.
Line 44 ⟶ 45:
GRUB will boot into its command shell. (If your system does boot from hard drive instead, check your BIOS boot drive settings.) When the <code>grub ></code> prompt appears, remove the auxiliary disk from the drive and replace the boot disk. From the GRUB shell, you can now complete the installation on the boot disk:
 
<sourcesyntaxhighlight lang="bash">
install (fd0)/boot/stage1 (fd0) (fd0)/boot/stage2 (fd0)/boot/menu.cfg
</syntaxhighlight>
</source>
 
The parameters tell GRUB:
Line 73 ⟶ 74:
 
===Installing to USB===
'''NOTE''': I have tried many tools to install GRUB onto a USB device under windows, however, I have not been able to figure out how. So, to install, either use a Linux distro on your PC of use a Linux Live CD.
 
Putting GRUB onto a USB device is as easy as following the above example of installing to a standard hard disk. There is one extra step involved, finding out under which mount point youyour USB device is located. You may even have to mount it yourself if it is not already mounted. To install use the following steps:
 
If you need to mount your USB device: (Exchange <code>sdb1</code> with your device name.)
 
<sourcesyntaxhighlight lang="bash">
mkdir /mnt/sdb1
mount /dev/sdb1 /mnt/sdb1
</syntaxhighlight>
</source>
 
Create required directories:
 
<sourcesyntaxhighlight lang="bash">
mkdir /mnt/sdb1/boot
mkdir /mnt/sdb1/boot/grub
</syntaxhighlight>
</source>
 
Locate the <code>stage1</code>, <code>stage2</code>, and <code>*_stage1_5</code> files:
 
<sourcesyntaxhighlight lang="bash">
find / -name stage1
</syntaxhighlight>
</source>
 
Copy stage1 and stage2 files, <code>/usr/lib/grub/</code> is an example location, use the location returned by the find command:
 
<sourcesyntaxhighlight lang="bash">
cp /usr/lib/grub/stage1 /mnt/sdb1/boot/grub/stage1
cp /usr/lib/grub/stage2 /mnt/sdb1/boot/grub/stage2
</syntaxhighlight>
</source>
 
For FAT formatted USB device use:
 
<sourcesyntaxhighlight lang="bash">
cp /usr/lib/grub/fat_stage_1_5fat_stage1_5 /mnt/sdb1/boot/grub/fat_stage_1_5fat_stage1_5
</syntaxhighlight>
</source>
 
For ext2 formatted USB device use:
 
<sourcesyntaxhighlight lang="bash">
cp /usr/lib/grub/e2fs_stage_1_5 /mnt/sdb1/boot/grub/e2fs_stage_1_5
</syntaxhighlight>
</source>
 
Then execute the GRUB install application:
 
<sourcesyntaxhighlight lang="bash">
sudo grub
</syntaxhighlight>
</source>
 
Enter the following commands:
 
<sourcesyntaxhighlight lang="bash">
root (sdb1hd1,1)
setup (sdb1hd1)
quit
</syntaxhighlight>
</source>
if you don't know where your kernel is, you can use the command "find /boot/grub/e2fs_stage_1_5" to get the parameters which would be used in the command root (sdb1,1) and setup (sdb1).
 
===Installing to hard disk===
Line 137 ⟶ 139:
 
==Load your kernel over network (TFTP)==
{{FirstPerson|section=1}}
You can also use GRUB's builtin network support to increase your build/test turn around time. You can boot another machine with a kernel directly from your build directory without having to copy it over manually. See also, [http://www.gnu.org/software/grub/manual/html_node/General-usage-of-network-support.html#General-usage-of-network-support How to set up your network] in the official GRUB manual.
 
Line 144 ⟶ 147:
Run
 
<sourcesyntaxhighlight lang="bash">
./configure --help
</syntaxhighlight>
</source>
 
to see a list of options. In my case, I use Netgear tulip cards, so I execute:
 
<sourcesyntaxhighlight lang="bash">
./configure --enable-tulip
make
make install
</syntaxhighlight>
</source>
 
You may want to consider using the <code>--prefix</code> option if you don't want to overwrite your existing GRUB install or do not have root access.
Line 194 ⟶ 197:
===Wiki Pages===
*[[Grub Error 13]]
*[[Multiboot]]
 
===Tutorials===
Line 201 ⟶ 205:
*[[Topic:9548|Switching back to real mode from GRUB]]
*[[Topic:9586|Setting boot-time graphic video mode with GRUB]]
*[[Topic:1744118255|GRUB VBE Patch]]
 
===External Links===
*[http://grub.enbug.org/ GRUB wiki]
*[http://tldp.org/HOWTO/Linux+Win9x+Grub-HOWTO/index.html Linux+Win9x+Grub HOWTO]
*[http://promote-opensource.org/modules/mylinks/singlelink.php?cid=14&lid=94 Linux Recovery and Boot Disk Creation with Grub]
*[http://www.skyjammer.com/files/knoppix/ Win32 GRUB]
*[http://www.ameritech.net/users/gholmer/booting.html Booting with GRUB]
*[http://grub4dos.sourceforge.net/ WinGRUB]
*[http://www.geocities.com/lode_leroy/grubinstall/ Grub installer for Windows]
*[http://grub.linuxeden.com/ GRUB for DOS]
*[http://www.pixelbeat.org/docs/disk/ GRUB PC Disk details]
*[http://www.gnu.org/software/grub/manual/legacy/grub.html GRUB Legacy manual]
 
*[httphttps://grubgna.linuxeden.comorg/projects/grub4dos/ GRUB for DOS]
==Grub for EFI==
 
This section will tell you how to compile, build and install Grub2 on an EFI system. This have been tested on an MacBook Pro6,1
 
===Compile===
 
First you need a x86_64 linux with gcc and binutils. I downloaded a Ubuntu 10.4 LiveCD, booted it in VirtualBox and installed it to disk.
 
You need to make sure gcc, bison, flex etc are installed. Do this with the apt package manager. apt-get install gcc bison flex is what i did.
 
You need the grub2 source code. I got that from ftp://alpha.gnu.org/gnu/grub/
 
Download grub-1.9-rc2.tar.gz and unpack it.
 
Next thing to do is "./configure --with-platform=efi --target=x86_64"
 
then "make"
 
Now you should have compiled grub2 efi if everything went ok.
 
===Build Grub.efi===
 
grub.efi is a bundle of tools including grub itself. You need to make the efi image by selecting what modules you want.
 
For Grub to be able to read disk partitions you need a module for that. Either you want plain-old bootsector and msdos style partition map or you want GPT (new fancy one) you need to select correct module when bundling grub.efi.
 
For your grub to be functional you should include as many filesystems as possible and also linux,multiboot,multiboot2 etc so that you can read any type of kernel from any type of filesystem.
 
So.. Lets build grub.efi
 
Go to "grub-core" folder.
 
Execute: ./grub-mkimage -d . -o grub.efi -p /efi/grub minicmd part_gpt part_msdos part_apple fat ext2 hfsplus hfs ntfs reiserfs xfs iso9660 udf ls search loopback linux multiboot multiboot2 chain reboot halt appleldr help configfile hexdump loadbios memrw fixvideo crc sh video gfxterm font png
 
where "-p /efi/grub" tells where grub is located. Grub.cfg will be loaded from this path on booting device.
 
That will build "grub.efi" in the subfolder and this can now be copied to a USB-disk, harddisk etc.
 
===Installing===
 
I partitioned my usbdisk with MacOSX diskutil, but any partition tool should/would do. I created a small 100mb partition as first partition and created a huge secondary partition for files. I formated the partition to HFS+, but i guess FAT should be more compatible since i dont think other EFI firmwares have HFS+ filesystem support like the Mac..
 
Anyway i created "/efi/grub/" folder and copied grub.efi to /efi/grub/grub.efi on my disk. I then created a grub.cfg file alongside with it.
 
To make OSX find the Grub.efi image on boot i did;
 
"sudo bless --verbose --folder=/Volumes/EFI --file=/Volumes/EFI/efi/grub/grub.efi --setBoot"
 
where /Volumes/EFI is the first partition on my usb disk..
 
Now i saved my work and rebooted.. Press/hold "option" key during boot will bring up boot menu. I now get an option to boot en EFI DISK. I select this and now Grub2 shows like any other Grub..
 
Configuration of grub and config file is like any other grub2 syntax.
 
[[Category:Bootloaders]]
[[Category:GRUB]]
[[de:Grand Unified Bootloader]]