R.A. Epigonos et al.

[linux] grubのディスクを作る

ブートローダであるgrubのディスクをinstall-grubを使わずに作成してみる。

フロッピーディスクのフォーマットとファイルシステムの作成。

% fdformat /dev/fd0
Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.
Formatting ... done
Verifying ... done
% mkfs.ext2 -c /dev/fd0
mke2fs 1.42.3 (14-May-2012)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
184 inodes, 1440 blocks
72 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=1572864
1 block group
8192 blocks per group, 8192 fragments per group
184 inodes per group

badblocks: Device or resource busy while trying to open /dev/fd0
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

マウントして、ディレクトリを作成して、必要なファイルをコピー

% mount /dev/fd0 /mnt/floppy
% mkdir -p /mnt/floppy/boot/grub/
% cp /boot/grub/stage1 /boot/grub/stage2 /boot/grub/*stage1_5 /mnt/floppy/boot/grub

menu.listの編集

% cat /mnt/floppy/boot/grub/menu.lst
timeout=none
title "Linux Mint 13 hdd"
        insmod part_msdos
        insmod ext2
        root (hd1,msdos1)
        loopback loop /linuxmint-13-mate-dvd-32bit.iso
        linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/linuxmint-13-mate-dvd-32bit.iso noeject noprompt
        initrd (loop)/casper/initrd.lz

menu.listの内容を元にMBRに書き込み

% umount /mnt/floppy
% grub


    GNU GRUB  version 0.97  (640K lower / 5120K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]

grub> root
 Possible commands are: root rootnoverify

grub> root (fd0)
 Filesystem type is ext2fs, using whole disk

grub> setup (fd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (fd0)"... failed (this is not fatal)
 Running "embed /boot/grub/e2fs_stage1_5 (fd0)"... failed (this is not fatal)
 Running "install /boot/grub/stage1 (fd0) /boot/grub/stage2 p /boot/grub/menu.lst "... succeeded
Done.

grub> quit

このフロッピーで起動するとメニューが現れる。インストールされているのはgrub2ではないため、grub2からの機能(loopback等)を含む上の設定ファイルでは起動しない。

リファレンス

  1. GPTからMBRへの変更 - 間違いだらけの備忘録

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-06-01T20:32:29+09:00
  2. Modified: 2010-06-01T20:32:29+09:00
  3. Generated: 2023-08-27T23:09:16+09:00