Fulfilling a dream.

Since I’ve heard about invention of IA-64 architecture in 2002, I was interested in everything its box comes with, be it Itanium CPU, EFI firmware, or GPT disk partioning. It was always my dream to play with those things. Itanium was too expensive and most of the humans I’ve worked with never have any need to use it. So I’ve never worked with the physical CPU but just played a bit with ski . My life’s first server came with an EFI boot method, but being a n00b at that time, I was not able to configure it to boot with elilo which felt quite frustrating at that time. And now on 29th July, 2009, I decided to give GPT partitions a shot on my AMD64 box (Intel DG35EC mobo ++ Intel Core 2 Duo CPU) as I’m plugging in my new 500 GiB disk. There is no problem with disks partitioning with GPT as all of the operating systems I use (GNU/Linux, FreeBSD and GNU Emacs) have no problem reading/writing to it :). So the only problem is booting a disk formatted with GPT as I’ve a BIOS based mobo. I’d an idea how that is going to be, but I’m not sure if there are any FOSS boot loders that are able to boot in this way. Since I use GRUB, I asked my friend (google) if he knows anything about GRUB and GPT. And it revealed that GRUB2 has support for GPT, i.e. grub-install detects at runtime if it is installed on GPT disk. 🙂
With the help of the search results, GRUB2, GPT fdisk (or gdisk), phcoder on #grub and software repository of Arch GNU/Linux distribution, I’m able to boot from my GPT disk.

% sudo gdisk -l /dev/sdb
GPT fdisk (gdisk) version 0.2.0

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdb: 976773168 sectors, 465.8 GiB
Disk identifier (GUID): FADB3815-91DF-4134-8492-E6FE33A3162E
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Total free space is 93345773 sectors (44.5 GiB)

Number  Start (block)     End (block)  Size        Code  Name
   1              34            2081   1024.0 KiB  EF02  BIOS boot
   2            2082       125831201   60.0 GiB    0700  GNU/Linux root
   3       125831202       134219809   4.0 GiB     A503  FreeBSD-root
   4       134219810       142608417   4.0 GiB     A502  swap
   5       142608418       143132705   256.0 MiB   0700  GNU/Linux boot
   6       143132706       252184609   52.0 GiB    A503  FreeBSD-home
   7       252184610       378013729   60.0 GiB    0700  GNU/Linux home
   8       378013730       380110881   1024.0 MiB  0700  news spool
   9       380110882       883427361   240.0 GiB   0700  archives
% sed -e '/^#/d' -e '/^[[:space:]]*$/d' </boot/grub/grub.cfg
1insmod gpt
set default=0
set timeout=10
set root=(hd1,2)
search --no-floppy --fs-uuid --set 6ad9832e-6241-4adc-b67b-3829cd1a2942
if loadfont /usr/share/grub/ascii.pf2 ; then
  set gfxmode=1024x768
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
menuentry "Arch GNU/Linux" {
        set root=(hd0,5)
        linux /vmlinuz26 root=/dev/sdb2 ro vga=0x0f00
        initrd /kernel26.img
}
menuentry "Arch GNU/Linux (fallback)" {
        set root=(hd0,5)
        linux /vmlinuz26 root=/dev/sdb2 ro vga=0x0f00
        initrd /kernel26-fallback.img
}
insmod bsd
menuentry "FreeBSD 7.2-RELEASE" {
        set root=(hd0,3)
        freebsd /boot/kernel/kernel
        freebsd_loadenv /boot/device.hints
        freebsd_module_elf /boot/kernel/coretemp.ko
        freebsd_module_elf /boot/kernel/geom_journal.ko
        set FreeBSD.vfs.root.mountfrom=ufs:ad6p3.journal
}

RIP MBR based partitioning. 🙂

Note: Intel BIOS requires a partition to be marked as active in MBR in order to be able to boot from that disk.

Advertisements

8 Comments

  1. Jedediah Frey
    Posted 20100129 at 174039 | Permalink | Reply

    The command in the latest version of grub2 (at least on Debian distributions that I use) has changed to ‘kfreebsd’. Meaning everywhere you have ‘freebsd’ it should be changed to ‘kfreebsd’.

    kfreebsd /boot/kernel/kernel
    kfreebsd_loadenv /boot/device.hints

    Found this after wondering why no ones instructions on the internet worked and doing a ‘strings bsd.mod’ on the grub module.

    • Posted 20100129 at 204042 | Permalink | Reply

      Hi Jedediah,

      Thanks for your comment. I’m still running old GRUB2 which has that. But this seriously braindead on Debian/GRUB2 side. WTF, they’re modifying things so much that normal documentation didn’t apply anymore.

      • Jedediah Frey
        Posted 20100130 at 162856 | Permalink

        It looks like it’s not just in the Debian version. I downloaded the latest version of 1.97.2 from Grub2’s website sure enough in the source was this:

        cmd_freebsd = grub_register_extcmd (“kfreebsd”, grub_cmd_freebsd,
        GRUB_COMMAND_FLAG_BOTH,
        “kfreebsd FILE”, “Load kernel of FreeBSD.”,
        freebsd_opts);
        cmd_openbsd = grub_register_extcmd (“kopenbsd”, grub_cmd_openbsd,
        GRUB_COMMAND_FLAG_BOTH,
        “kopenbsd FILE”, “Load kernel of OpenBSD.”,
        openbsd_opts);
        cmd_netbsd = grub_register_extcmd (“knetbsd”, grub_cmd_netbsd,
        GRUB_COMMAND_FLAG_BOTH,
        “knetbsd FILE”, “Load kernel of NetBSD.”,
        netbsd_opts);

  2. 762e5e74
    Posted 20100130 at 173253 | Permalink | Reply

    And it looks like they’re trying to distinguish between OS from the kernel[1].

    [1] – http://lists.gnu.org/archive/html/commit-grub/2009-10/msg00012.html

  3. ph
    Posted 20100131 at 205718 | Permalink | Reply

    Hi 762e5e74,

    you see to know a hell of a lot about a lot of things,,,,,,

    could you tell me how you learnt about these things – process of booting up an OS and
    what must i read to understand this post of yours!

    i also dont know my way around wordpress so couldn’t find out about your profession but i assume it has something to do with system administration?

  4. 762e5e74
    Posted 20100202 at 052927 | Permalink | Reply

    Hi ph,

    Yeah, I prefer to call myself CS student, rather than SysAdmin :).

    Ignorance is not bliss.

    • ph
      Posted 20100202 at 061850 | Permalink | Reply

      all right then CS student,

      coming back to my original question,

      do you recommend any particualr books, hands on training etc to a guy who is interested in learning about System programming, OS fundamentals and possibly in linux/ or windows even – i’m not picky!

  5. Posted 20100524 at 153724 | Permalink | Reply

    Another reason why I think someone (me?) needs to redo sysinstall in BSD. Its old and ugly…

One Trackback

  1. […] !archlinux !grub #gpt #grub2 !freebsd https://762e5e74.wordpress.com/2009/08/03/fulfilling-a-dream/ […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: