<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://freebsdwiki.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://freebsdwiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Immessouane</id>
		<title>FreeBSDwiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://freebsdwiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Immessouane"/>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php/Special:Contributions/Immessouane"/>
		<updated>2026-04-08T09:47:04Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.18.0</generator>

	<entry>
		<id>http://freebsdwiki.net/index.php/GRUB_FreeBSD</id>
		<title>GRUB FreeBSD</title>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php/GRUB_FreeBSD"/>
				<updated>2008-02-18T17:30:45Z</updated>
		
		<summary type="html">&lt;p&gt;Immessouane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Grub Bootloader on FreeBSD ==&lt;br /&gt;
by &amp;lt;Jiafu He&amp;gt;jiafu_he at yahoo.com, 05/18/2004&lt;br /&gt;
&lt;br /&gt;
This mini-howto is written as a dummy introduction on how to get, &lt;br /&gt;
install, setup and use GNU/Grub bootloader on FreeBSD. If you need &lt;br /&gt;
more detailed information, go read the Grub mannual at &lt;br /&gt;
http://www.gnu.org/manual/grub/html_mono/grub.html&lt;br /&gt;
Note: UFS2 is supported starting from the verion Grub-0.94_3.&lt;br /&gt;
&lt;br /&gt;
1. Obtaining Grub files:&lt;br /&gt;
   To use Grub on FreeBSD UFS2, you need files &amp;quot;stage1&amp;quot;, &amp;quot;stage2&amp;quot; and &lt;br /&gt;
   &amp;quot;ufs2_stage1_5&amp;quot;. To handle other types of file systems, you need &lt;br /&gt;
   other stage 1.5 files like &amp;quot;ffs_stage1_5&amp;quot;, &amp;quot;e2fs_stage1_5&amp;quot;, or &lt;br /&gt;
   &amp;quot;fat_stage1_5&amp;quot; etc. &lt;br /&gt;
   You can obtain the files from either&lt;br /&gt;
   i. the GNU/Grub website http://www.gnu.org/software/grub/&lt;br /&gt;
   ii. or FreeBSD Grub port. Grub-0.94_3 requires freebsd 5.2.1 or &lt;br /&gt;
      current. To install Grub-0.94_3, do the following:&lt;br /&gt;
   -------------------------------&lt;br /&gt;
   #cd /usr/ports/sysutils/grub  /* go to the grub freebsd port dir */&lt;br /&gt;
   #make install clean    /* install it */&lt;br /&gt;
   -------------------------------&lt;br /&gt;
   If all goes well, the Grub files are generated in directory&lt;br /&gt;
   /usr/local/share/grub/i386-freebsd/ and the executable &amp;quot;grub&amp;quot; is &lt;br /&gt;
   installed under /usr/local/sbin/&lt;br /&gt;
