「GRUB Legacy」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
 
(2人の利用者による、間の6版が非表示)
8行目: 8行目:
 
[[fr:GRUB]]
 
[[fr:GRUB]]
 
[[he:GRUB]]
 
[[he:GRUB]]
[[id:GRUB2]]
+
[[id:GRUB]]
 
[[it:GRUB Legacy]]
 
[[it:GRUB Legacy]]
 
[[nl:GRUB]]
 
[[nl:GRUB]]
 
[[ru:GRUB Legacy]]
 
[[ru:GRUB Legacy]]
[[tr:Grub]]
+
[[zh-hans:GRUB Legacy]]
[[uk:GRUB]]
+
[[zh-hant:GRUB]]
[[zh-CN:GRUB Legacy]]
 
[[zh-TW:GRUB2]]
 
 
{{Related articles start}}
 
{{Related articles start}}
 
{{Related|Arch ブートプロセス}}
 
{{Related|Arch ブートプロセス}}
 
{{Related|ブートローダー}}
 
{{Related|ブートローダー}}
 
{{Related|ブートデバッグ}}
 
{{Related|ブートデバッグ}}
{{Related3|Grub-Legacy-gfx|grub-gfx}}
 
 
{{Related|カーネルパラメータ}}
 
{{Related|カーネルパラメータ}}
 
{{Related articles end}}
 
{{Related articles end}}
   
[http://www.gnu.org/software/grub/grub-legacy.html GRUB Legacy] は [[GNU プロジェクト]]によってメンテナンスされていた [http://www.gnu.org/software/grub/manual/multiboot/ マルチブート] ブートローダーです。Erich Stefan Boleyn によって設計・実装された GRUB (GRand Unified Bootloader) から由来しています。
+
[https://www.gnu.org/software/grub/grub-legacy.html GRUB Legacy] は [[GNU プロジェクト]]によってメンテナンスされていた [https://www.gnu.org/software/grub/manual/multiboot/ マルチブート] ブートローダーです。Erich Stefan Boleyn によって設計・実装された GRUB (GRand Unified Bootloader) から由来しています。
   
 
''ブートローダー''とはコンピューターが起動した時に最初に走るプログラムです。Linux カーネルをロードして制御を移行する役割を担っています。バトンを受け取ったカーネルは、オペレーティングシステムを初期化します。
 
''ブートローダー''とはコンピューターが起動した時に最初に走るプログラムです。Linux カーネルをロードして制御を移行する役割を担っています。バトンを受け取ったカーネルは、オペレーティングシステムを初期化します。
   
{{Warning|GRUB Legacy は上流のメンテナンスをもはや受けておらず Arch でも公式にサポートは打ち切られています (ニュースを見て下さい: [https://www.archlinux.org/news/grub-legacy-no-longer-supported/])。GRUB ユーザーは [[GRUB]](2) または [[Syslinux]] に切り替えることが推奨されています。[[#GRUB2 へのアップグレード|GRUB2 へのアップグレード]]を参照。}}
+
{{Warning|GRUB Legacy は上流のメンテナンスをもはや受けておらず Arch でも公式にサポートは打ち切られています (ニュースを見て下さい: [https://www.archlinux.jp/news/grub-legacy-no-longer-supported/])。GRUB ユーザーは [[GRUB]](2) または [[Syslinux]] に切り替えることが推奨されています。[[#GRUB2 へのアップグレード|GRUB2 へのアップグレード]]を参照。}}
   
 
{{Note|システムに grub-legacy の grub-0.97 パッケージをインストールしている場合、パッケージアップデートによって {{Pkg|grub}}-2.xx パッケージ (GRUB2) に更新されます。grub-legacy を使いたい場合 {{AUR|grub-legacy}} をインストールすればパッケージは衝突しません。アップデート {{ic|/usr/lib/grub/}} のファイルが更新され、grub-legacy のファイルが {{ic|/boot/grub}} にインストールされます。{{ic|MBR}} は削除されません。{{ic|/boot/grub/menu.lst.pacsave}} を {{ic|/boot/grub/menu.lst}} に名前を変更することで grub-legacy に戻すことができます。
 
{{Note|システムに grub-legacy の grub-0.97 パッケージをインストールしている場合、パッケージアップデートによって {{Pkg|grub}}-2.xx パッケージ (GRUB2) に更新されます。grub-legacy を使いたい場合 {{AUR|grub-legacy}} をインストールすればパッケージは衝突しません。アップデート {{ic|/usr/lib/grub/}} のファイルが更新され、grub-legacy のファイルが {{ic|/boot/grub}} にインストールされます。{{ic|MBR}} は削除されません。{{ic|/boot/grub/menu.lst.pacsave}} を {{ic|/boot/grub/menu.lst}} に名前を変更することで grub-legacy に戻すことができます。
 
}}
 
}}
  +
  +
== サポートされているファイルシステム ==
  +
  +
GRUB Legacy は、[https://www.gnu.org/software/grub/manual/legacy/grub.html#Features 複数のファイルシステム] (特に [[FAT32]]、[[Wikipedia:ja:ext2|ext2]]、[[Wikipedia:ja:ReiserFS|ReiserFS]]、[[XFS]] (v4 のみ)) に対する独自のサポートがあります。
  +
  +
{{Warning|ファイルシステムには、GRUB Legacy がまだ対応していない新しい機能が導入されることがあります。その場合、GRUB Legacy と互換性の無い機能を無効化しない限り、そのファイルシステムを {{ic|/boot}} に対して使用するべきではありません。この問題は、[[パーティショニング#/boot|/boot パーティション]]を別に分けて、[[FAT32]] などの広くサポートされているファイルシステムを使用することで、回避することができます。}}
   
 
== インストール ==
 
== インストール ==
212行目: 215行目:
 
GRUB では複数のインスタンスが存在する可能性があるので (マルチブート環境)、GRUB のファイルがシステムのどこにあるのか指定する必要があります。GRUB のファイルは専用のパーティションである {{ic|/boot}} 下にあります。
 
GRUB では複数のインスタンスが存在する可能性があるので (マルチブート環境)、GRUB のファイルがシステムのどこにあるのか指定する必要があります。GRUB のファイルは専用のパーティションである {{ic|/boot}} 下にあります。
   
  +
{{Note|GRUB は一般的なカーネルの命名規則と異なった方法でストレージデバイスを定義します:
{{Note|GRUB defines storage devices differently than conventional kernel naming does.
 
   
 
* ハードディスクは ''(hdX)'' と定義されます。USB ストレージデバイスを示すこともあります。
 
* ハードディスクは ''(hdX)'' と定義されます。USB ストレージデバイスを示すこともあります。
221行目: 224行目:
 
# grub
 
# grub
   
  +
以下は {{ic|/boot}} が別パーティションとなっておらず単に {{ic|/}} 下のディレクトリである場合の例です:
The following example is for systems ''without'' a separate {{ic|/boot}} partition, wherein {{ic|/boot}} is merely a directory under {{ic|/}}:
 
   
 
grub> find /boot/grub/stage1
 
grub> find /boot/grub/stage1
   
  +
以下は {{ic|/boot}} パーティションが分割されている場合の例です:
The following example is for systems ''with'' a separate {{ic|/boot}} partition:
 
   
 
grub> find /grub/stage1
 
grub> find /grub/stage1
   
  +
GRUB はファイルを見つけたら {{ic|stage1}} ファイルの場所を出力します。例:
GRUB will find the file, and output the location of the {{ic|stage1}} file. For example:
 
 
{{hc|grub> find /grub/stage1|
 
{{hc|grub> find /grub/stage1|
 
(hd0,0)}}
 
(hd0,0)}}
   
  +
上記の値を設定ファイルの {{ic|root}} 行に入力してください。{{ic|quit}} と入力するとシェルが終了します。
This value should be entered on the {{ic|root}} line in your configuration file. Type {{ic|quit}} to exit the shell.
 
   
 
=== Windows とのデュアルブート ===
 
=== Windows とのデュアルブート ===
   
以下を {{ic|/boot/grub/menu.lst}} の最後に追記してください (assuming that your Windows partition is on the first partition of the first drive):
+
以下を {{ic|/boot/grub/menu.lst}} の最後に追記してください (Windows パーティションが一番目のドライブの一番目のパーティションにある場合):
   
 
{{hc|/boot/grub/menu.lst|<nowiki>
 
{{hc|/boot/grub/menu.lst|<nowiki>
247行目: 250行目:
   
 
{{Note|
 
{{Note|
  +
* Windows 7 とデュアルブートする場合、{{ic|makeactive}} 行はコメントアウトしてください。
* If you are attempting to dual-boot with Windows 7, you should comment out the line {{ic|makeactive}}.
 
* Windows 2000 and later versions do NOT need to be on the first partition to boot (contrary to popular belief). If the Windows partition changes (i.e. if you add a partition before the Windows partition), you will need to edit the Windows {{ic|boot.ini}} file to reflect the change (see [http://vlaurie.com/computers2/Articles/bootini.htm this article] for details on how to do that).
+
* Windows 2000 以上では起動するパーティションが必ずしも最初のパーティションとは限りません。Windows のパーティションが二番目以降の場合、Windows {{ic|boot.ini}} ファイルを編集して変更を加える必要があります (詳しくは [http://vlaurie.com/computers2/Articles/bootini.htm この記事] を参照)
 
}}
 
}}
   
  +
Windows が他のハードディスクにある場合、{{ic|map}} コマンドを使って下さい。Windows が一番目のドライブにあるかのように思わせます。Windows パーティションが二番目のドライブの一番目のパーティションにある場合:
If Windows is located on another hard disk, the {{ic|map}} command must be used. This will make your Windows install think it is actually on the first drive. Assuming that your Windows partition is on the first partition of the second drive:
 
   
 
{{hc|/boot/grub/menu.lst|<nowiki>
 
{{hc|/boot/grub/menu.lst|<nowiki>
262行目: 265行目:
 
</nowiki>}}
 
</nowiki>}}
   
  +
{{Note|Windows 7 とデュアルブートする場合、{{ic|makeactive}} 行はコメントアウトしてください。}}
{{Note|If you are attempting to dual-boot with Windows 7, you should comment out the line {{ic|makeactive}}.}}
 
   
 
=== GNU/Linux とのデュアルブート ===
 
=== GNU/Linux とのデュアルブート ===
   
  +
Arch Linux を定義するときと同じです。例:
This can be done the same way that an Arch Linux install is defined. For example:
 
 
{{hc|/boot/grub/menu.lst|<nowiki>
 
{{hc|/boot/grub/menu.lst|<nowiki>
 
title Other Linux
 
title Other Linux
278行目: 281行目:
 
=== chainloader と configfile ===
 
=== chainloader と configfile ===
   
  +
システムメンテナンスを楽にするために、"automagic" GRUB 設定機構を提供している他の Linux ディストリビューション (例: Debian, Ubuntu, openSUSE) を起動する時は {{ic|chainloader}} または {{ic|configfile}} コマンドを使って下さい。これによってディストリビューションは自ら {{ic|menu.lst}} とブートオプションを管理できるようになります。
To facilitate system maintenance, the {{ic|chainloader}} or {{ic|configfile}} command should be used to boot another Linux distribution that provides an "automagic" GRUB configuration mechanism (e.g. Debian, Ubuntu, openSUSE). This allows the distribution to manage its own {{ic|menu.lst}} and boot options.
 
   
  +
* {{ic|chainloader}} コマンドは (カーネルイメージ以外の) 他のブートローダーをロードします。パーティションのブートセクタに他のブートローダーをインストールしている場合に有用です (例えば GRUB)。GRUB のメインインスタンスを [[Master Boot Record|MBR]] にインストールして、ディストリビューションごとの GRUB のインスタンスをパーティションブートレコード (PBR) にインストールできます。
* The {{ic|chainloader}} command will load another bootloader (rather than a kernel image); useful if another bootloader is installed in a partition's boot sector (GRUB, for example). This allows one to install a "main" instance of GRUB to the [[Master Boot Record|MBR]] and distribution-specific instances of GRUB to each partition boot record (PBR).
 
   
  +
* {{ic|configfile}} コマンドは指定した設定ファイルをロードするように実行中の GRUB インスタンスに指示します。このコマンドを使うことで GRUB を別個にインストールすることなく他のディストリビューションの {{ic|menu.lst}} をロードすることができます。ただし欠点として {{ic|menu.lst}} がインストールしている GRUB のバージョンに対応していない可能性があります。一部のディストリビューションは GRUB に独自パッチをあてまくっています。
* The {{ic|configfile}} command will instruct the currently running GRUB instance to load the specified configuration file. This can be used to load another distribution's {{ic|menu.lst}} without a separate GRUB installation. The caveat of this approach is that other {{ic|menu.lst}} may not be compatible with the installed version of GRUB; some distributions heavily patch their versions of GRUB.
 
   
For example, GRUB is to be installed to the [[Master Boot Record|MBR]] and some other bootloader (be it GRUB or [[LILO]]) is already installed to the boot sector of {{ic|(hd0,2)}}.
+
例えば、GRUB [[Master Boot Record|MBR]] をインストールして他のブートローダー (GRUB [[LILO]]) {{ic|(hd0,2)}} のブートセクタにインストールされている場合:
   
 
---------------------------------------------
 
---------------------------------------------
297行目: 300行目:
 
-----------------------------
 
-----------------------------
   
  +
{{ic|menu.lst}} に以下のように記述できます:
One can simply include in {{ic|menu.lst}}:
 
   
 
title Other Linux
 
title Other Linux
303行目: 306行目:
 
chainloader +1
 
chainloader +1
   
Or, if the bootloader on {{ic|(hd0,2)}} is GRUB:
+
もしくは {{ic|(hd0,2)}} のブートローダーが GRUB の場合:
   
 
title Other Linux
 
title Other Linux
309行目: 312行目:
 
configfile /boot/grub/menu.lst
 
configfile /boot/grub/menu.lst
   
The {{ic|chainloader}} command can also be used to load the MBR of a second drive:
+
{{ic|chainloader}} コマンドを使って二番目のドライブの MBR をロードすることもできます:
   
 
title Other drive
 
title Other drive
315行目: 318行目:
 
chainloader +1
 
chainloader +1
   
=== Dual booting with GNU/Linux (GRUB2) ===
+
=== GNU/Linux とのデュアルブート (GRUB2) ===
   
If the other Linux distribution uses GRUB2 (e.g. Ubuntu 9.10+), and you installed its boot loader to its root partition, you can add an entry like this one to your {{ic|/boot/grub/menu.lst}}:
+
他の Linux ディストリビューションが GRUB2 を使っていて (例: Ubuntu 9.10+)、ブートローダーを root パーティションにインストールしている場合、{{ic|/boot/grub/menu.lst}} に以下のようにエントリを追加することができます:
 
{{hc|/boot/grub/menu.lst|<nowiki>
 
{{hc|/boot/grub/menu.lst|<nowiki>
 
# other Linux using GRUB2
 
# other Linux using GRUB2
325行目: 328行目:
 
</nowiki>}}
 
</nowiki>}}
   
  +
起動時にこのエントリを選択すると他のディストリビューション ({{ic|/dev/sda3}}) の GRUB2 メニューがロードされます。
Selecting this entry at boot will load the other distribution's GRUB2 menu assuming that the distribution is installed on {{ic|/dev/sda3}}.
 
   
  +
== ブートローダーのインストール ==
== Bootloader installation ==
 
   
  +
=== GRUB ライブラリの手動リカバリ ===
=== Manual recovery of GRUB libs ===
 
   
  +
{{ic|*stage*}} ファイルは通常 {{ic|/boot/grub}} に保存されますが、システムのインストール時にブートローダーをインストールしなかった場合や、パーティションやファイルシステムが破損した場合は存在しないことがあります。
The {{ic|*stage*}} files are expected to be in {{ic|/boot/grub}}, which may not be the case if the bootloader was not installed during system installation or if the partition/filesystem was damaged, accidentally deleted, etc.
 
   
  +
以下のように手動で GRUB のライブラリをコピーしてください:
Manually copy the GRUB libs like so:
 
 
# cp -a /usr/lib/grub/i386-pc/* /boot/grub
 
# cp -a /usr/lib/grub/i386-pc/* /boot/grub
   
 
{{Note|Do not forget to mount the system's boot partition if your setup uses a separate one! The above assumes that either the boot partition resides on the root filesystem or is mounted to /boot on the root file system!}}
 
{{Note|Do not forget to mount the system's boot partition if your setup uses a separate one! The above assumes that either the boot partition resides on the root filesystem or is mounted to /boot on the root file system!}}
   
  +
=== ブートローダーのインストールに関する注意事項 ===
=== General notes about bootloader installation ===
 
   
  +
GRUB は別のメディア (例: ライブ CD) からインストールしたり、起動中の Arch 環境から直接インストールできます。GRUB ブートローダーを再インストールしなくてはならない場合は滅多にありません。以下のような場合に再インストールは不要です:
GRUB may be installed from a separate medium (e.g. a LiveCD), or directly from a running Arch install. The GRUB bootloader is ''seldom'' required to be reinstalled and installation is ''not'' necessary when:
 
   
  +
* 設定ファイルを更新するとき。
* The configuration file is updated.
 
* The {{AUR|grub-legacy}} package is updated.
+
* {{AUR|grub-legacy}} パッケージをアップデートするとき。
   
  +
インストールが必要なのは以下のような場合です:
Installation is ''necessary'' when:
 
   
  +
* ブートローダーをまだインストールしていないとき。
* A bootloader is not already installed.
 
  +
* 他のオペレーティングシステムによって Linux のブートローダーが上書きされたとき。
* Another operating system overwrites the Linux bootloader.
 
  +
* 何らかの理由でブートローダーが起動しないとき。
* The bootloader fails for some unknown reason.
 
   
 
Before continuing, a few notes:
 
Before continuing, a few notes:
   
* Be sure that your GRUB configuration is correct ({{ic|/boot/grub/menu.lst}}) before proceeding. Refer to [[#Finding GRUB's root|Finding GRUB's root]] to ensure your devices are defined correctly.
+
* Be sure that your GRUB configuration is correct ({{ic|/boot/grub/menu.lst}}) before proceeding. Refer to [[#GRUB root を見つける|Finding GRUB's root]] to ensure your devices are defined correctly.
 
* GRUB must be installed on the [[Master Boot Record|MBR]] (first sector of the hard disk), or the first partition of the first storage device to be recognized by most BIOSes. To allow individual distributions the ability to manage their own GRUB menus, multiple instances of GRUB can be used, see [[#chainloader と configfile|chainloader and configfile]].
 
* GRUB must be installed on the [[Master Boot Record|MBR]] (first sector of the hard disk), or the first partition of the first storage device to be recognized by most BIOSes. To allow individual distributions the ability to manage their own GRUB menus, multiple instances of GRUB can be used, see [[#chainloader と configfile|chainloader and configfile]].
 
* Installing the GRUB bootloader may need to be done from within a {{ic|chroot}}ed environment (i.e. from installed environment via a separate medium) for cases like RAID configurations or if you forgot/broke your GRUB installation. You will need to [[Change Root]] from a LiveCD or another Linux installation to do so.
 
* Installing the GRUB bootloader may need to be done from within a {{ic|chroot}}ed environment (i.e. from installed environment via a separate medium) for cases like RAID configurations or if you forgot/broke your GRUB installation. You will need to [[Change Root]] from a LiveCD or another Linux installation to do so.
   
  +
まず、GRUB シェルを開いてください:
First, enter the GRUB shell:
 
   
 
# grub
 
# grub
   
Use the {{ic|root}} command with the output from the {{ic|find}} command (see [[#Finding GRUB's root|Finding GRUB's root]]) to instruct GRUB which partition contains stage1 (and therefore, {{ic|/boot}}):
+
Use the {{ic|root}} command with the output from the {{ic|find}} command (see [[#GRUB root を見つける|Finding GRUB's root]]) to instruct GRUB which partition contains stage1 (and therefore, {{ic|/boot}}):
   
 
grub> root (hd1,0)
 
grub> root (hd1,0)
367行目: 370行目:
 
{{Tip|The GRUB shell also supports tab-completion. If you type 'root (hd' then press {{ic|Tab}} twice you will see the available storage devices, this can also be done for partitions. Tab-completion also works from the GRUB boot menu. If there is an error in your configuration file you can edit in the boot menu and use tab-completion to help find devices and partitions. See [[#Edit GRUB entries in the boot menu]].}}
 
{{Tip|The GRUB shell also supports tab-completion. If you type 'root (hd' then press {{ic|Tab}} twice you will see the available storage devices, this can also be done for partitions. Tab-completion also works from the GRUB boot menu. If there is an error in your configuration file you can edit in the boot menu and use tab-completion to help find devices and partitions. See [[#Edit GRUB entries in the boot menu]].}}
   
=== Installing to the MBR ===
+
=== MBR にインストール ===
   
The following example installs GRUB to the [[Master Boot Record|MBR]] of the first drive:
+
以下のコマンドは一番目のドライブの [[Master Boot Record|MBR]] GRUB をインストールします:
   
 
grub> setup (hd0)
 
grub> setup (hd0)
   
  +
=== パーティションにインストール ===
=== Installing to a partition ===
 
   
  +
以下のコマンドは一番目のドライブの一番目のパーティションに GRUB をインストールします:
The following example installs GRUB to the first partition of the first drive:
 
   
 
grub> setup (hd0,0)
 
grub> setup (hd0,0)
   
  +
{{ic|setup}} を実行したら {{ic|quit}} と入力してシェルを終了してください。chroot の中にいる場合、[[Change Root|chroot を終了してパーティションをアンマウント]]してください。再起動して GRUB が起動することを確認します。
After running {{ic|setup}}, enter {{ic|quit}} to exit the shell. If you chrooted, [[Change Root|exit your chroot and unmount partitions]]. Now reboot to test.
 
   
=== Alternate method (grub-install) ===
+
=== 他の方法 (grub-install) ===
   
 
{{Note|This procedure is known to be less reliable, the recommended method is to use the GRUB shell.}}
 
{{Note|This procedure is known to be less reliable, the recommended method is to use the GRUB shell.}}
   
  +
{{ic|grub-install}} コマンドの後にブートローダーをインストールするディレクトリを指定することもできます。例えば GRUB ブートローダーを一番目のドライブの MBR にインストールする場合:
Use the {{ic|grub-install}} command followed by the location to install the bootloader. For example to install the GRUB bootloader to the MBR of the first drive:
 
   
 
# grub-install /dev/sda
 
# grub-install /dev/sda
391行目: 394行目:
 
GRUB will indicate whether it successfully installs. If it does not, you will have to use the GRUB shell method.
 
GRUB will indicate whether it successfully installs. If it does not, you will have to use the GRUB shell method.
   
  +
== ヒントとテクニック ==
== Tips and tricks ==
 
   
 
他の設定事項。
 
他の設定事項。
397行目: 400行目:
 
=== グラフィカルブート ===
 
=== グラフィカルブート ===
   
視覚効果を使いたい場合、[[en2:Grub-Legacy-gfx|grub-gfx]] を見て下さい。[[GRUB]] は背景画像やビットマップフォントなどのグラフィカルな機能も備えています。
+
[[GRUB]] は背景画像やビットマップフォントなどのグラフィカルな機能も備えています。
   
 
=== フレームバッファの解像度 ===
 
=== フレームバッファの解像度 ===
407行目: 410行目:
 
So instead of using that table, you can use one of the tools mentioned below to get the correct code:
 
So instead of using that table, you can use one of the tools mentioned below to get the correct code:
   
==== GRUB recognized value ====
+
==== GRUB が認識する値 ====
   
 
This is an easy way to find the resolution code using only GRUB itself.
 
This is an easy way to find the resolution code using only GRUB itself.
428行目: 431行目:
   
 
# {{Pkg|hwinfo}} パッケージをインストール。
 
# {{Pkg|hwinfo}} パッケージをインストール。
# Run {{ic|hwinfo --framebuffer}} as root.
+
# root で {{ic|hwinfo --framebuffer}} を実行。
 
# Pick up the code corresponding to the desired resolution.
 
# Pick up the code corresponding to the desired resolution.
 
# Use the 6 digit code with 0x prefix in {{ic|1=vga=}} kernel option in {{ic|menu.lst}}. Or convert it to decimal to avoid the use of 0x prefix.
 
# Use the 6 digit code with 0x prefix in {{ic|1=vga=}} kernel option in {{ic|menu.lst}}. Or convert it to decimal to avoid the use of 0x prefix.
   
Example output of '''hwinfo''':
+
'''hwinfo''' の出力例:
   
 
Mode 0x0364: 1440x900 (+1440), 8 bits
 
Mode 0x0364: 1440x900 (+1440), 8 bits
441行目: 444行目:
 
kernel /vmlinuz-linux root=/dev/sda1 ro '''vga=0x0365'''
 
kernel /vmlinuz-linux root=/dev/sda1 ro '''vga=0x0365'''
   
  +
=== パーティションの命名 ===
{{Note|''vbetest'' gives you VESA mode to which we need to add 512 to get the correct value to use in kernel option line. While ''hwinfo'' gives you directly the correct value needed by the kernel.}}
 
   
==== vbetest ====
+
==== ラベル ====
 
# Install {{AUR|lrmi}}{{Broken package link|{{aur-mirror|lrmi}}}} which contains the '''vbetest''' tool (x86_64 users will need to use [[#hwinfo|hwinfo]]).
 
# Run {{ic|vbetest}} as root
 
# Then note the number in [ ] corresponding to your desired resolution.
 
# Press {{ic|q}} to quit '''vbetest''' interactive prompt.
 
## As an option, in a console as root, you can test the mode you just picked up by running {{ic|vbetest -m <yourcode>}} and see a pattern like [http://www.phoronix.net/image.php?id=803&image=x_vbespy_5 this one]
 
# Add '''512''' to the discovered value picked up above and use the total value to define the {{ic|1=vga=}} parameter in the kernel options of {{ic|menu.lst}}.
 
# Reboot to enjoy the result
 
 
For example '''vbetest''' on one computer:
 
 
[356] 1440x900 (256 color palette)
 
[357] 1440x900 (8:8:8)
 
 
So here the number you want is 357. Then, 357 + 512 = 869, so you will use '''vga=869'''. Add your value to the end of the kernel line in {{ic|menu.lst}} as shown below:
 
 
kernel /vmlinuz-linux root=/dev/sda1 ro '''vga=869'''
 
 
{{Note|
 
* (8:8:8) is for 24-bit color (24bit is 32bit)
 
* (5:6:5) is for 16-bit color
 
* (5:5:5) is for 15-bit color
 
}}
 
 
=== Naming partitions ===
 
 
==== By Label ====
 
   
 
If you alter (or plan to alter) partition sizes from time to time, you might want to consider defining your drive/partitions by a label. You can label ext2, ext3, ext4 partitions by:
 
If you alter (or plan to alter) partition sizes from time to time, you might want to consider defining your drive/partitions by a label. You can label ext2, ext3, ext4 partitions by:
480行目: 456行目:
 
kernel /boot/vmlinuz-linux root=/dev/disk/by-label/Arch_Linux ro
 
kernel /boot/vmlinuz-linux root=/dev/disk/by-label/Arch_Linux ro
   
==== By UUID ====
+
==== UUID ====
   
The [[UUID]] (Universally Unique IDentifier) of a partition may be discovered with {{ic|blkid}} or {{ic|ls -l /dev/disk/by-uuid}}. It is defined in {{ic|menu.lst}} with either:
+
パーティションの [[UUID]] (Universally Unique IDentifier) {{ic|blkid}} {{ic|ls -l /dev/disk/by-uuid}} で確認できます。{{ic|menu.lst}} で以下のように定義します:
   
 
kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/''uuid_number''
 
kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/''uuid_number''
   
  +
または:
or:
 
   
 
kernel /boot/vmlinuz-linux root=UUID=''uuid_number''
 
kernel /boot/vmlinuz-linux root=UUID=''uuid_number''
   
=== Boot as root (single-user mode) ===
+
=== root で起動 (シングルユーザーモード) ===
   
  +
ブートローダーの起動時に、エントリを選択して編集してください ({{ic|e}} キー)。以下のパラメータをカーネルオプションに追加します:
At the boot loader, select an entry and edit it ({{ic|e}} key). Append the following parameters to the kernel options:
 
 
[...] single init=/bin/bash
 
[...] single init=/bin/bash
  +
上記を設定するとシングルユーザーモード (init 1) で起動し、パスワードを入力しなくても root プロンプトが使えます。root パスワードの再設定などのリカバリに役立ちますが、[[GRUB/ヒントとテクニック#GRUB メニューのパスワード保護|パスワード保護]]を設定しない場合は重大なセキュリティの欠陥にもなりえます。
This will start in single-user mode (init 1), i.e. you will end up to a root prompt without being asked for password.
 
This may be useful for recovery features, like resetting the root password.
 
However, this is a huge security flaw if you have not set any [[GRUB/Tips and tricks#GRUB メニューのパスワード保護|password protection]] for grub.
 
   
=== Password protection ===
+
=== パスワード保護 ===
   
 
You can enable password protection in the GRUB configuration file for operating systems you wish to have protected. Bootloader password protection may be desired if your BIOS lacks such functionality and you need the extra security.
 
You can enable password protection in the GRUB configuration file for operating systems you wish to have protected. Bootloader password protection may be desired if your BIOS lacks such functionality and you need the extra security.
568行目: 542行目:
 
Now all that is needed is a way to easily change the default manually. This can be accomplished using the command {{ic|grub-set-default}}. So, to reboot into Windows, enter the following command:
 
Now all that is needed is a way to easily change the default manually. This can be accomplished using the command {{ic|grub-set-default}}. So, to reboot into Windows, enter the following command:
   
# grub-set-default 1 && sudo shutdown -r now
+
# grub-set-default 1
  +
  +
上記のコマンドを実行したら、再起動してください。
   
 
For ease of use, you might to wish to implement the "[[ユーザーにシャットダウンを許可]] fix" (including {{ic|/sbin/grub-set-default}} amongst the commands the user is allowed to issue without supplying a password).
 
For ease of use, you might to wish to implement the "[[ユーザーにシャットダウンを許可]] fix" (including {{ic|/sbin/grub-set-default}} amongst the commands the user is allowed to issue without supplying a password).
660行目: 636行目:
 
Now try to set up GRUB again.
 
Now try to set up GRUB again.
   
[[https://bbs.archlinux.org/viewtopic.php?pid=799930 Here]] is the forum post reporting this problem.
+
この問題について詳しくは [https://bbs.archlinux.org/viewtopic.php?pid=799930 フォーラムの投稿] を参照してください。
   
  +
=== Windows パーティションに誤ってインストールしてしまった場合 ===
=== Accidental install to a Windows partition ===
 
   
  +
GRUB を間違って Windows のパーティションにインストールした場合、GRUB はパーティションのブートセクタに情報を書き込んで、Windows ブートローダーの情報を消してしまいます (Windows XP 以前の NTLDR の話です。それ以降のバージョンの場合は不明)。
If you accidentally install GRUB to a Windows partition, GRUB will write some information to the boot sector of the partition, erasing the reference to the Windows bootloader. (This is true for NTLDR the bootloader for Windows XP and earlier, unsure about later versions).
 
   
  +
使用している Windows の Windows Recovery Console を使って修復する必要があります。コンピューターメーカーの多くは製品の中にリカバリコンソールを同梱していないため (大抵はリカバリパーティションが使われます)、Microsoft はダウンロードして使えるように用意しています。XP を使っている場合、[http://tips.vlaurie.com/2006/05/recovery-console-for-those-without-an-xp-disk/ こちらのページ] に[[フロッピーディスク]]をリカバリ CD にする方法が載っています。リカバリ CD を起動 (あるいは Windows のリカバリモードを有効化) したら {{ic|fixboot}} を実行してパーティションのブートセクタを修復してください。その後、GRUB をインストールしなおしてください。
To fix this you will need to use the Windows Recovery Console for your Windows release. Because many computer manufacturers do not include this with their product (many choose to use a recovery partition) Microsoft has made them available for download. If you use XP, look at [http://tips.vlaurie.com/2006/05/recovery-console-for-those-without-an-xp-disk/ this page] to be able to turn the floppy disks to a Recovery CD. Boot the Recovery CD (or enable Windows Recovery mode) and run {{ic|fixboot}} to repair the partition boot sector. After this, you will have to install GRUB again---this time, to the MBR, not to the Windows partition---to boot Linux.
 
   
[[Master Boot Record#Windows ブートレコードをリストアする]]見て下さい。
+
[[Master Boot Record#Windows ブートレコードをリストアする]]見て下さい。
   
=== Edit GRUB entries in the boot menu ===
+
=== ブートメニューの GRUB エントリを編集 ===
   
  +
ブートメニューでエントリを選択したら {{ic|e}} を押すことでエントリを編集できます。デバイスを確認したい場合はタブ補完を使ってください。{{ic|Esc}} で編集を終了します。その後 {{ic|b}} を押して編集したエントリを起動できます。
Once you have selected and entry in the boot menu, you can edit it by pressing key {{ic|e}}. Use tab-completion if you need to to discover devices then {{ic|Esc}} to exit. Then you can try to boot by pressing {{ic|b}}.
 
  +
{{Note|編集した設定は保存されません。}}
{{Note|These settings '''will not be saved'''.}}
 
   
=== device.map error ===
+
=== device.map エラー ===
   
If an error is raised mentioning {{ic|/boot/grub/device.map}} during installation or boot, run:
+
インストールや起動時に {{ic|/boot/grub/device.map}} に関するエラーが表示される場合、以下のコマンドを実行:
   
 
# grub-install --recheck /dev/sda
 
# grub-install --recheck /dev/sda
   
  +
GRUB はデバイスマップを再チェックします。パーティションのサイズを変更したりドライブを追加・削除したときに上記のコマンドが必要になることがあります。
to force GRUB to recheck the device map, even if it already exists. This may be necessary after resizing partitions or adding/removing drives.
 
   
 
=== KDE reboot pull-down menu fails ===
 
=== KDE reboot pull-down menu fails ===
722行目: 698行目:
 
== 参照 ==
 
== 参照 ==
   
* [http://www.gnu.org/software/grub/ GNU GRUB]
+
* [https://www.gnu.org/software/grub/ GNU GRUB]
 
* [http://www.troubleshooters.com/linux/grub/index.htm GRUB Grotto]
 
* [http://www.troubleshooters.com/linux/grub/index.htm GRUB Grotto]

2023年12月12日 (火) 07:28時点における最新版

関連記事

GRUB LegacyGNU プロジェクトによってメンテナンスされていた マルチブート ブートローダーです。Erich Stefan Boleyn によって設計・実装された GRUB (GRand Unified Bootloader) から由来しています。

ブートローダーとはコンピューターが起動した時に最初に走るプログラムです。Linux カーネルをロードして制御を移行する役割を担っています。バトンを受け取ったカーネルは、オペレーティングシステムを初期化します。

警告: GRUB Legacy は上流のメンテナンスをもはや受けておらず Arch でも公式にサポートは打ち切られています (ニュースを見て下さい: [1])。GRUB ユーザーは GRUB(2) または Syslinux に切り替えることが推奨されています。GRUB2 へのアップグレードを参照。
ノート: システムに grub-legacy の grub-0.97 パッケージをインストールしている場合、パッケージアップデートによって grub-2.xx パッケージ (GRUB2) に更新されます。grub-legacy を使いたい場合 grub-legacyAUR をインストールすればパッケージは衝突しません。アップデート /usr/lib/grub/ のファイルが更新され、grub-legacy のファイルが /boot/grub にインストールされます。MBR は削除されません。/boot/grub/menu.lst.pacsave/boot/grub/menu.lst に名前を変更することで grub-legacy に戻すことができます。

目次

サポートされているファイルシステム

GRUB Legacy は、複数のファイルシステム (特に FAT32ext2ReiserFSXFS (v4 のみ)) に対する独自のサポートがあります。

警告: ファイルシステムには、GRUB Legacy がまだ対応していない新しい機能が導入されることがあります。その場合、GRUB Legacy と互換性の無い機能を無効化しない限り、そのファイルシステムを /boot に対して使用するべきではありません。この問題は、/boot パーティションを別に分けて、FAT32 などの広くサポートされているファイルシステムを使用することで、回避することができます。

インストール

GRUB Legacy は GRUB バージョン 2.x のために公式リポジトリから落とされましたが、依然として grub-legacyAUR パッケージでインストールできます。

また、GRUB をブートローダーとして使うにはドライブやパーティションのブートセクタにインストールする必要があります。これについてはブートローダーのインストールセクションで説明しています。

GRUB2 へのアップグレード

アップグレードは必須なのか?

答えはノーです。GRUB Legacy がシステムから削除されることはなく、完全に機能する状態であり続けます。

ただし、サポートされない他のパッケージと同じように、バグは修正されなくなります。したがって、GRUB バージョン 2.x にアップグレードするか他のブートローダーに変えるほうが良いでしょう。

GRUB Legacy は GPT ディスク, Btrfs ファイルシステム, UEFI ファームウェアをサポートしていません。

アップグレード方法

GRUB Legacy から GRUB バージョン 2.x にアップグレードするのは Arch Linux に GRUB を新規インストールするのと同じです。GRUB#インストール を見て下さい。

相違点

  • GRUB Legacy と GRUB ではコマンドが異なります。先に進む前に GRUB commands を確認してください (例: "find" は "search" に置き換わっています)。
  • 今の GRUB はモジュール式であり "stage 1.5" を必要としません。そのため、ブートローダー自体の機能は限定的です -- 拡張機能の必要に応じてハードドライブからモジュールがロードされます (例: RAIDLVM のサポート)。
  • デバイスの命名規則が GRUB Legacy と GRUB で変わっています。パーティションは0ではなく1から番号付けされ、ドライブは0から番号が始まり、パーティションテーブルのタイプが前に付きます。例えば、/dev/sda1(hd0,msdos1) (MBR) や (hd0,gpt1) (GPT) と表記されます。
  • GRUB は GRUB Legacy よりもかなり大きくなっています (/boot に ~13 MB は占領します)。分割された /boot パーティションから起動している状態で、このパーティションが 32MB よりも小さい場合、ディスク容量の問題が起こったり、pacman が新しいカーネルのインストールを拒否したりします。

重要なデータのバックアップ

GRUB のインストールはスムーズに行われるべきですが、GRUB v2 にアップグレードする前に GRUB Legacy のファイルを保持しておくことを強く推奨します。

# mv /boot/grub /boot/grub-legacy

ブートコードやパーティションテーブルを含んでいる MBR をバックアップするには (/dev/sdX は実際のディスクパスに置き換えてください):

# dd if=/dev/sdX of=/path/to/backup/mbr_backup bs=512 count=1

MBR の446バイトにはブートコードが含まれていて、次の64バイトにはパーティションテーブルが含まれています。リストアする際にパーティションテーブルを上書きしたくない場合は、MBR ブートコードだけをバックアップすることを推奨します:

# dd if=/dev/sdX of=/path/to/backup/bootcode_backup bs=446 count=1

GRUB2 を正しくインストールできないときは、#GRUB Legacy のリストア を見て下さい。

GRUB Legacy の設定ファイルを新しいフォーマットに変換する

grub-mkconfig が失敗する場合、次のコマンドで /boot/grub/menu.lst ファイルを /boot/grub/grub.cfg に変換してください:

# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg
ノート: このオプションは BIOS システムでだけ機能します、UEFI システム上では使えません。

例えば:

/boot/grub/menu.lst
default=0
timeout=5

title  Arch Linux Stock Kernel
root   (hd0,0)
kernel /vmlinuz-linux root=/dev/sda2 ro
initrd /initramfs-linux.img

title  Arch Linux Stock Kernel Fallback
root   (hd0,0)
kernel /vmlinuz-linux root=/dev/sda2 ro
initrd /initramfs-linux-fallback.img
/boot/grub/grub.cfg
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi
set timeout=5

menuentry 'Arch Linux Stock Kernel' {
  set root='(hd0,1)'; set legacy_hdbias='0'
  legacy_kernel   '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'
  legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'
  
}

menuentry 'Arch Linux Stock Kernel Fallback' {
  set root='(hd0,1)'; set legacy_hdbias='0'
  legacy_kernel   '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'
  legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'
}

GRUB の /boot/grub/grub.cfg 設定ファイルを作るのを忘れて、再起動したら GRUB のコマンドシェルが表示された場合、以下を入力してください:

sh:grub> insmod legacycfg
sh:grub> legacy_configfile ${prefix}/menu.lst

Arch で起動して正しい GRUB /boot/grub/grub.cfg 設定ファイルを再生成してください。

GRUB Legacy のリストア

  • GRUB v2 のファイルをどけてください:
# mv /boot/grub /boot/grub.nonfunctional
  • GRUB Legacy を /boot にコピーしてください:
# cp -af /boot/grub-legacy /boot/grub
  • MBR と sda の次の 62 セクタをバックアップしたコピーで置き換えて下さい:
警告: このコマンドはパーティションテーブルも復元するので、古いパーティションテーブルで修正済みのパーティションテーブルを上書きすることに注意してください。あなたのシステムが破壊されます
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=1

MBR のブートコードだけをリストアするとより安全です:

# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=446 count=1

設定

設定ファイルは /boot/grub/menu.lst です。必要に応じてこのファイルを編集してください。

  • timeout # -- default オペレーティングシステムが自動的にロードされるまで待機する時間 (秒数)。
  • default # -- timeout がつきたときに選択されるデフォルトのブートエントリ。

設定例 (/boot が別パーティションにある場合):

/boot/grub/menu.lst
# Config file for GRUB - The GNU GRand Unified Bootloader
# /boot/grub/menu.lst

# DEVICE NAME CONVERSIONS
#
#  Linux           GRUB
# -------------------------
#  /dev/fd0        (fd0)
#  /dev/sda        (hd0)
#  /dev/sdb2       (hd1,1)
#  /dev/sda3       (hd0,2)
#

#  FRAMEBUFFER RESOLUTION SETTINGS
#     +-------------------------------------------------+
#          | 640x480    800x600    1024x768   1280x1024
#      ----+--------------------------------------------
#      256 | 0x301=769  0x303=771  0x305=773   0x307=775
#      32K | 0x310=784  0x313=787  0x316=790   0x319=793
#      64K | 0x311=785  0x314=788  0x317=791   0x31A=794
#      16M | 0x312=786  0x315=789  0x318=792   0x31B=795
#     +-------------------------------------------------+
#  for more details and different resolutions see
#  https://wiki.archlinux.org/index.php/GRUB#Framebuffer_Resolution

# general configuration:
timeout   5
default   0
color light-blue/black light-cyan/blue

# boot sections follow
# each is implicitly numbered from 0 in the order of appearance below
#
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
#
#-*

# (0) Arch Linux
title  Arch Linux
root   (hd0,0)
kernel /vmlinuz-linux root=/dev/sda3 ro
initrd /initramfs-linux.img

# (1) Windows
#title Windows
#rootnoverify (hd0,0)
#makeactive
#chainloader +1

GRUB の root を見つける

GRUB では複数のインスタンスが存在する可能性があるので (マルチブート環境)、GRUB のファイルがシステムのどこにあるのか指定する必要があります。GRUB のファイルは専用のパーティションである /boot 下にあります。

ノート: GRUB は一般的なカーネルの命名規則と異なった方法でストレージデバイスを定義します:
  • ハードディスクは (hdX) と定義されます。USB ストレージデバイスを示すこともあります。
  • デバイスとパーティションの番号はゼロから始まります。例えば、BIOS によって認識された一番目のハードディスクは (hd0) になります。二番目のデバイスは (hd1) です。パーティションにも同じ法則が適用されます。一番目のハードディスクの二番目のパーティションは (hd0,1) になります。

/boot の位置がわからない場合、GRUB シェルの find コマンドを使って GRUB のファイルを見つけて下さい。root で GRUB シェルに入るには:

# grub

以下は /boot が別パーティションとなっておらず単に / 下のディレクトリである場合の例です:

grub> find /boot/grub/stage1

以下は /boot パーティションが分割されている場合の例です:

grub> find /grub/stage1

GRUB はファイルを見つけたら stage1 ファイルの場所を出力します。例:

grub> find /grub/stage1
 (hd0,0)

上記の値を設定ファイルの root 行に入力してください。quit と入力するとシェルが終了します。

Windows とのデュアルブート

以下を /boot/grub/menu.lst の最後に追記してください (Windows パーティションが一番目のドライブの一番目のパーティションにある場合):

/boot/grub/menu.lst
 title Windows
 rootnoverify (hd0,0)
 makeactive
 chainloader +1
ノート:
  • Windows 7 とデュアルブートする場合、makeactive 行はコメントアウトしてください。
  • Windows 2000 以上では起動するパーティションが必ずしも最初のパーティションとは限りません。Windows のパーティションが二番目以降の場合、Windows の boot.ini ファイルを編集して変更を加える必要があります (詳しくは この記事 を参照)。

Windows が他のハードディスクにある場合、map コマンドを使って下さい。Windows が一番目のドライブにあるかのように思わせます。Windows パーティションが二番目のドライブの一番目のパーティションにある場合:

/boot/grub/menu.lst
 title Windows
 map (hd0) (hd1)
 map (hd1) (hd0)
 rootnoverify (hd1,0)
 makeactive
 chainloader +1
ノート: Windows 7 とデュアルブートする場合、makeactive 行はコメントアウトしてください。

GNU/Linux とのデュアルブート

Arch Linux を定義するときと同じです。例:

/boot/grub/menu.lst
 title Other Linux
 root (hd0,2)
 kernel /path/to/kernel root=/dev/sda3 ro
 initrd /path/to/initrd
ノート: 他のオプションが必要だったり、初期 RAM ディスクが使えないこともあります。他のディストリビューションの /boot/grub/menu.lst を確認して下さい。または chainloader と configfile を参照 (推奨)。

chainloader と configfile

システムメンテナンスを楽にするために、"automagic" GRUB 設定機構を提供している他の Linux ディストリビューション (例: Debian, Ubuntu, openSUSE) を起動する時は chainloader または configfile コマンドを使って下さい。これによってディストリビューションは自ら menu.lst とブートオプションを管理できるようになります。

  • chainloader コマンドは (カーネルイメージ以外の) 他のブートローダーをロードします。パーティションのブートセクタに他のブートローダーをインストールしている場合に有用です (例えば GRUB)。GRUB のメインインスタンスを MBR にインストールして、ディストリビューションごとの GRUB のインスタンスをパーティションブートレコード (PBR) にインストールできます。
  • configfile コマンドは指定した設定ファイルをロードするように実行中の GRUB インスタンスに指示します。このコマンドを使うことで GRUB を別個にインストールすることなく他のディストリビューションの menu.lst をロードすることができます。ただし欠点として menu.lst がインストールしている GRUB のバージョンに対応していない可能性があります。一部のディストリビューションは GRUB に独自パッチをあてまくっています。

例えば、GRUB が MBR をインストールして他のブートローダー (GRUB や LILO) が (hd0,2) のブートセクタにインストールされている場合:

---------------------------------------------
|   |           |           |   %           |
| M |           |           | B %           |
| B |  (hd0,0)  |  (hd0,1)  | L %  (hd0,2)  |
| R |           |           |   %           |
|   |           |           |   %           |
---------------------------------------------
  |                           ^
  |       chainloading        |
  -----------------------------

menu.lst に以下のように記述できます:

title Other Linux
root (hd0,2)
chainloader +1

もしくは (hd0,2) のブートローダーが GRUB の場合:

title Other Linux
root (hd0,2)
configfile /boot/grub/menu.lst

chainloader コマンドを使って二番目のドライブの MBR をロードすることもできます:

title Other drive
rootnoverify (hd1)
chainloader +1

GNU/Linux とのデュアルブート (GRUB2)

他の Linux ディストリビューションが GRUB2 を使っていて (例: Ubuntu 9.10+)、ブートローダーを root パーティションにインストールしている場合、/boot/grub/menu.lst に以下のようにエントリを追加することができます:

/boot/grub/menu.lst
 # other Linux using GRUB2
 title Ubuntu
 root (hd0,2)
 kernel /boot/grub/core.img

起動時にこのエントリを選択すると他のディストリビューション (/dev/sda3) の GRUB2 メニューがロードされます。

ブートローダーのインストール

GRUB ライブラリの手動リカバリ

*stage* ファイルは通常 /boot/grub に保存されますが、システムのインストール時にブートローダーをインストールしなかった場合や、パーティションやファイルシステムが破損した場合は存在しないことがあります。

以下のように手動で GRUB のライブラリをコピーしてください:

# cp -a /usr/lib/grub/i386-pc/* /boot/grub
ノート: Do not forget to mount the system's boot partition if your setup uses a separate one! The above assumes that either the boot partition resides on the root filesystem or is mounted to /boot on the root file system!

ブートローダーのインストールに関する注意事項

GRUB は別のメディア (例: ライブ CD) からインストールしたり、起動中の Arch 環境から直接インストールできます。GRUB ブートローダーを再インストールしなくてはならない場合は滅多にありません。以下のような場合に再インストールは不要です:

  • 設定ファイルを更新するとき。
  • grub-legacyAUR パッケージをアップデートするとき。

インストールが必要なのは以下のような場合です:

  • ブートローダーをまだインストールしていないとき。
  • 他のオペレーティングシステムによって Linux のブートローダーが上書きされたとき。
  • 何らかの理由でブートローダーが起動しないとき。

Before continuing, a few notes:

  • Be sure that your GRUB configuration is correct (/boot/grub/menu.lst) before proceeding. Refer to Finding GRUB's root to ensure your devices are defined correctly.
  • GRUB must be installed on the MBR (first sector of the hard disk), or the first partition of the first storage device to be recognized by most BIOSes. To allow individual distributions the ability to manage their own GRUB menus, multiple instances of GRUB can be used, see chainloader and configfile.
  • Installing the GRUB bootloader may need to be done from within a chrooted environment (i.e. from installed environment via a separate medium) for cases like RAID configurations or if you forgot/broke your GRUB installation. You will need to Change Root from a LiveCD or another Linux installation to do so.

まず、GRUB シェルを開いてください:

# grub

Use the root command with the output from the find command (see Finding GRUB's root) to instruct GRUB which partition contains stage1 (and therefore, /boot):

grub> root (hd1,0)
ヒント: The GRUB shell also supports tab-completion. If you type 'root (hd' then press Tab twice you will see the available storage devices, this can also be done for partitions. Tab-completion also works from the GRUB boot menu. If there is an error in your configuration file you can edit in the boot menu and use tab-completion to help find devices and partitions. See #Edit GRUB entries in the boot menu.

MBR にインストール

以下のコマンドは一番目のドライブの MBR に GRUB をインストールします:

grub> setup (hd0)

パーティションにインストール

以下のコマンドは一番目のドライブの一番目のパーティションに GRUB をインストールします:

grub> setup (hd0,0)

setup を実行したら quit と入力してシェルを終了してください。chroot の中にいる場合、chroot を終了してパーティションをアンマウントしてください。再起動して GRUB が起動することを確認します。

他の方法 (grub-install)

ノート: This procedure is known to be less reliable, the recommended method is to use the GRUB shell.

grub-install コマンドの後にブートローダーをインストールするディレクトリを指定することもできます。例えば GRUB ブートローダーを一番目のドライブの MBR にインストールする場合:

# grub-install /dev/sda

GRUB will indicate whether it successfully installs. If it does not, you will have to use the GRUB shell method.

ヒントとテクニック

他の設定事項。

グラフィカルブート

GRUB は背景画像やビットマップフォントなどのグラフィカルな機能も備えています。

フレームバッファの解像度

One can use the resolution given in the menu.lst, but you might want to use your LCD wide-screen at its full native resolution. Here is what you can do to achieve this:

On Wikipedia, there is a list of extended framebuffer resolutions (i.e. beyond the ones in the VBE standard). But, for example, the one I want to use for 1440x900 (vga=867) does not work. This is because the graphic card manufacturers are free to choose any number they wish, as this is not part of the VBE 3 standard. This is why these codes change from one card to the other (possibly even for the same manufacturer).

So instead of using that table, you can use one of the tools mentioned below to get the correct code:

GRUB が認識する値

This is an easy way to find the resolution code using only GRUB itself.

On the kernel line, specify that the kernel should ask you which mode to use.

kernel /vmlinuz-linux root=/dev/sda1 ro vga=ask

Now reboot. GRUB will now present a list of suitable codes to use and the option to scan for even more.

You can pick the code you would like to use (do not forget it, it is needed for the next step) and boot using it.

Now replace ask in the kernel line with the correct one you have picked.

e.g. the kernel line for [369] 1680x1050x32 would be:

kernel /vmlinuz-linux root=/dev/sda1 ro vga=0x369

hwinfo

  1. hwinfo パッケージをインストール。
  2. root で hwinfo --framebuffer を実行。
  3. Pick up the code corresponding to the desired resolution.
  4. Use the 6 digit code with 0x prefix in vga= kernel option in menu.lst. Or convert it to decimal to avoid the use of 0x prefix.

hwinfo の出力例:

Mode 0x0364: 1440x900 (+1440), 8 bits
Mode 0x0365: 1440x900 (+5760), 24 bits

And the kernel line:

kernel /vmlinuz-linux root=/dev/sda1 ro vga=0x0365

パーティションの命名

ラベル

If you alter (or plan to alter) partition sizes from time to time, you might want to consider defining your drive/partitions by a label. You can label ext2, ext3, ext4 partitions by:

e2label /dev/drive|partition label

The label name can be up to 16 characters long but cannot have spaces for GRUB to understand it. Then define it in your menu.lst:

kernel /boot/vmlinuz-linux root=/dev/disk/by-label/Arch_Linux ro

UUID

パーティションの UUID (Universally Unique IDentifier) は blkidls -l /dev/disk/by-uuid で確認できます。menu.lst で以下のように定義します:

kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/uuid_number

または:

kernel /boot/vmlinuz-linux root=UUID=uuid_number

root で起動 (シングルユーザーモード)

ブートローダーの起動時に、エントリを選択して編集してください (e キー)。以下のパラメータをカーネルオプションに追加します:

[...] single init=/bin/bash

上記を設定するとシングルユーザーモード (init 1) で起動し、パスワードを入力しなくても root プロンプトが使えます。root パスワードの再設定などのリカバリに役立ちますが、パスワード保護を設定しない場合は重大なセキュリティの欠陥にもなりえます。

パスワード保護

You can enable password protection in the GRUB configuration file for operating systems you wish to have protected. Bootloader password protection may be desired if your BIOS lacks such functionality and you need the extra security.

First, choose a password you can remember and then encrypt it:

# grub-md5-crypt
 Password:
 Retype password:
 $1$ZOGor$GABXUQ/hnzns/d5JYqqjw

Then add your password to the beginning of the GRUB configuration file at /boot/grub/menu.lst (the password must be at the beginning of the configuration file for GRUB to be able to recognize it):

# general configuration
timeout   5
default   0
color light-blue/black light-cyan/blue

password --md5 $1$ZOGor$GABXUQ/hnzns/d5JYqqjw
ノート: Remember that Grub uses the standard QWERTY layout for input.

Then for each operating system you wish to protect, add the lock command:

# (0) Arch Linux
title  Arch Linux
lock
root   (hd0,1)
kernel /boot/vmlinuz-linux root=/dev/disk/by-label/Arch_Linux ro
initrd /boot/initramfs-linux.img
警告: If you disable booting from other boot devices (like a CD drive) in the BIOS's settings and then password protect all your operating system entries, it could be difficult to re-enable booting back into the operating systems if the password is forgotten.

It is always possible to reset your BIOS settings by setting the appropriate jumper on the motherboard (see your motherboard's manual, as it is specific to every model). So in case other have access to the hardware, there is basically no way to prevent boot breakthroughs.

Restart with named boot choice

If you realize that you often need to switch to some other non-default OS (e.g. Windows) having to reboot and wait for the GRUB menu to appear is tedious. GRUB offers a way to record your OS choice when restarting instead of waiting for the menu, by designating a temporary new default which will be reset as soon as it has been used.

Supposing a simple menu.lst setup like this:

/boot/grub/menu.lst
# general configuration:
timeout 10
default 0
color light-blue/black light-cyan/blue

# (0) Arch
title  Arch Linux
root (hd0,1)
kernel /boot/vmlinuz-linux root=/dev/disk/by-label/ARCH ro
initrd /boot/initramfs-linux.img

# (1) Windows
title Windows XP
rootnoverify (hd0,0)
makeactive
chainloader +1

Arch is the default (0). We want to restart in to Windows. Change default 0 to default saved -- this will record the current default in a default file in the GRUB directory whenever the savedefault command is used. Now add the line savedefault 0 to the bottom of the Windows entry. Whenever Windows is booted, it will reset the default to Arch, thus making changing the default to Windows temporary.

Now all that is needed is a way to easily change the default manually. This can be accomplished using the command grub-set-default. So, to reboot into Windows, enter the following command:

# grub-set-default 1

上記のコマンドを実行したら、再起動してください。

For ease of use, you might to wish to implement the "ユーザーにシャットダウンを許可 fix" (including /sbin/grub-set-default amongst the commands the user is allowed to issue without supplying a password).

LILO と GRUB

LILO パッケージをインストールしている場合、削除して下さい。LILO を呼び出すようにしている場合 (例: make all を使ってカーネルをコンパイル)、LILO が GRUB を上書きします。インストールメディアのバージョンによって、LILO がベースシステムに含まれている可能性があります。

ノート: Removing liloAUR will not remove LILO from the MBR if it has been installed there; it will merely remove the liloAUR package. The LILO bootloader installed to the MBR will be overwritten when GRUB (or another bootloader) is installed over it.

GRUB ブートディスク

まず、フロッピーディスクをフォーマット:

# fdformat /dev/fd0
# mke2fs /dev/fd0

次にディスクをマウント:

# mount -t ext2 /dev/fd0 /mnt/fl

GRUB をディスクにインストール:

# grub-install --root-directory=/mnt/fl '(fd0)'

menu.lst ファイルをディスクにコピー:

# cp /boot/grub/menu.lst /mnt/fl/boot/grub/menu.lst

フロッピーをアンマウント:

# umount /mnt/fl

Now you should be able to restart your computer with the disk in the drive and it should boot to GRUB. Make sure that your floppy disk is set to have higher priority than your hard drive when booting in your BIOS first, of course.

参照: Super GRUB Disk

GRUB のメニューを非表示にする

The hiddenmenu option can be used in order to hide the menu by default. That way no menu is displayed and the default option is going to be automatically selected after the timeout passes. Still, you are able to press Esc and the menu shows up. To use it, just add to your /boot/grub/menu.lst:

hiddenmenu

トラブルシューティング

GRUB Error 17

ノート: the solution below works also for GRUB Error 15

The first check to do is to unplug any external drive. Seems obvious, but sometimes we get tired ;)

If your partition table gets messed up, an unpleasant "GRUB error 17" message might be the only thing that greets you on your next reboot. There are a number of reasons why the partition table could get messed up. Commonly, users who manipulate their partitions with GParted -- particularly logical drives -- can cause the order of the partitions to change. For example, you delete /dev/sda6 and resize /dev/sda7, then finally re-create what used to be /dev/sda6 only now it appears at the bottom of the list, /dev/sda9 for example. Although the physical order of the partitions/logical drives has not changed, the order in which they are recognized has changed.

Fixing the partition table is easy. Boot from your Arch CD/DVD/USB, login as root and fix the partition table:

# fdisk /dev/sda

Once in disk, enter e[x]tra/expert mode, [f]ix the partition order, then [w]rite the table and exit.

You can verify that the partition table was indeed fixed by issuing an fdisk -l. Now you just need to fix GRUB. See the Bootloader installation section.

Basically you need to tell GRUB the correct location of your /boot then re-write GRUB to the MBR on the disk.

For example:

# grub
grub> root (hd0,6)
grub> setup (hd0)
grub> quit

See [this page] for a more in-depth summary of this section.

/boot/grub/stage1 not read correctly

If you see this error message while trying to set up GRUB, and you are not using a fresh partition table, it is worth checking it.

# fdisk -l /dev/sda

This will show you the partition table for /dev/sda. So check here, whether the "Id" values of your partitions are correct. The "System" column will show you the description of the "Id" values.

If your boot partition is marked as being "HPFS/NTFS", for example, then you have to change it to "Linux". To do this, go to fdisk,

# fdisk /dev/sda

change a partition's system id with t, select you partition number and type in the new system id (Linux = 83). You can also list all available system ids by typing L instead of a system id.

If you have changed a partitions system id, you should [v]erify your partition table and then [w]rite it.

Now try to set up GRUB again.

この問題について詳しくは フォーラムの投稿 を参照してください。

Windows パーティションに誤ってインストールしてしまった場合

GRUB を間違って Windows のパーティションにインストールした場合、GRUB はパーティションのブートセクタに情報を書き込んで、Windows ブートローダーの情報を消してしまいます (Windows XP 以前の NTLDR の話です。それ以降のバージョンの場合は不明)。

使用している Windows の Windows Recovery Console を使って修復する必要があります。コンピューターメーカーの多くは製品の中にリカバリコンソールを同梱していないため (大抵はリカバリパーティションが使われます)、Microsoft はダウンロードして使えるように用意しています。XP を使っている場合、こちらのページフロッピーディスクをリカバリ CD にする方法が載っています。リカバリ CD を起動 (あるいは Windows のリカバリモードを有効化) したら fixboot を実行してパーティションのブートセクタを修復してください。その後、GRUB をインストールしなおしてください。

Master Boot Record#Windows ブートレコードをリストアするも見て下さい。

ブートメニューの GRUB エントリを編集

ブートメニューでエントリを選択したら e を押すことでエントリを編集できます。デバイスを確認したい場合はタブ補完を使ってください。Esc で編集を終了します。その後 b を押して編集したエントリを起動できます。

ノート: 編集した設定は保存されません。

device.map エラー

インストールや起動時に /boot/grub/device.map に関するエラーが表示される場合、以下のコマンドを実行:

# grub-install --recheck /dev/sda

GRUB はデバイスマップを再チェックします。パーティションのサイズを変更したりドライブを追加・削除したときに上記のコマンドが必要になることがあります。

KDE reboot pull-down menu fails

If you have opened a sub-menu with the list of all operating systems configured in GRUB, selected one, and upon restart, you still booted your default OS, then you might want to check if you have the line:

default saved

in /boot/grub/menu.lst.

GRUB fails to find or install to any virtio /dev/vd* or other non-BIOS devices

I had trouble installing GRUB while installing Arch Linux in an virtual KVM machine using a virtio device for hard drive. To install GRUB, I figured out the following: Enter a virtual console by typing Ctrl+Alt+F2 or any other F-key for a free virtual console. This assumes that your root file system is mounted in the folder /mnt and the boot file system is either mounted or stored in the folder /mnt/boot.

1. Assure that all needed GRUB files is present in your boot directory (assuming it is mounted in /mnt/boot folder), by issuing the command:

# ls /mnt/boot/grub

2. If the /mnt/boot/grub folder already contains all the needed files, jump to step 3. Otherwise, do the following commands (replacing /mnt, your_kernel and your_initrd with the real paths and file names). You should also have the menu.lst file written to this folder:

# mkdir -p /mnt/boot/grub                # if the folder is not yet present
# cp -r /boot/grub/stage1 /boot/grub/stage2 /mnt/boot/grub
# cp -r your_kernel your_initrd /mnt/boot

3. Start the GRUB shell with the following command:

# grub --device-map=/dev/null

4. Enter the following commands. Replace /dev/vda, and (hd0,0) with the correct device and partition corresponding to your setup.

device (hd0) /dev/vda
root (hd0,0)
setup (hd0)
quit

5. GRUB がエラーメッセージを表示しない場合、完了です。適切なモジュールを ramdisk に追加する必要があります。詳しくは QEMU#(Arch) Linux ゲストを用意する を参照。

参照