####### # # E-scripts on Grub. # # Note 1: use the eev command (defined in eev.el) and the # ee alias (in my .zshrc) to execute parts of this file. # Executing this file as a whole makes no sense. # # Note 2: be VERY careful and make sure you understand what # you're doing. # # Note 3: If you use a shell other than zsh things like |& # and the for loops may not work. # # Note 4: I always run as root. # # Note 5: some parts are too old and don't work anymore. Some # never worked. # # Note 6: the definitions for the find-xxxfile commands are on my # .emacs. # # Note 7: if you see a strange command check my .zshrc -- it may # be defined there as a function or an alias. # # Note 8: the sections without dates are always older than the # sections with dates. # # This file is at # or at . # See also , # , # , # , # and . # ####### # «.grub-adjust» (to "grub-adjust") # «.menu.lst» (to "menu.lst") # «.grub-floppy» (to "grub-floppy") # «.grub-floppy-old» (to "grub-floppy-old") # «.grub» (to "grub") # «.grub-src» (to "grub-src") # «.netbsd» (to "netbsd") # «.floppy_images» (to "floppy_images") # «.invaders» (to "invaders") # «.update-grub» (to "update-grub") # «.chainloader» (to "chainloader") # «.device.map» (to "device.map") # «.partition.map» (to "partition.map") # «.grub-install» (to "grub-install") # «.grub:find» (to "grub:find") # «.grub:setup» (to "grub:setup") # «.grub-1.95» (to "grub-1.95") # «.grub2» (to "grub2") # «.grub2-on-test.img» (to "grub2-on-test.img") # «.grub-on-hd-image» (to "grub-on-hd-image") # «.grub2-on-iso» (to "grub2-on-iso") # «.grub2-on-a-floppy» (to "grub2-on-a-floppy") # «.grub2-menu-interface» (to "grub2-menu-interface") # «.supergrubdisk» (to "supergrubdisk") ##### # # grub shell demo # 2000dec10 # ##### # tr T \\t > $EEG <<'---' help cat (hdT0,T0)/Tboot/Tgrub/ cat (hd0,0)/boot/grub/menu.lst root (hd1,T0) 0xFF root (hd1,0,a) 0xFF kernel (hd0,0)/boot/grub/kernel # boot chainloader (hd1,T0) quit --- eeg grub # # (find-grubnode "Command-line-specific commands") # (find-grubnode "Command-line-specific commands" "Command: chainloader") # (find-grubnode "Command-line-specific commands" "Command: setup") # (find-grubnode "Command-line-specific commands" "Command: install") # (find-grubnode "Invoking grub-install") # (find-grubnode "Bootstrap tricks") ##### # # Just recopy the new kernels and adjust menu.lst # 2000jul20 # ##### # «grub-adjust» (to ".grub-adjust") # (find-es "dpkg" "all-installed-.debs") # (find-fline "~/oinstalleddebs" "kernel-image") # (find-status "kernel-image-2.2.15") # (find-vldifile "kernel-image-2.2.15.list") # (find-fline "/usr/doc/kernel-image-2.2.15/") # (find-status "kernel-image-2.2.16-edrx") # (find-vldifile "kernel-image-2.2.16-edrx.list") # (find-fline "/usr/doc/kernel-image-2.2.16-edrx/") # (find-fline "/boot/") # mount -o remount,rw /hda1 # mkdir -p /hda1/boot/grub/ cp -iv /boot/vmlinuz-2.2.16-edrx /hda1/boot/grub/ cp -iv /boot/vmlinuz-2.2.17-edrx /hda1/boot/grub/ cp -iv /boot/vmlinuz-2.2.18-edrx /hda1/boot/grub/ cp -iv /boot/vmlinuz-2.2.19-edrx /hda1/boot/grub/ cp -iv /gnu/boot/gnumach.gz /hda1/boot/grub/ cp -iv /gnu/boot/serverboot.gz /hda1/boot/grub/ cp -iv /gnu/boot/servers.boot /hda1/boot/grub/ cp -iv /freebsd/boot/{loader*,support.4th} /hda1/boot/grub/ cp -iv /freebsd/kernel /hda1/boot/grub/ # # «menu.lst» (to ".menu.lst") mount -o remount,rw /hda1 cat > /hda1/boot/grub/menu.lst <<'---' timeout 5 title Linux root=/dev/hdd8 kernel=(hd0,0)/boot/grub/vmlinuz-2.2.19-edrx kernel (hd0,0)/boot/grub/vmlinuz-2.2.19-edrx root=/dev/hdd8 ro vga=1 title Linux root=/dev/hdd8 kernel=(hd0,0)/boot/grub/vmlinuz-2.2.18-edrx kernel (hd0,0)/boot/grub/vmlinuz-2.2.18-edrx root=/dev/hdd8 ro vga=1 title Linux root=/dev/hdd8 kernel=(hd0,0)/boot/grub/vmlinuz-2.2.17-edrx kernel (hd0,0)/boot/grub/vmlinuz-2.2.17-edrx root=/dev/hdd8 ro vga=1 title Linux root=/dev/hdd8 kernel=(hd0,0)/boot/grub/vmlinuz-2.2.16-edrx kernel (hd0,0)/boot/grub/vmlinuz-2.2.16-edrx root=/dev/hdd8 ro vga=1 title Linux root=/dev/hdd8 kernel=(hd0,0)/boot/grub/vmlinuz kernel (hd0,0)/boot/grub/vmlinuz root=/dev/hdd8 ro vga=1 title Linux root=/dev/hdd8 kernel=(hd0,0)/boot/grub/vmlinuz-2.4xx kernel (hd0,0)/boot/grub/vmlinuz-2.4xx root=/dev/hdd8 ro vga=1 title GNU/Hurd kernel (hd0,0)/boot/hurd-new/gnumach.gz root=device:hd0s2 module (hd0,0)/boot/hurd-new/ext2fs.static --multiboot-command-line=${kernel-command-line} --host-priv-port=${host-port} --device-master-port=${device-port} --exec-server-task=${exec-task} -T typed ${root} $(task-create) $(task-resume) module (hd0,0)/boot/hurd-new/ld.so.1 /hurd/exec $(exec-task=task-create) title GNU/Hurd (using gnumach-edrx) kernel (hd0,0)/boot/hurd-new/gnumach-edrx.gz root=device:hd0s2 module (hd0,0)/boot/hurd-new/ext2fs.static --multiboot-command-line=${kernel-command-line} --host-priv-port=${host-port} --device-master-port=${device-port} --exec-server-task=${exec-task} -T typed ${root} $(task-create) $(task-resume) module (hd0,0)/boot/hurd-new/ld.so.1 /hurd/exec $(exec-task=task-create) title GNU/Hurd (old, using serverboot) kernel (hd0,0)/boot/grub/gnumach.gz root=hd0s2 module (hd0,0)/boot/grub/serverboot.gz title NetBSD ELF (use "wd2a", "wd2b", generic) kernel --type=netbsd (hd0,0)/boot/grub/netbsd title The NetBSD "boot" file (not working) kernel (hd0,0)/boot/grub/netbsd_boot title RH 6.1 root=/dev/hdd5 kernel=(hd0,0)/boot/grub/vmlinuz-2.2.12-20 kernel (hd0,0)/boot/grub/vmlinuz-2.2.12-20 root=/dev/hdd5 ro vga=1 title FreeBSD (hd1,0,a) 0xFF root (hd1,0,a) 0xFF kernel (hd0,0)/boot/grub/kernel title FreeBSD (hd2,2,a) 0xFF root (hd2,2,a) 0xFF kernel (hd0,0)/boot/grub/kernel title FreeBSD.angg (hd2,2,a) 0xFF root (hd2,2,a) 0xFF kernel (hd0,0)/boot/grub/kernel.ANGG title FreeBSD loader (use "show", "set currdev=disk2s1a", and "boot") root (hd1,0,a) 0xFF kernel (hd0,0)/boot/grub/loader title FreeBSD loader (hd2,2,a) root (hd2,2,a) 0xFF kernel (hd0,0)/boot/grub/loader title Invaders kernel (hd0,0)/boot/grub/invaders --- # ##### # # grub floppy # 2004dec14 # ##### # «grub-floppy» (to ".grub-floppy") # # (find-grubnode "Creating a GRUB boot floppy") # (find-fline "/lib/grub/i386-pc/") dd if=/dev/zero of=/tmp/floppy.img bs=1024 count=1440 cd /lib/grub/i386-pc/ dd if=stage1 of=/tmp/floppy.img bs=512 count=1 dd if=stage2 of=/tmp/floppy.img bs=512 seek=1 # # (find-man "1 qemu") cd /tmp/linux-test/ qemu -m 64 -dummy-net \ -fda /tmp/floppy.img -boot a # -kernel bzImage-2.4.21 \ -append "root=/dev/hda" linux.img ##### # # grub floppy # 2000aug12 # ##### # «grub-floppy-old» (to ".grub-floppy-old") # superformat -V /dev/fd0 hd # cd /hda1/boot/grub/ # dd if=stage1 of=/dev/fd0 bs=512 count=1 mcopy stage2 a: laf # # (find-grubnode "Installation") # (find-grubnode "") # (find-grubnode "Automated install" "install (fd0)+1") # (find-grubnode "Commands" "install STAGE1-FILE") # (find-grubnode "Commands" "install STAGE1-FILE" "`d'") # (find-grubnode "Commands" "install STAGE1-FILE" "`p'") # (find-grubnode "Filename syntax") # (find-grubnode "Installing GRUB on a floppy") cd /hda1/boot/grub/ mcopy stage1 a: mcopy stage2 a: grub --batch <<'---' root (fd0) install (fd0)/stage1 (fd0) (fd0)/stage2 p quit --- # install (fd0)+1 (hd0) (hd0,1)/boot/grub/stage2 p # (find-man "8 mke2fs" "Force") # From a mail by Okuji in the bug-grub list, circa 2000oct17: # rm -Rv /tmp/grubflo/ mkdir /tmp/grubflo/ cd /tmp/grubflo/ dd if=/dev/zero of=floppy bs=512 count=2880 mke2fs -F floppy mount -o loop floppy /mnt mkdir -p /mnt/boot/grub/ cp -a /hda1/boot/grub/{*stage*,gnumach.gz,server*} /mnt/boot/grub/ # (to "menu.lst") cat > /mnt/boot/grub/menu.lst <<'---' timeout 5 title GNU/Hurd kernel (fd0)/boot/grub/gnumach.gz root=hd0s2 module (fd0)/boot/grub/serverboot.gz --- ls -lAF /mnt/boot df | grep -v /dev/hd umount /mnt echo "(fd0) /tmp/grubflo/floppy" > /tmp/map grub --device-map=/tmp/map --config-file='(fd0)/boot/grub/menu.lst' # ##### # # grub # 2000jun17 # ##### # «grub» (to ".grub") # (find-status "grub") # (find-vldifile "grub.list") # (find-fline "/usr/share/doc/grub/") # (find-fline "/usr/share/doc/grub/README.debian" "copy the binary files") # (find-fline "/usr/share/grub/i386-pc/") # mount -o remount,rw /hda1 rm -R /hda1/boot/grub/ mkdir /hda1/boot/grub/ cp -iv /usr/share/grub/i386-pc/* /hda1/boot/grub/ cp -iv /vmlinuz /hda1/boot/grub/ cp -iv /hdc5/boot/gnumach.gz /hda1/boot/grub/ cp -iv /hdc5/boot/serverboot.gz /hda1/boot/grub/ insmod ufs mount /hdd9 cp -iv /hdd9/kernel /hda1/boot/grub/freebsdkernel # # (find-fline "/usr/share/doc/grub/menu.lst") cat > /hda1/boot/grub/menu.lst <<'---' timeout 5 title Linux root=/dev/hdd8 kernel=(hd0,0)/boot/grub/vmlinuz kernel (hd0,0)/boot/grub/vmlinuz root=/dev/hdd8 ro vga=1 title Linux root=/dev/hdd8 kernel=(hd0,0)/boot/grub/vmlinuz kernel (hd0,0)/boot/grub/vmlinuz root=/dev/hdd8 ro vga=1 title FreeBSD (hd2,2,a) root (hd2,2,a) kernel (hd0,0)/boot/grub/freebsdkernel title GNU/Hurd kernel (hd0,0)/boot/grub/gnumach.gz root=hd2s5 module (hd0,0)/boot/grub/serverboot.gz title GNU/Hurd single-user kernel (hd0,0)/boot/grub/gnumach.gz root=hd2s5 -s module (hd0,0)/boot/grub/serverboot.gz --- # (find-grubnode "Installation under UNIX" "/sbin/grub --batch") grub --batch <<'---' install (hd0,0)/boot/grub/stage1 (hd0) (hd0,0)/boot/grub/stage2 p (hd0,0)/boot/grub/menu.lst quit --- # # But I haven't been able to configure freebsd's rootdev, # it always complains about not finding what it wants in "wd0s1`". # Partition check: (oops - date for this?) # hda: hda1 hda2 hda3 hda4 < hda5 hda6 > # hdc: hdc1 hdc2 hdc3 hdc4 < hdc5 hdc6 > # hdd: hdd1 hdd2 hdd3! hdd4 < hdd5 hdd6 hdd7 hdd8 > < hdd9 hdd10 hdd11 hdd12 > ##### # # grub source # 2000jul01 # ##### pdsc $SDEBIAN/dists/potato/main/source/base/grub_0.5.93.1.dsc cd /usr/src/grub-0.5.93.1/ debian/rules binary |& tee odr # strace -o ~/s grub/grub # The newly-compiled grub can read all my partions without disk errors # under Linux, but not when I boot using it... Try "cat (hd0," in # both versions... # (code-c-d "grub" "/usr/src/grub-0.5.93.1/") # (find-grubfile "") # (find-grubfile "stage2/common.c" "Partition table invalid or corrupt") # (find-grubfile "stage2/disk_io.c" "ERR_BAD_PART_TABLE") # (find-grubfile "stage2/disk_io.c" '* 2 "ERR_BAD_PART_TABLE") # (find-grubfile "stage2/disk_io.c" '* 3 "ERR_BAD_PART_TABLE") cd /usr/src/grub-0.5.93.1/ for i in $(find * -name '*.c'); do echo "-- $i:" getstrings < $i | grep install done # (find-grubfile "stage2/builtins.c") # (find-grubfile "stage2/builtins.c" "struct builtin builtin_install =") # (find-grubfile "stage2/builtins.c" "install_func") # (find-grubfile "stage2/builtins.c" "install_func" "patched with new values") # It seems that I don't need to rerun Grub after changing my menu.lst; # Grub remembers only its location (partition/path) and will reread it # from there every time it boots. ##### # # grub 0.90 # 2001oct26 # ##### # «grub-src» (to ".grub-src") # pdsc $SDEBIAN/pool/main/g/grub/grub_0.90-12.dsc cd /usr/src/grub-0.90/ find * | grep '\.[chsS]$' > .files.chS etags $(<.files.chS) debian/rules binary |& tee odrb # cd /usr/src/grub-0.90/ make install |& tee omi # # (code-c-d "grub" "/usr/src/grub-0.90/" "/usr/src/grub-0.90/docs/grub") # (code-c-d "grub" "/usr/src/grub-0.90/" "grub") # (find-grubfile "") # (find-grubnode "Top") # (find-grubnode "Invoking grub-install") mount -o remount,rw /dev/hda1 strace-to ~/s \ grub-install --root-directory=/hda1/boot/grub /dev/hda1 grub-install --root-directory=/hda1/boot/grub /dev/hda cp -v /usr/lib/grub/i386-pc/* /hda1/boot/grub/ # (find-grubfile "stage2/start.S") ##### # # Grub and NetBSD # 2001oct26 # ##### # «netbsd» (to ".netbsd") # (find-grubnode "NetBSD") # (find-grubnode "kernel") # (find-grubfile "stage2/builtins.c" "\"netbsd\", 6") ##### # # Grub and FreeBSD (now via "loader") # 2000aug30 # ##### # (find-grubnode "FreeBSD") # (find-fline "/freebsd/boot/") # (find-fline "/freebsd/var/src/sys/") # (find-fline "/freebsd/var/src/sys/boot/forth/") # (find-fline "/freebsd/var/src/sys/boot/i386/loader/") # But how does the loader discover where's the BSD partition? ##### # # Making Grub treat files as floppy images # 2000oct11 # ##### # «floppy_images» (to ".floppy_images") # (find-grubfile "netboot/3c90x.txt" "floppy image") # (find-grubnode "Network") # (find-grubfile "") # (find-grubfile "netboot/") # (find-grubfile "netboot/README.netboot") # (find-node "(multiboot)OS image format") ##### # # etherboot # 2000oct13 # ##### # rm -Rv /usr/src/etherboot-4.7.6/ cd /usr/src/ tar -xvzf $S/http/etherboot.sourceforge.net/etherboot-4.7.6.tar.gz cd /usr/src/etherboot-4.7.6/ # cd /usr/src/etherboot-4.7.6/src/ make |& tee om # (find-ethbtfile "src/om") # (progn (find-ethbtfile "src/om") (wrap 0)) # # (code-c-d "ethbt" "/usr/src/etherboot-4.7.6/") # (find-ethbtfile "") # (find-ethbtfile "mknbi-1.0/") # (find-ethbtfile "mknbi-1.0/spec.txt" "/* load address") # (find-ethbtfile "mknbi-1.0/first-dos.S" "simulating either a floppy drive or a hard disk") # (find-ethbtfile "doc/text/") # (find-ethbtfile "doc/text/spec.txt") # (find-ethbtfile "doc/text/spec.txt" '* 2 "jump") # (find-ethbtfile "RELNOTES" "handles ROM, Linux, FreeDOS, and DOS images") # (find-ethbtfile "contrib/hdload/petr.msg") # (find-ethbtfile "contrib/mntnbi/mntnbi.pl") # (find-ethbtfile "mknbi-1.0/first-dos.S") # (find-ethbtfile "mknbi-1.0/first-dos.S" "function 02: read disk") ##### # # netboot # 2000oct13 # ##### # rm -Rv /usr/src/netboot/ cd /usr/src/ tar -xvzf $S/http/www.han.de/~gero/netboot/files/netboot-0.9.0e.tar.gz cd /usr/src/netboot/ # (code-c-d "netbt" "/usr/src/netboot/") # (find-netbtfile "") # (find-netbtfile "README" "subscribe netboot") # (find-netbtfile "bootrom/netdrvr/dossim/") # (find-netbtfile "mknbi-dos/") # ##### # # DEBUG_PRINT # 2000oct19 # ##### # From a mail by Okuji in the bug-grub list, circa 2000oct19: debug C code by inserting grub_printf calls into some places. For example, you write this: #define DEBUG_PRINT(msg) \ grub_printf("DEBUG: line %d in %s: %s\n", \ __LINE__, __FILE__, (msg)) ... DEBUG_PRINT ("before foo"); foo (); DEBUG_PRINT ("after foo"); # (find-grubfile "NEWS" "mini-debug") zcatinfo /usr/share/info/grub > /tmp/grub.info # (find-fline "/tmp/grub.info") cd /usr/src/grub-0.5.95/ agrep -i debug $(find *) ##### # # invaders # 2001may19 # ##### # «invaders» (to ".invaders") # http://www.erikyyy.de/invaders/ # http://www.erikyyy.de/invaders/invaders-1.0.0.tar.gz # rm -Rv /usr/src/invaders/ cd /usr/src/ tar -xvzf $S/http/www.erikyyy.de/invaders/invaders-1.0.0.tar.gz cd /usr/src/invaders/ rm -v invaders find *.[chS] | sort > .files.chS etags $(<.files.chS) ./compile.sh |& tee oc # mount -o remount,rw /dev/hda1 cd /usr/src/invaders/ cp -v invaders /hda1/boot/grub/ # # (code-c-d "invaders" "/usr/src/invaders/") # (find-invadersfile "") # (find-invadersfile "README") # (find-invadersfile "oc") # (find-invadersfile "boot.S") # (find-invadersfile "boot.S" "#include ") # (find-invadersfile "multiboot.h") # (find-fline "/hda1/boot/grub/") # (find-node "(binutils)objcopy") ##### # # cvs # 2000dec10 # ##### # (find-grubnode "Obtaining and Building GRUB" "cvs -d") # mkdir -p ~/usrc/grub/cvs/ cd ~/usrc/grub/cvs/ export CVS_RSH="ssh" cvs -z3 -d:ext:anoncvs@savannah.gnu.org:/cvsroot/grub co grub tar -cvzf grub-cvs.tar.gz grub/ # cd ~/usrc/grub/ tar -xvzf cvs/grub-cvs.tar.gz # # (code-c-d "grub" "~/usrc/grub/grub/") # (find-grubfile "") # (find-grubfile "docs/") # (find-grubfile "docs/menu.lst") ##### # # update-grub # 2004sep06 # ##### # «update-grub» (to ".update-grub") # (find-status "grub") # (find-vldifile "grub.list") # (find-fline "/usr/doc/grub/") # (find-man "8 update-grub") # (find-fline "/sbin/update-grub") # (find-fline "/sbin/update-grub" "menu.lst") # (find-fline "/sbin/update-grub" "/boot/boot/grub") # (find-fline "/sbin/update-grub" "BEGIN AUTOMAGIC KERNELS LIST") ##### # # grub chainloading # 2004sep11 # ##### # «chainloader» (to ".chainloader") # (find-grubnode "chainloader") # (find-grubnode "Chain-loading") # (find-grubnode "Invoking grub-install") # (find-grubnode "Invoking the grub shell") # (find-fline "/sbin/grub-install") # (find-fline "/sbin/grub-install" "grub_shell=${sbindir}/grub") ##### # # the device map # 2004sep11 # ##### # «device.map» (to ".device.map") # (find-grubnode "Basic usage" "`--device-map=FILE'") # (find-grubnode "Device map") # (find-fline "/sbin/grub-install" "device_map=${grubdir}/device.map") # zcatinfo /usr/share/info/grub > /tmp/grub.info # (find-fline "/tmp/grub.info") # # (find-fline "/sbin/grub-install" "# Create the device map file") # (find-fline "/usr/sbin/grub-install") rm -v /tmp/device.map echo quit \ | /sbin/grub --batch --device-map=/tmp/device.map cat /tmp/device.map # ### The result will typically be something like this: # (fd0) /dev/fd0 # (hd0) /dev/hda # (hd1) /dev/hdb # «partition.map» (to ".partition.map") # Is there a way to produce a "partition map"? # Grub gives non-linuxish names to logical partitions and BSD partitions. # A workaround: # add a "/.id" file to each partition. # (find-angg ".zshrc" "partitionids") # Grub is able to browse and cat files. # (find-grubnode "cat") # cat > $EEG <<'%%%' cat (hd0,0)/.id cat (hd0,1)/.id cat (hd0,2)/.id cat (hd0,3)/.id quit %%% # eeg grub --batch --device-map=/tmp/device.map eeg grub --device-map=/tmp/device.map # ##### # # CDs with grub # 2004sep11 # ##### # (find-grubnode "Making a GRUB bootable CD-ROM") # mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \ # -boot-load-size 4 -boot-info-table -o grub.iso iso # (find-man "mkisofs" " -b eltorito_boot_image") # (find-man "mkisofs" " -no-emul-boot") # (find-fline "/lib/grub/i386-pc/" "stage2") ##### # # grub-install # 2004sep13 # ##### # «grub-install» (to ".grub-install") # (find-grubnode "Installing GRUB using grub-install") # (find-grubnode "Invoking grub-install") # (find-fline "/sbin/grub-install" "# Create the device map file") # cat > /tmp/dummygrubshell <<'%%%' #!/bin/sh -- echo Args: $* cat %%% chmod 777 /tmp/dummygrubshell rm -Rv /tmp/grubroot mkdir /tmp/grubroot # mkdir -p /tmp/grubroot/boot/grub/ cd /tmp/grubroot/boot/grub/ rm -v device.map echo quit \ | sudo /sbin/grub --batch --device-map=device.map cat device.map # # (find-fline "/sbin/grub-install" "The file $file not read correctly.") # (find-fline "/sbin/grub-install" "log_file") # (find-fline "/tmp/") grub-install --grub-shell=/tmp/dummygrubshell --root-directory=/tmp/grubroot \ /dev/hda2 # # «grub:find» (to ".grub:find") # (find-grubnode "Installing GRUB natively" "not sure which partition" "find") # (find-grubnode "find") # (find-fline "/hda2/.id") cat /hda2/.id cat > $EEG <<'%%%' find /.id root (hd0,1) cat /.id quit %%% eeg sudo grub --device-map=/tmp/device.map # # «grub:setup» (to ".grub:setup") # (find-grubnode "Installation under UNIX") # (find-grubnode "Installing GRUB natively" "instead of putting it in the MBR") # (find-grubnode "setup") # (find-grubnode "install") # (find-grubnode "Images") mkdir -p /hda2/boot/grub/ cp -v /lib/grub/i386-pc/* /hda2/boot/grub/ # cat /hda2/.id cat > $EEG <<'%%%' root (hd0,1) cat /.id setup (hd0,1) quit %%% eeg sudo grub --device-map=/tmp/device.map # # (find-fline "/hda1/boot/grub/menu.lst") # (find-fline "/hda2/boot/grub/menu.lst") cat > /hda2/boot/grub/menu.lst <<'%%%' title Linux root=/dev/hdb3 kernel=(hd1,2)/vmlinuz root (hd1,2) kernel /boot/vmlinuz-2.4.26-1-386 root=/dev/hdb3 ro initrd /boot/initrd.img-2.4.26-1-386 title chainloader /dev/hda chainloader (hd0)+1 title halt halt %%% # # (find-status "grub") # (find-vldifile "grub.list") # (find-udfile "grub/") # (find-node "(grub)Installing GRUB natively" "setup") grub> root (hd0,0) If you are not sure which partition actually holds this directory, use the command `find' (*note find::), like this: grub> find /boot/grub/stage1 This will search for the file name `/boot/grub/stage1' and show the devices which contain the file. Once you've set the root device correctly, run the command `setup' (*note setup::): grub> setup (hd0) This command will install the GRUB boot loader on the Master Boot Record (MBR) of the first drive. If you want to put GRUB into the boot sector of a partition instead of putting it in the MBR, specify the partition into which you want to install GRUB: grub> setup (hd0,0) # (find-grubnode "Basic usage" "`--read-only'") # (find-man "grub-install") # (find-fline "/hdb2/wdc1/boot/grub/boot/grub/device.map") zcatinfo /usr/share/info/grub > /tmp/grub.info # (find-fline "/tmp/grub.info") ##### # # grub 1.95 (upstream) # 2007feb06 # ##### # «grub-1.95» (to ".grub-1.95") # http://en.wikipedia.org/wiki/GNU_GRUB # http://www.gnu.org/software/grub/ # http://www.gnu.org/software/grub/grub-2.en.html # http://www.gnu.org/software/grub/grub-2-download.en.html # ftp://alpha.gnu.org/gnu/grub/grub-1.95.tar.gz # rm -Rv ~/usrc/grub-1.95/ tar -C ~/usrc/ -xvzf $S/ftp/alpha.gnu.org/gnu/grub/grub-1.95.tar.gz cd ~/usrc/grub-1.95/ # ./configure --help |& tee och ./configure |& tee oc make |& tee om # # (code-c-d "grub2" "~/usrc/grub-1.95/") # (find-grub2sh "find | sort") # (find-grub2file "") # (find-grub2file "INSTALL" "LZO") # (find-grub2file "configure.ac" "-llzo2") # (find-debpkg-links "lzop") # (find-debpkg-links "liblzo-dev") # (find-grubsh "find") (find-zsh "grep-available lzo") ##### # # grub2 (upstream, CVS) # 2007sep25 # ##### # «grub2» (to ".grub2") # http://grub.enbug.org/ # http://grub.enbug.org/MailingLists # http://lists.gnu.org/mailman/listinfo/grub-devel # http://lists.gnu.org/archive/html/grub-devel/ # rm -Rv ~/usrc/grub2/ mkdir ~/usrc/grub2/ cd ~/usrc/ tar -C ~/usrc/ -xvzf ~/tmp/grub2-cvs.tar.gz cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/grub co grub2 cd ~/usrc/ tar -cvzf ~/tmp/grub2-cvs.tar.gz grub2/ cd ~/usrc/grub2/ # rm -Rv ~/usrc/grub2/ mkdir ~/usrc/grub2/ cd ~/usrc/ tar -C ~/usrc/ -xvzf ~/tmp/grub2-cvs.tar.gz cd ~/usrc/grub2/ find * | sort > .files find * -name '*.[ch]' | sort > .files.ch # My question: # Installing grub on an HD image # http://lists.gnu.org/archive/html/grub-devel/2007-09/msg00039.html # An answer: # [PATCH] do not require that device is a partition # http://lists.gnu.org/archive/html/grub-devel/2007-10/msg00030.html # http://lists.gnu.org/archive/html/grub-devel/2007-10/txtDXw8NsjObG.txt # (find-grub2file "normal/misc.c" "dev->disk->has_partitions") cp -iv normal/misc.c normal/misc.c.orig # patch -p0 normal/misc.c <<'%%%' # 43c43 # < else if (! dev->disk || ! dev->disk->has_partitions || dev->disk->partition) # --- # > else # %%% etags $(cat .files.ch) ./configure --help |& tee och mkdir ~/usrc/grub2/ulocal ./configure --prefix=$PWD/ulocal --enable-grub-emu |& tee oc make |& tee om make install |& tee omi # # (code-c-d "grub2" "~/usrc/grub2/" :grep) # (find-grub2file ".files.ch") # (find-grub2file ".files") # (find-grub2file "") # (find-grub2file "och") # How to make grub2 work without (global) installation? # (find-grub2file "configure.ac") # (find-grub2file "grub-install") # (find-grub2file "grub-install" "prefix=/usr/local") # (find-grub2file "grub-install" "uses grub-setup to install grub") # (find-grub2file "grub-setup") # Aha: --prefix=$PWD/ulocal # (find-grub2grep "grep -nH -e modules $(cat .files.ch)") # (find-grub2grep "grep -nH -e device-map $(cat .files.ch)") # «grub2-on-test.img» (to ".grub2-on-test.img") # (find-es "plurall" "loop-fdisk-mke2fs")  (eepitch-shell) cd ~/usrc/grub2/ ./grub-install ./grub-install /tmp/test.img ./grub-install /tmp/test.img --root-directory=/tmp/dev1/boot/grub/ ./grub-install /tmp/test.img --root-directory=/tmp/dev1/boot/grub/ --modules= # ./grub-install $(cat /tmp/test.dev0) --root-directory=/tmp/dev1/ # grub-probe: error: cannot find a GRUB drive for /dev/hda1. # Auto-detection of a filesystem module failed. # Please specify the module with the option `--modules' explicitly. # (find-grub2file "") # (find-grub2grep "grep -nH -e modules $(cat .files.ch)") # (find-grub2file "grub-install" "--modules=MODULES") # (find-grub2file "grub-install" "Please specify the module") # (find-grub2file "grub-install" "$grub_probe --target=fs") # (find-grub2file "ulocal/lib/grub/i386-pc/") # (find-grub2file "boot/i386/pc/diskboot.S") # (find-grub2file "om") # (find-grub2file "util/grub-probe.c") sudo mkdir /tmp/dev1/boot/ sudo chown edrx:edrx /tmp/dev1/boot/ # /home/edrx/usrc/grub2(edrx:pe)# ./grub-install /tmp/test.img --root-directory=/tmp/dev1/boot/ # grub-probe: error: cannot find a GRUB drive for /dev/loop5. # Auto-detection of a filesystem module failed. # Please specify the module with the option `--modules' explicitly. # /home/edrx/usrc/grub2(edrx:pe)# # (find-grub2file "util/grub-probe.c") # (find-grub2file "util/grub-probe.c" "--target=") ##### # # Installing grub on an HD image # 2007oct05 # ##### # «grub-on-hd-image» (to ".grub-on-hd-image") # My question: # Installing grub on an HD image # http://lists.gnu.org/archive/html/grub-devel/2007-09/msg00039.html # An answer: # [PATCH] do not require that device is a partition # http://lists.gnu.org/archive/html/grub-devel/2007-10/msg00030.html # http://lists.gnu.org/archive/html/grub-devel/2007-10/txtDXw8NsjObG.txt ##### # # Grub2 on an ISO image # 2007oct29 # ##### # «grub2-on-iso» (to ".grub2-on-iso") # http://lists.gnu.org/archive/html/grub-devel/2007-08/msg00064.html # http://lists.gnu.org/archive/html/grub-devel/2007-08/msg00072.html # http://www.gnu.org/software/grub/manual/html_node/ ##### # # Grub2 on a floppy image # 2007oct29 # ##### # «grub2-on-a-floppy» (to ".grub2-on-a-floppy") # Adapted from: # http://grub.enbug.org/TestingOnX86 # That page ("TestingOnX86") has a link to this mailing list message: # http://lists.gnu.org/archive/html/grub-devel/2004-09/msg00111.html # and the mailing list message contains a grub.cfg, that has these lines: # # #GNU/Linux # insmod linux # insmod boot # insmod multiboot # (find-fline "~/usrc/grub2/") # (find-grub2sh "./grub-mkimage -h") # (find-grub2sh "./grub-setup -h") # (find-man "8 mkdosfs") # (find-man "8 mkdosfs" "-C" "Create the file")  (eepitch-shell)  (eepitch-kill)  (eepitch-shell) sudo umount /tmp/floppy cd ~/usrc/grub2/ ./grub-mkimage -d . -v -o /tmp/core.img _chain fat /sbin/mkdosfs -C /tmp/floppy.img 1440 mkdir /tmp/floppy/ sudo mount -o loop /tmp/floppy.img \ /tmp/floppy/ sudo mkdir -p /tmp/floppy/boot/grub/ sudo cp -v boot.img /tmp/core.img *.mod /tmp/floppy/boot/grub/ echo "(fd0) /tmp/floppy.img" \ > /tmp/device.map sudo ./grub-setup -v -r "(fd0)" \ -d /tmp/floppy/boot/grub/ \ -m /tmp/device.map \ "(fd0)" cat > /tmp/menu.lst <<'%%%' timeout 5 title Linux root=/dev/hdd8 kernel=(hd0,0)/boot/grub/vmlinuz-2.2.19-edrx kernel (hd0,0)/boot/grub/vmlinuz-2.2.19-edrx root=/dev/hdd8 ro vga=1 %%% sudo cp -v /tmp/menu.lst /tmp/floppy/boot/grub/ # What is grub.cfg? # test -f grub.cfg && sudo cp -f grub.cfg /mnt/loop/boot/grub/ sudo umount /tmp/floppy # (find-man "1 qemu") qemu -m 64 -fda /tmp/floppy.img ##### # # The command-line and menu interfaces in grub2 # 2007oct29 # ##### # «grub2-menu-interface» (to ".grub2-menu-interface") # Does grub2 have a CLI with tab completion and a menu interface like # grub-legacy? Yes, it's at normal/menu.c, but it's not running, it # seems - # (find-node "(grub)Command-line interface") # (find-node "(grub)Menu interface") # (find-grub2grep "grep -niH -e tab $(find *.c)") # (find-grub2grep "grep -niH -e 'list devices or files' $(find *)") # (find-grub2file "kern/rescue.c" "list devices or files") # (find-grub2grep "grep -niH -e 'grub_rescue_cmd_ls' $(find *)") # (find-grub2file "kern/rescue.c" "grub_rescue_cmd_ls" "print_devices") # (find-grub2file "ChangeLog") # (find-grub2file "ChangeLog" "When \"menu\" is not set") # (find-grub2file "normal/menu.c") # (find-grub2file "normal/completion.c") # (find-grub2file "normal/") # (find-grub2file "") # (find-grub2file "om") # Also: just "ls" is not printing any devices, just a blank line... ##### # # SuperGrubDisk # 2007oct29 # ##### # «supergrubdisk» (to ".supergrubdisk") # http://geocities.com/supergrubdisk/ # http://supergrub.forjamari.linex.org/ # https://listas.ensanjose.net/pipermail/supergrub/ # https://listas.ensanjose.net/pipermail/supergrub-es/ # http://forjamari.linex.org/projects/supergrub/ # http://forjamari.linex.org/frs/download.php/687/sgd_0.9664.iso.bz2 # http://forjamari.linex.org/frs/download.php/692/sgd_public_source_code_0.9664.tar.bz2 # tar -tvjf $S/http/forjamari.linex.org/frs/download.php/692/sgd_public_source_code_0.9664.tar.bz2 # bzcat $S/http/forjamari.linex.org/frs/download.php/687/sgd_0.9664.iso.bz2 > /tmp/sgd.iso # rm -Rf /tmp/sgd_public_source_code_0.9664/ tar -C /tmp/ -xvjf $S/http/forjamari.linex.org/frs/download.php/692/sgd_public_source_code_0.9664.tar.bz2 cd /tmp/sgd_public_source_code_0.9664/ # # (find-fline "/tmp/sgd_public_source_code_0.9664/") # (code-c-d "sgd" "/tmp/sgd_public_source_code_0.9664/") # (find-sgdfile "") # (find-sgdfile "boot/grub/") # It uses grub-legacy... # (find-sgdfile "dev_grub/ChangeLog") ##### # # parsing /proc/cmdline # 2007oct29 # ##### # «.parsing-proc-cmdline» (to "parsing-proc-cmdline") # «parsing-proc-cmdline» (to ".parsing-proc-cmdline") # (find-fline "/proc/cmdline") # (find-sh "cat /proc/cmdline | tr ' ' '\n'") # The entries in /proc/cmdline are separated by spaces, not by NULLs. # On persephone: # auto BOOT_IMAGE=Linux ro root=301 # On an isolinux CD booting the Debian Etch DVD kernel and initrd: # vga=normal initrd=/initrd.gz -- BOOT_IMAGE=/vmlinuz # A very good message about trusted/treacherous Grub: # http://lists.gnu.org/archive/html/grub-devel/2007-10/msg00165.html # ``I can make arguments like these too: "A cluster bomb is a # technology. Like all technology, it has both benign and malignant # and antisocial usage cases."'' # http://www.pixelbeat.org/docs/disk/ # http://grub.enbug.org/TestingOnX86 # Local Variables: # coding: raw-text-unix # ee-delimiter-hash: "\n#\n" # ee-delimiter-percent: "\n%\n" # ee-anchor-format: "«%s»" # End: