顯示具有 GRUB2 標籤的文章。 顯示所有文章
顯示具有 GRUB2 標籤的文章。 顯示所有文章

How to develop and integrate brand new module into GRUB2?

Step 1. Need to modify Makefile.core.am & Makefile.core.def to include your new module.
            to see how to do this, search in Makefile.core.am & Makefile.core.def for "hello" module.

Step 2. Install m4-1.4.6
$ wget ftp://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz                                                                                              
$ tar -zxvf m4-1.4.6.tar.gz                                                                                                                                
$ ./configure                                                                                                                                                                                                
$ ./make                                                                                                                                                                                                
$ ./make install                                                                                                                                                                                                

Step 3. Install package
$ apt-get install autoconf automaker1.11 autogen                                                                                     

Step 4. Run autogen.sh
 $ cd ./grub-2.00                                                                                                                                                          
 $ ./autogen                                                                                                                                                                     

Step 5. Make & Make install
$  cd ./grub-2.00                                                                                                                                            
$ ./configure --prefix=/home/gary/gy-grub/grub-2.00/XXX                                                                        
$ ./make                                                                                                                                                      
$ ./make install                                                                                                                                                                               

note:
$ update-grub

Combine GRUB2, GPT, UEFI and NanoBSD on Ubuntu 11.04 ?


1. Installing Ubuntu 11.04
  • please change sources.list with apt-get install from ... 
  • tw.archive.ubuntu.com  ->  mirror.nttu.edu.tw
2. Installing ufsutils/gdisk package ...

  • apt-get install ufsutils
  • apt-get install gdisk
3. Partition your hard drive
  • my plan as follows.
    • /dev/sdb1 -> EFI system partition "EF00"
    • /dev/sdb2 -> NanoBSD #1 "A500"
    • /dev/sdb3 -> NanoBSD #1 "A500"
    • /dev/sdb4 -> Data "A503"
  • gdisk /dev/sdb 
  • ...
  • mkfs.vfat -F32 /dev/sdb1
  • mkfs.ufs -O 2 /dev/sdb2
  • mkfs.ufs -O 2 /dev/sdb3
  • mkfs.ufs -O 2 /dev/sdb4
4. Mount EFI system partition
  • mkdir /boot/efi
  • mount /dev/sdb1 /boot/efi
  • mkdir -p /boot/efi/efi
5. Install grub for efi
  • apt-get install grub-efi-amd64
6. Setup your grub2 into the EFI system partition
  • modprobe dm-mod
  • grub-install --boot-directory=/boot/efi/efi --bootloader-id=GRUB2 --no-floppy --recheck
  • cp /usr/share/grub/unicode.pf2 /boot/efi/efi/grub/
  • cp /boot/grub/grub.cfg /boot/efi/efi/grub/grub.cfg
    • grub.cfg context as follows.
      • insmod ufs2
      • set root='(hd0,1,a)'
      • search --no-floppy --fs-uuid --set 4ea7f1272cbdb23e
      • echo Loading kernel of FreeBSD kernel ...
      • kfreebsd /boot/kernel/kernel
      • kfreebsd_loadenv /boot/device.hints
      • set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a
      • set kFreeBSD.vfs.root.mountfrom.options=rw
      • ...
7. Copy my old grub.cfg and seting up the EFI boot entry.
  • modprobe efivars
  • efibootmgr --create --gpt --disk /dev/sdb --part 1 --write-signature --label "GRUB2" --loader "\\EFI\\grub\\grub.efi"
note. GRUB2 is the entry that would appear on the EFI bootloader










Linux_Windows_BIOS_UEFI_boot_USB


https://gitorious.org/tianocore_uefi_duet_builds/pages/Linux_Windows_BIOS_UEFI_boot_USB



Manual setup of UEFI, GPT and GRUB2

http://jkyamog.blogspot.com/2011/09/manual-setup-of-uefi-gpt-and-grub2.html

Manual setup of UEFI, GPT and GRUB2


Ref: http://jkyamog.blogspot.com/2011/09/manual-setup-of-uefi-gpt-and-grub2.html


Manual setup of UEFI, GPT and GRUB2

