From owner-freebsd-hackers@FreeBSD.ORG Fri May 21 18:48:05 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 762A016A4CF for ; Fri, 21 May 2004 18:48:05 -0700 (PDT) Received: from web21505.mail.yahoo.com (web21505.mail.yahoo.com [66.163.169.16]) by mx1.FreeBSD.org (Postfix) with SMTP id 526C443D4C for ; Fri, 21 May 2004 18:48:05 -0700 (PDT) (envelope-from jiafu_he@yahoo.com) Message-ID: <20040522014749.9700.qmail@web21505.mail.yahoo.com> Received: from [151.196.118.13] by web21505.mail.yahoo.com via HTTP; Fri, 21 May 2004 18:47:49 PDT Date: Fri, 21 May 2004 18:47:49 -0700 (PDT) From: Jiafu He To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: Re: mini-howto: Grub on FreeBSD (UFS2) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 May 2004 01:48:05 -0000 Sorry, forgot the main part. see it here: =================================================== ######## How to Use Grub Bootloader on FreeBSD ######## ######## jiafu_he@yahoo.com, 05/18/2004 ######## This mini-howto is written as a dummy introduction on how to get, install, setup and use GNU/Grub bootloader on FreeBSD. If you need more detailed information, go read the Grub mannual at http://www.gnu.org/manual/grub/html_mono/grub.html Note: UFS2 is supported starting from the verion Grub-0.94_3. 1. Obtaining Grub files: To use Grub on FreeBSD UFS2, you need files "stage1", "stage2" and "ufs2_stage1_5". To handle other types of file systems, you need other stage 1.5 files like "ffs_stage1_5", "e2fs_stage1_5", or "fat_stage1_5" etc. You can obtain the files from either i. the GNU/Grub website http://www.gnu.org/software/grub/ ii. or FreeBSD Grub port. Grub-0.94_3 requires freebsd 5.2.1 or current. To install Grub-0.94_3, do the following: ------------------------------- #cd /usr/ports/sysutils/grub /* go to the grub freebsd port dir */ #make install clean /* install it */ ------------------------------- If all goes well, the Grub files are generated in directory /usr/local/share/grub/i386-freebsd/ and the executable "grub" is installed under /usr/local/sbin/ 2. Installing Grub on UFS2 partition: i. Create /boot/grub/ directory (or alternatively /grub/) on your HD and copy files in it: ----------------------------------------------- #cd /boot;mkdir grub #cp -Rf /usr/local/share/grub/i386-freebsd grub ----------------------------------------------- Make sure at least files "stage1" and "stage2" are under /boot/grub/. To be complete, the pertinent stage 1.5 file (here "ufs2_stage1_5") is also needed. ii. Create Grub boot floppy. You can either a. using "dd" (recommended): ----------------------------------------------- #dd if=stage1 of=/dev/fd0 bs=512 count=1 /* stage1 to block #1 */ 1+0 records in 1+0 records out #dd if=stage2 of=/dev/fd0 bs=512 seek=1 /* stage2 starting from block #2 */ 153+1 records in 153+1 records out # ----------------------------------------------- b. or alternatively using Grub "setup" under FreeBSD: ----------------------------------------------- #fdformat -f1440 /dev/fd0 /* low level format the floppy if you want to */ #newfs -LGrubBoot -O1 /dev/fd0 /* format into UFS1 */ #mount /dev/fd0 /mnt #mkdir /mnt/boot #cp -Rf /usr/local/share/grub/i386-freebsd /mnt/boot/grub #touch /mnt/boot/grub/menu.lst /* touch and edit menu.lst, see step 3 */ #umount /mnt #grub grub> device (fd0) /dev/fd0 /* set the device map */ grub> root (fd0) Filesystem type is ffs, using whole disk grub> find /boot/grub/stage1 /* verify whether the required files are there */ (fd0) grub> setup (fd0) /* setup the floppy */ Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/ffs_stage1_5" exists... yes Running "embed /boot/grub/ffs_stage1_5 (fd0)"... failed (this is not fatal) Running "embed /boot/grub/ffs_stage1_5 (fd0)"... failed (this is not fatal) Running "install /boot/grub/stage1 (fd0) /boot/grub/stage2 p /boot/grub/menu.lst " ... succeeded Done. ----------------------------------------------- 3. Touch and edit "/boot/grub/menu.lst". An example is given below, assuming that - partition 0: Windows XP; - partition 1: FreeBSD; - partition 2: Linux. ------------------------------------------- default saved # boot the last selection. Work together with savedefault below timeout 10 # timeout 10 seconds password --md5 $1$rEjBN0$0J06NigS.2ImTaipPOh0w/ # md5 passwd encryption: "testgrub" # Boot Windows XP. You have to chainloading. title Windows XP Professional # display boot title on the Grub prompt root (hd0,0) # set the root device or partition makeactive # set the partition active so that next time it can be automatically # booted after timing-out chainloader +1 # Here we have to chainload savedefault # save this selection as the default for next bootstrap # Boot FreeBSD title FreeBSD 5.1_p16 root (hd0,1,a) kernel /boot/loader # specify the kernel or kernel loader makeactive savedefault # Boot Redhat Linux title Redhat Linux root (hd0,2) kernel /boot/vmlinuz-2.4.18-14smp ro root=LABEL=/ hdc=ide-scsi initrd /boot/initrd-2.4.18-14smp.img makeactive savedefault # Install Grub on Slice 1 (the FreeBSD partition) title Install Grub on FreeBSD (Slice 1) root (hd0,1,a) setup (hd0) savedefault --------------------------------------------- 4. Install Grub to MBR on your hard disk (using grub native way): i. Boot the machine using the floppy just created; ii. on the Grub menu screen, you can either make use of the last menu entry (see menu.lst above) or do the following: ----------------------------------- : (Grub menu screen) : p # password is needed since the password line is in config file. password: testgrub c # enter command prompt Then you enter the command prompt: grub> find /boot/grub/stage1 /* find which partition has Grub files */ (hd0,1,a) /* it will display the found parition */ grub> root (hd0,1,a) Filesystem type is ufs2, partition type 0xa5 grub> setup (hd0) /* install Grub in MBR */ Checking if "/boot/grub/stage1" exists ... yes Checking if "/boot/grub/stage2" exists ... yes Checking if "/boot/grub/ufs2_stage1_5" exists ... yes Running "embed /boot/grub/ufs2_stage1_5 (hd0)"... 16 sectors embeded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,1,a)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded ------------------------------------ 5. Finally how to generate md5-encrypted password: Enter any Grub command prompt: grub> md5crypt /* call the md5 password encryption utility */ password: yourDesiredPassword /* passwd are replaced by same number of "*" */ EncryptedPassword /* encrypted password is returned here, put it in config file */ That is pretty much it. Enjoy! ########### End of MiniHowto: Grub on FreeBSD ############# ==================================================== Jiafu He wrote: hi, folks, I saw some questions on Grub for FreeBSD. Here I have a short mini-howto on how to use Grub on FreeBSD, which originated from the notes I took. Hope it can provide a tiny bit help. Thanks. Jiafu --------------------------------- Do you Yahoo!? Yahoo! Domains - Claim yours for only $14.70/year --------------------------------- Do you Yahoo!? Yahoo! Domains - Claim yours for only $14.70/year