SGDDevCamporells

From Super Grub Disk Wiki
Jump to navigationJump to search

How to build grub2

svn co http://svn.savannah.gnu.org/svn/grub/trunk/grub2

Change directory to grub2

cd grub2
sudo apt-get install ruby bison autotools-dev automake liblzo2-2 liblzo2-dev libc6-dev
sudo apt-get install build-essential
./autogen.sh
./configure && make

Install grub2 on your system

This command does not modify your MBR so you do not have to be afraid to run it.

sudo make install

Create a basic grub2 cdrom

grub-mkrescue ../../grub2_cdrom_thanks_to_grub_mkrescue.iso

Boot Linux Grub2 Manual commands

set sgd_vmlinuz_path=/vmlinuz
set sgd_initrd_path=/initrd.img
search --set=sgd_linux_kernel -f $sgd_vmlinuz_path
search --set=sgd_linux_initrd -f $sgd_initrd_path
probe -u ($sgd_linux_kernel) --set=sgd_root_uuid
set root=$sgd_linux_kernel
linux ($sgd_linux_kernel)$sgd_vmlinuz_path root=UUID=$sgd_root_uuid
initrd ($sgd_linux_initrd)$sgd_initrd_path
boot

Create an advanced grub2 cdrom

Create raiz_disco_grub2_sgd_test1 folder

mkdir raiz_disco_grub2_sgd_test1 folder

Create a boot/grub/grub.cfg file inside raiz_disco_grub2_sgd_test1folder with the following content:


# Timeout for menu
set timeout=10

# Set default boot entry as Entry 0
set default=0

# Entry 0 - Load first Kernel and Initrd (initrd support)
menuentry "First Kernel and Initrd" {
 set sgd_vmlinuz_path=/vmlinuz
 set sgd_initrd_path=/initrd.img
 search --set=sgd_linux_kernel -f $sgd_vmlinuz_path
 search --set=sgd_linux_initrd -f $sgd_initrd_path
 probe -u ($sgd_linux_kernel) --set=sgd_root_uuid
 set root=$sgd_linux_kernel
 linux ($sgd_linux_kernel)$sgd_vmlinuz_path root=UUID=$sgd_root_uuid
 initrd ($sgd_linux_initrd)$sgd_initrd_path
 boot
}

Finally you create:

grub-mkrescue --overlay=./raiz_disco_grub2_sgd_test1/ ./grub2_cdrom_thanks_to_grub_mkrescue.iso

How to modify grub-rescue-pc package

grub-rescue-pc just generates a cdrom and a floppy image. It is more or less what Super Grub2 Disk it is. So here we will learn how to modify grub-rescue-pc package from debian and upstream source code. After building the package we will set up a local repository and install it.

Debian Grub2 Source Code grab

svn export svn://svn.savannah.gnu.org/grub/trunk/grub2 grub2
cd grub2
svn export svn://svn.debian.org/svn/pkg-grub/grub2/trunk/debian
svn cat svn://svn.debian.org/pkg-grub/grub/trunk/debian/update-grub > debian/legacy/update-grub
svn export svn://svn.sv.nongnu.org/grub-extras/trunk debian/grub-extras

Debian Grub2 Super Grub Disk patch

SGD Disk patch for Grub2 can be found here at berlios download: https://developer.berlios.de/project/filelist.php?group_id=10921. (Check SG2D Source Code section)


In order to apply it you need to be at Debian source code package root folder and run:

patch -p1 < ../path/to/th /grub2_package_super_grub_disk.patch

This patch has every command that grub2 needs to be a super disk.

Debian Grub2 Build

You change directory to the Debian package source code root folder and you just run:

debuild -b

This command will create for you in ../ (upper folder) some files among binary packages, source packages, a .changes file and .dsc file (maybe it will not create this last one).

(Depending on your setup you might receive errors because of non-installed packages. Just install them as they are requested.)

Debian Grub2 Repository setup

Although you can install the grub-rescue-pc by hand thanks to

dpkg -i /path/to/package

I recommend you to setup a local repository so that you can install the packages with the Debian package system advantages.

So in order to setup a repository we are going to need the reprepro package.

apt-get install reprepro

We create a new folder.

mkdir /home/user/supergrub2_repository/

We enter it.

cd /home/user/supergrub2_repository/

We create conf folder

mkdir conf

We edit distributions file instead conf folder

gedit conf/distributions

This is the recommended distributions content (Althought I am not an expert so this might be improved):

Origin: Adrian Gibanel Lopez
Label: sid_label
Suite: unstable
Codename: sid
Architectures: i386 source
Components: main
Description: Svn updated grub2 packages and Super Grub2 Disk.

Debian Grub2 Repository import

We change directory to repository root

cd /home/user/supergrub2_repository/

We import the new package to the repository.

reprepro -Vb . include sid /home/adrian/gnu/sgd/sgd_grub2/grub2_package_updated_to_svn/nuevo/sgd_improved/grub2_1.96+20090725-1.1_i386.changes

(You have to use your own .changes file at Debian package source code root folder parent folder).

sources.list update

You should edit /etc/apt/sources.list file as root.

su
<Enter your password>
gedit /etc/apt/sources.list

Add this line to the top of the file:

deb file:/home/user/supergrub2_repository/ sid main

Save the file and exit from gedit.

Package System update

Run as root:

apt-get update

(If you have done everything ok no error should be reported).

grub-rescue-pc installation

Now you just have to run as root:

apt-get install grub-rescue-pc

Final grub-rescue-pc iso test

Now you can find the resultant files at: /usr/lib/grub-rescue/
grub-rescue-cdrom.iso
grub-rescue-floppy.img

So that you can maybe try to boot the cdrom image in qemu:

qemu -boot d -cdrom /usr/lib/grub-rescue/grub-rescue-cdrom.iso -hda /path/to/harddisk.img

References