I recently got a Crucial m4.  I then have to transfer my existing HDD on it.  Its easier to do a clean install of Oneiric and it would pretty much do UEFI + GPT + GRUB2 for you.  However if you want to manually transfer everything I did the following steps:

  • Boot on Oneiric live CD or another boot this that will boot in UEFI mode. Its important that boot is on UEFI mode and not BIOS mode
  • Go to a shell and install gdisk as we want to partition the SSD w/ GPT and not MBR. fdisk only supports MBR
    apt-get install gdisk
    
  • Partition a EFI system partition.  This would hold grub2 files later and other boot loaders if needed.  I partitioned mine on sda1 as type EF00 (EFI System) w/ the size of 200mb.  Yes a bit bigger than what is needed however most people recommend 200mb as some boot loaders needs a bigger space.
  • Format the partitions.  The EFI System partition is formatted as vfat, as per EFI spec.
    mkfs.vat /dev/sda1
    mkswap /dev/sda2
    mkfs.ext4 -E stripe-width=128 /dev/sda3
    mkfs.ext4 -E stripe-width=128 /dev/sda4
    
    I put in a stripe width of 128 k as there are some recommendation this is optimal for SSD. However test suggest that your mileage may vary.
  • Mount and create the dirs on EFI system partition
    mkdir /boot/efi
    mount /dev/sda1 /boot/efi
    mkdir -p /boot/efi/efi
  • Install grub efi
    apt-get install grub-efi-amd64
    
  • Setup grub on the EFI system partition
    modprobe dm-mod
    grub-install --boot-directory=/boot/efi/efi --bootloader-id=GRUB2 --no-floppy --recheck
    cp /usr/share/grub/unicode.pf2 /boot/efi/efi/grub/
    cp /boot/grub/grub.cfg /boot/efi/efi/grub/grub.cfg
    
    I copied my old grub.cfg and update the UUID to point to the new SSD
  • Setup the EFI boot entry
    modprobe efivars
    efibootmgr --create --gpt --disk /dev/sda --part 1 --write-signature --label "GRUB2" --loader "\\EFI\\grub\\grub.efi"
    
    GRUB2 is the entry that would appear on the EFI bootloader.
The following resource helped me a lot
https://help.ubuntu.com/community/UEFIBooting#Install_GRUB2_in_.28U.29EFI_systems

I am still working out on the graphics output,  This would only give you a text based grub.

How to install GRUB2 into flash on FreeBSD

1. Setup GRUB package
gy# cd /usr/ports/sysinstall/grub2
gy# make install clean

2. fdisk&newfs three partition in a flash as follows.
da0
da0s1
da0s2
da0s3

gy# newfs /dev/da0s3

3. Create folder "/boot/grub"
gy# mkdir /mnt/da0
gy# mount /dev/da0s3d /mnt/da0

// gy# mkdir /mnt//boot
// gy# mkdir /mnt/boot/grub

4. install GRUB2 into da0
// cp -r /boot/grub/* /mnt/boot/grub
// copy
gy# grub-install --root-directory=/mnt/da0 /dev/da0  
or
gy# grub-install --modules=ufs2 /dev/da0
gy# grub-mkconfig -o /mnt/da0/boot/grub/grub.cfg
//gy# grub-setup /dev/da0





Note that. please type as follows command if show of grub rescue >
grub rescue>set root=hd0,2,d
grub rescue>prefix=(hd0,2,d)/boot/grub
grub rescue>insmod normal
grub rescue>normal

GRUB2 rescue

grub rescue>

grub rescue>set
prefix=(hd0,6)/boot/grub
root=hd0,6

grub rescue>ls
(hd0), (hd0,1), (hd0,2), (hd0,3), (hd0,5)
grub rescue>set root=(hd0,1)
grub rescue>set prefix=(hd0,1)/boot/grub
grub rescue>insmod normal
rescue:grub>normal





  • Modify : /boot/grub/grub.cfg
    • Excute update-grub to modify menu
    • sudo update-grub

  • Reinstall grub
    • sudo grub-install /dev/sda

Testing GRUB 2 on your GPT-partitioned flash drive


I did a quick test, and you can, too.  I'll explore this some more after GRUB 2 and 9.10 are finalized.

Here's my summary.

