Make a NanoBSD for GPT scheme on Freebsd9.0 RC1 + UEFI on VirtualBox

1. get freebsd 9.0 rc1, then install all srouce code

2. Install dmidecode ports on FreeBSD 9.0 RC1
    Path : /usr/local/sbin/dmidecode
  • # cd /usr/ports/sysutils/dmicode/
  • # make install clean
  • # ./usr/loacl/sbin/dmidecode | grep Name
    • Product Name : VirtualBox
3. Modify /usr/src/sys/amd64/amd64/machdep.c to add the string as follows
  • strncmp(sysenv, "VirtualBox", 10)  == 0 || 
4. Compile your kernel
  • # cd /sys/amd64/conf
  • # cp GENERIC NASBSD9
  • # ee NASBSD9
    • or put the file of NASBSD9 to /home/backup, and set soft link
      • #cd /usr/src/sys/amd64/conf
      • #ln -s /home/backup/NASBSD9
  • To compile your kernel
    • # cd /sys/amd64/conf
    • # config NASBSD9
    • # cd ../compile/NASBSD9
    • # make depend
    • # make
    • # make install
    • # reboot
    • # uname -a
5. Installing GRUB2
  1. Create an EFI system partition
    • On Ubuntu 11.10
      • $ apt-get install gdisk ufsutils
      • $ gdisk /dev/sdx 
      • EF00 
      • using 'gdisk' to partition an GPT format disk with an EFI system partition.
      • $ mkfs.vfat -F32 /dev/sdx1
    • On FreeBSD 8/9
      • # gpart create -s GPT /dev/adax








// ref to solve efi booting
// need to add product name from smibios, ex:VirtualBox
http://forums.freebsd.org/showthread.php?t=12198


//must to format FAT32 on flash disk in order to access EFI system for montherboard boot up.
mkfs.vfat -F32 /dev/sdc1

gpart create GPT /dev/ada0




build grub1.99 rc1


./configure LEX=/usr/local/bin/flex --with-platform=efi --target=x86_64
  • LEX=/usr/local/bin/flex
    • I installed the latest port (flex-2.5.35_4) from /usr/ports/textproc/flex
  • cd /usr/ports/lang/gcc44 
    • make install


----------------------------------------------------

// 宣告一塊虛擬memory disk -> md0
#mdconfig -a -t vnode -f _.disk.image

// 將_.disk.image 掛載在/mnt
#mount /dev/md0a /mnt

// 卸載 md0
#mdconfig -d -u 0

---------------------------------------------------

// Make a cpio+gz image
$find . | cpio -ocvB | gzip > /usr/src/tools/tools/nanobsd/nanobsd.cpio.gz

解壓縮
$gzip -dc folder1.cpio.gz | cpio -idv

------------------------------------------------------------------------

mkdir /tmp/ramdisk; chmod 777 /tmp/ramdisk
mount -t tmpfs -o size=256M tmpfs /tmp/ramdisk/

Read more: http://www.linuxscrew.com/2010/03/24/fastest-way-to-create-ramdisk-in-ubuntulinux/#ixzz1ciIwVOz3

虹光大成就-密教灌頂(一)