&lt;br /&gt;
2. Installing Grub on UFS2 partition:&lt;br /&gt;
   i. Create /boot/grub/ directory (or alternatively /grub/) on your HD&lt;br /&gt;
      and copy files in it:&lt;br /&gt;
   -----------------------------------------------&lt;br /&gt;
   #cd /boot;mkdir grub&lt;br /&gt;
   #cp -Rf /usr/local/share/grub/i386-freebsd grub&lt;br /&gt;
   -----------------------------------------------&lt;br /&gt;
   Make sure at least files &amp;quot;stage1&amp;quot; and &amp;quot;stage2&amp;quot; are under /boot/grub/. To be &lt;br /&gt;
   complete, the pertinent stage 1.5 file (here &amp;quot;ufs2_stage1_5&amp;quot;) is also needed. &lt;br /&gt;
   ii. Create Grub boot floppy. You can either&lt;br /&gt;
     a. using &amp;quot;dd&amp;quot; (recommended):&lt;br /&gt;
     ----------------------------------------------- &lt;br /&gt;
     #dd if=stage1 of=/dev/fd0 bs=512 count=1 /* stage1 to block #1 */ &lt;br /&gt;
     1+0 records in&lt;br /&gt;
     1+0 records out&lt;br /&gt;
     #dd if=stage2 of=/dev/fd0 bs=512 seek=1 /* stage2 starting from block #2 */&lt;br /&gt;
     153+1 records in&lt;br /&gt;
     153+1 records out&lt;br /&gt;
     #&lt;br /&gt;
     ----------------------------------------------- &lt;br /&gt;
     b. or alternatively using Grub &amp;quot;setup&amp;quot; under FreeBSD:&lt;br /&gt;
     ----------------------------------------------- &lt;br /&gt;
     #fdformat -f1440 /dev/fd0  /* low level format the floppy if you want to */&lt;br /&gt;
     #newfs -LGrubBoot -O1 /dev/fd0 /* format into UFS1 */&lt;br /&gt;
     #mount /dev/fd0 /mnt&lt;br /&gt;
     #mkdir /mnt/boot&lt;br /&gt;
     #cp -Rf /usr/local/share/grub/i386-freebsd /mnt/boot/grub&lt;br /&gt;
     #touch /mnt/boot/grub/menu.lst /* touch and edit menu.lst, see step 3 */&lt;br /&gt;
     #umount /mnt&lt;br /&gt;
     #grub&lt;br /&gt;
     grub&amp;gt; device (fd0) /dev/fd0  /* set the device map */&lt;br /&gt;
     grub&amp;gt; root (fd0)&lt;br /&gt;
      Filesystem type is ffs, using whole disk&lt;br /&gt;
     grub&amp;gt; find /boot/grub/stage1 /* verify whether the required files are there */&lt;br /&gt;
      (fd0)&lt;br /&gt;
     grub&amp;gt; setup (fd0) /* setup the floppy */&lt;br /&gt;
      Checking if &amp;quot;/boot/grub/stage1&amp;quot; exists... yes&lt;br /&gt;
      Checking if &amp;quot;/boot/grub/stage2&amp;quot; exists... yes&lt;br /&gt;
      Checking if &amp;quot;/boot/grub/ffs_stage1_5&amp;quot; exists... yes&lt;br /&gt;
      Running &amp;quot;embed /boot/grub/ffs_stage1_5 (fd0)&amp;quot;... failed (this is not fatal) &lt;br /&gt;
      Running &amp;quot;embed /boot/grub/ffs_stage1_5 (fd0)&amp;quot;... failed (this is not fatal)&lt;br /&gt;
      Running &amp;quot;install /boot/grub/stage1 (fd0) /boot/grub/stage2 p /boot/grub/menu.lst &amp;quot;&lt;br /&gt;
      ... succeeded&lt;br /&gt;
     Done.&lt;br /&gt;
     ----------------------------------------------- &lt;br /&gt;