OS:   Kubuntu 9.10 alpha 6 (which uses the latest version of GRUB 2 (1.97x).
Bootloader:  GRUB 2 (beta)
Disk device:  1 GB Kingston USB flash drive
Motherboard:  Intel DG33FBC; Intel D915GAVL
Disk partition utility:   GParted Live CD, current version

Steps:

1   Boot into Kubuntu

2   Open Konsole (Terminal program)

3   Optional:  Zero-out your flash drive
THIS WILL DESTROY ALL DATA ON THE FLASH DRIVE.
This writes zeros to the entire flash drive and restores it to factory-new condition.
Find out how Kubuntu sees your flash drive:
sudo fdisk -lu
Let's say, for this example, it is /dev/sdc.
Use the dd command to write zeros to the entire flash drive:
sudo dd if=/dev/zero  of=/dev/sdc
(You will not see any progress meter or output until it finishes.  It took approximately 7 minutes on my system.)

4  Partition the flash drive using GParted Live CD
You can also do this using an installed gparted (Partition Editor).
Tip:  While in GParted Live CD, remember that you have access to a terminal if you need one (for dd, or sudo fdisk -lu): double-click Terminal icon at top.  For root, simply use sudo in front of commands.

I partitioned as follows:

Plug in the flash drive, click Devices > Refresh (you may have do it more than once until the flash drive appears in the drop-down list of drives at the upper right or under GParted > Devices).
You'll get a message that a Disklabel must be set on the disk and asked if you want the (default) msdos  Disklabel.  (You will also get this message if you highlight unallocated space and click Partition > New).  You don't want msdos, so click the Advanced button and select gpt, then Create.

Partitions:

Partition 1:  BIOS Boot partition
8 MB (the minimum size offered), FAT32, for the BIOS Boot partition (embedding core.img).
Set a flag:  Partition > Manage flags, then check the bios_grub box (as the tag).
Set a Label on the partition to remind you what it is:
Partition > Label, and I typed BIOS_BOOT as the label.

Partition 2:  For setting up the GRUB 2 files in /boot/grub
10 MB, ext2
Also, set the boot flag on this partition to make it the active partition:
Partition > Manage flags > check the boot box.
Set a label on the partition to remind you what it is:
Partition > Label, and type GRUB_FILES as the label.

Partition 3:  A for-fun extra test partition for the heck of it.  (In another test, I also tested creating 10 partitions, and it went well under GPT.)
200 GB, ext2

5  Install GRUB 2 to the flash drive
Exit GParted Live CD, remove the CD and the flash drive, reboot into your regular Kubuntu.
Plug in the flash drive.  See how it is mounted (or go into Dolphin and click on the second partition GRUB_FILES to mount it).  Open Konsole. install GRUB 2 to the flash drive, setting up the GRUB 2 files in the second partition (GRUB_FILES) and installing the bootloader (boot.img = 512 bytes) to the MBR of the flash drive.
Example:
Suppose the second partition is mounted as /media/GRUB_FILES and suppose the flash drive is seen as /dev/sdc in Kubuntu (use sudo fdisk -lu to find out).  Then install GRUB 2 to it as follows:
sudo grub-install --root-directory=/media/GRUB_FILES  /dev/sdc
If it doesn't go, do it again with --recheck:
sudo grub-install --recheck --root-directory=/media/GRUB_FILES /dev/sdc

6  Re-booting from the flash drive:
Make sure your BIOS is set to boot from USB and configure BIOS to boot from your flash drive.
If you re-boot starting from your Kubuntu session, keep the flash drive plugged in (but click Safely Remove to unmount it), reboot the PC, enter BIOS setup, configure BIOS to boot from USB and put the flash drive at the top of the drive list, F10 to Save & Exit, and re-boot from the flash drive.  After the POST, you should see the GRUB 2 prompt (coming from the GRUB 2 on the flash drive): grub>.  (You get the GRUB prompt grub>  since there is no boot menu  (/boot/grub/grub.cfg) configured.)  You can use this grub prompt to boot into one of your OSs; or simply shutdown the PC (grub>halt) and remove the flash drive; or re-boot (grub>reboot), enter BIOS setup, remove the flash drive, set BIOS to boot from your regular drive, F10 to save this change and exit to reboot from your regular drive.

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