&lt;br /&gt;
3. Touch and edit &amp;quot;/boot/grub/menu.lst&amp;quot;. An example is given below, assuming that&lt;br /&gt;
     - partition 0: Windows XP; &lt;br /&gt;
     - partition 1: FreeBSD;&lt;br /&gt;
     - partition 2: Linux.&lt;br /&gt;
   -------------------------------------------&lt;br /&gt;
   default saved  # boot the last selection. Work together with savedefault below&lt;br /&gt;
   timeout 10  # timeout 10 seconds&lt;br /&gt;
   password --md5 $1$rEjBN0$0J06NigS.2ImTaipPOh0w/ # md5 passwd encryption: &amp;quot;testgrub&amp;quot; &lt;br /&gt;
   # Boot Windows XP. You have to chainloading.&lt;br /&gt;
   title Windows XP Professional  # display boot title on the Grub prompt&lt;br /&gt;
   root (hd0,0)  # set the root device or partition&lt;br /&gt;
   makeactive  # set the partition active so that next time it can be automatically &lt;br /&gt;
               # booted after timing-out &lt;br /&gt;
   chainloader +1  # Here we have to chainload &lt;br /&gt;
   savedefault  # save this selection as the default for next bootstrap &lt;br /&gt;
   # Boot FreeBSD&lt;br /&gt;
   title FreeBSD 5.1_p16&lt;br /&gt;
   root (hd0,1,a)&lt;br /&gt;
   kernel /boot/loader  # specify the kernel or kernel loader&lt;br /&gt;
   makeactive&lt;br /&gt;
   savedefault&lt;br /&gt;
   # Boot Redhat Linux&lt;br /&gt;
   title Redhat Linux&lt;br /&gt;
   root (hd0,2)&lt;br /&gt;
   kernel /boot/vmlinuz-2.4.18-14smp ro root=LABEL=/ hdc=ide-scsi&lt;br /&gt;
   initrd /boot/initrd-2.4.18-14smp.img&lt;br /&gt;
   makeactive&lt;br /&gt;
   savedefault&lt;br /&gt;
   # Install Grub on Slice 1 (the FreeBSD partition)&lt;br /&gt;
   title Install Grub on FreeBSD (Slice 1)&lt;br /&gt;
   root (hd0,1,a)&lt;br /&gt;
   setup (hd0)&lt;br /&gt;
   savedefault&lt;br /&gt;
   ---------------------------------------------&lt;br /&gt;
&lt;br /&gt;
4. Install Grub to MBR on your hard disk (using grub native way):&lt;br /&gt;
   i. Boot the machine using the floppy just created;&lt;br /&gt;
   ii. on the Grub menu screen, you can either make use of the last menu entry &lt;br /&gt;
       (see menu.lst above) or do the following:&lt;br /&gt;
      -----------------------------------&lt;br /&gt;
             :&lt;br /&gt;
      (Grub menu screen)&lt;br /&gt;
             :&lt;br /&gt;
      p  # password is needed since the password line is in config file.&lt;br /&gt;
       password: testgrub&lt;br /&gt;
      c  # enter command prompt&lt;br /&gt;
      Then you enter the command prompt:&lt;br /&gt;
      grub&amp;gt; find /boot/grub/stage1  /* find which partition has Grub files */&lt;br /&gt;
      (hd0,1,a)  /* it will display the found parition */&lt;br /&gt;
      grub&amp;gt; root (hd0,1,a)&lt;br /&gt;
       Filesystem type is ufs2, partition type 0xa5&lt;br /&gt;
      grub&amp;gt; setup (hd0)  /* install Grub in MBR */&lt;br /&gt;
       Checking if &amp;quot;/boot/grub/stage1&amp;quot; exists ... yes&lt;br /&gt;
       Checking if &amp;quot;/boot/grub/stage2&amp;quot; exists ... yes&lt;br /&gt;
       Checking if &amp;quot;/boot/grub/ufs2_stage1_5&amp;quot; exists ... yes&lt;br /&gt;
       Running &amp;quot;embed /boot/grub/ufs2_stage1_5 (hd0)&amp;quot;... 16 sectors embeded.&lt;br /&gt;
       succeeded&lt;br /&gt;
       Running &amp;quot;install /boot/grub/stage1 (hd0) (hd0)1+16 p &lt;br /&gt;
       (hd0,1,a)/boot/grub/stage2 /boot/grub/menu.lst&amp;quot;... succeeded&lt;br /&gt;
      ------------------------------------&lt;br /&gt;
&lt;br /&gt;
5. Finally how to generate md5-encrypted password:&lt;br /&gt;
   Enter any Grub command prompt:&lt;br /&gt;
   grub&amp;gt; md5crypt  /* call the md5 password encryption utility */&lt;br /&gt;
    password: yourDesiredPassword  /* passwd are replaced by same number of &amp;quot;*&amp;quot; */&lt;br /&gt;
    EncryptedPassword  /* encrypted password is returned here, put it in config file */&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Immessouane</name></author>	</entry>

	</feed>