# sgdisk -p /dev/sdb Disk /dev/sdb: 5860533168 sectors, 2.7 TiB Logical sector size: 512 bytes Disk identifier (GUID): 379419D7-0F1F-4FB5-8800-490E3D800689 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 5860533134 Partitions will be aligned on 2048-sector boundaries Total free space is 2014 sectors (1007.0 KiB) Number Start (sector) End (sector) Size Code Name 1 2048 5860533134 2.7 TiB 8300 Linux filesystem(2) ファイルシステムを作成して、grubのバイナリをファイルシステムに コピーします。そしてstage1_5をGPTの後ろの空き領域に埋め込みます。 menu.lstも適当に作ってコピーします。
# mkfs.ext4 /dev/sdb1 (メッセージが表示される) # mount /dev/sdb1 /mnt # mkdir -p /mnt/boot/grub # cp stage1 stage2 menu.lst /mnt/boot/grub/ # dd if=e2fs_stage1_5 of=/dev/sdb seek=64 20+1 records in ・・・ (21セクター使用したことが分かる)(3) 当サイトのビルド済みバイナリをそのまま使う場合、USBメモリに書き込んで起動できるようにします。
# pwd /tmp/grub-0.97lenny # cat stage1 stage2 | dd of=/dev/sdc(4) USBメモリからgrubを起動し、installコマンドでHDDにgrubをセットアップします。
grub> geometry (hd1) (2台目であることを確認) drive 0x81: C/H/S = 1024/255/63, The number of sectors = 5860533168, LBA Partition num: 0, Filesystem type is ext2fs, partition type 0x8300 grub> root (hd1,0) Filesystem type is ext2fs, partition type 0x8300 grub> install /boot/grub/stage1 (hd1) (hd1)64+21 p (hd1,0)/boot/grub/stage2 (何も表示されなければインストール成功です)stage1_5がLBA 64以降の21セクター にあるので上記のようなinstallコマンドの引数になります。 そしてこれは当ディスクを1台目のHDDとして起動する場合です。
# cp stage1 menu.lst /mnt/boot/grub/ # dd if=stage2 of=/dev/sdb seek=256 276+1 records in ・・・ (277セクター使用したことが分かる)(4a) (4)と異なる部分を示します。
grub> install /boot/grub/stage1 (hd1) (hd1)256+277 (hd0,0)/boot/grub/menu.lststage2がLBA 256以降の277セクター にあり、そしてmenu.lstが起動時の1台目のディスクの第1パーティションにあるので上記のようなinstallコマンドの引数になります。
grub> geometry (hd0) (3TBディスクが1台目のHDDであることを確認) drive 0x80: C/H/S = 1024/255/63, The number of sectors = 5860533168, LBA Partition num: 0, Filesystem type is ext2fs, partition type 0x8300 grub> blocklist (hd0)0xffffffff+1 (2TiBの最終セクター 2^32-1 をBIOS INT13HでREAD) (hd0)4294967295+1 grub> blocklist (hd0)0x100000000+1 (2TiB超えの最初のセクター 2^32 をBIOS INT13HでREAD) (hd0)4294967296+1 grub> blocklist (hd0)5860533167+1 (当3TB Diskの最終セクターをBIOS INT13HでREAD) (hd0)5860533167+1 grub> root (hd0) Filesystem type unknown, using whole disk grub> cmp 1+1 5860533167+1 (第1GPTヘッダーと第2GPTヘッダーの比較) Differ at the offset 16: 0x9b [1+1], 0x3 [5860533167+1] (CRC32) Differ at the offset 17: 0xe9 [1+1], 0xf6 [5860533167+1] Differ at the offset 18: 0xca [1+1], 0xde [5860533167+1] Differ at the offset 19: 0x59 [1+1], 0x6e [5860533167+1] Differ at the offset 24: 0x1 [1+1], 0xaf [5860533167+1] (自ヘッダーのLBA) Differ at the offset 25: 0x0 [1+1], 0xa3 [5860533167+1] Differ at the offset 26: 0x0 [1+1], 0x58 [5860533167+1] Differ at the offset 27: 0x0 [1+1], 0x5d [5860533167+1] Differ at the offset 28: 0x0 [1+1], 0x1 [5860533167+1] Differ at the offset 32: 0xaf [1+1], 0x1 [5860533167+1] (他ヘッダーのLBA) Differ at the offset 33: 0xa3 [1+1], 0x0 [5860533167+1] Differ at the offset 34: 0x58 [1+1], 0x0 [5860533167+1] Differ at the offset 35: 0x5d [1+1], 0x0 [5860533167+1] Differ at the offset 36: 0x1 [1+1], 0x0 [5860533167+1] Differ at the offset 72: 0x2 [1+1], 0x8f [5860533167+1] (GPTエントリーのLBA) Differ at the offset 73: 0x0 [1+1], 0xa3 [5860533167+1] Differ at the offset 74: 0x0 [1+1], 0x58 [5860533167+1] Differ at the offset 75: 0x0 [1+1], 0x5d [5860533167+1] Differ at the offset 76: 0x0 [1+1], 0x1 [5860533167+1] grub> cmp 2+1 5860533135+1 (GPTエントリーが同一であることを確認) (同一である場合は何も表示されない) grub> grub> blocklist (hd0,0)/boot/initrd.img-3.2.0-37-generic (initrdが読み込めることを確認) (hd0,0)311296+32768,271624+516 事前に大きなファイルを沢山作り、2TiBを超えるまで埋めた。 grub> blocklist (hd0,0)/100m/00/f00001 (最初のファイルが読み込めることを確認) (hd0,0)2605056+16384,2637824+188416 grub> blocklist (hd0,0)/100m/22/f22333 (2TiBを超えている位置にあるファイルが読み込めることを確認) (hd0,0)4996579328+204800・2013-02-11
# gpart show => 34 5860533101 ada0 GPT (2.7T) 34 6 - free - (3.0k) 40 128 1 freebsd-boot (64k) 168 5851053944 2 freebsd-ufs (2.7T) 5851054112 8388608 3 freebsd-swap (4.0G) 5859442720 1090415 - free - (532M)Linuxのsgdiskコマンドで表示してみると、
# sgdisk -p /dev/sdb (中略) Total free space is 1090421 sectors (532.4 MiB) Number Start (sector) End (sector) Size Code Name 1 40 167 64.0 KiB A501 2 168 5851054111 2.7 TiB A503 3 5851054112 5859442719 4.0 GiB A502当サイトのgrubのgeometryコマンドで表示してみると、
grub> geometry (hd0) drive 0x80: C/H/S = 1024/255/63, The number of sectors = 5860533168, LBA Partition num: 0, Filesystem type unknown, partition type 0xa501 Partition num: 1, Filesystem type is ufs2, partition type 0xa503 Partition num: 2, Filesystem type unknown, partition type 0xa502FreeBSDのインストーラーのbsdinstallはパーティションを 1MiB単位に揃えようとすることはないようです。 MBRには /boot/pmbr がセットされていて、これはGPTのFreeBSD bootパーティション を探し出し、そこからバイナリをロード・実行するようです。 FreeBSD bootパーティションは64KiBと小さく、ファイルシステムではありません。
# pwd /boot/grub # dd if=/dev/zero of=zero1 count=1 # dd if=ufs2_stage1_5 of=/dev/null 18+1 records in ・・・ (19セクター使っていることが分かる) # cat ufs2_stage1_5 zero1 > ufs15 # dd if=ufs15 of=/dev/ada0p1 count=19(2) 以下のような menu.lst を /boot/grub/ の中に作っておきます。
title FreeBSD 9.1R root (hd0,1) kernel /boot/loader(3) 当サイトのビルド済みバイナリを書き込んだUSBメモリで起動し、 installコマンドでgrubをセットアップします。(この3TBディスクが1台目のHDDの場合)
grub> root (hd0,1) Filesystem type is ufs2, partition type 0xa503 grub> install /boot/grub/stage1 (hd0) (hd0,0)0+19 (hd0,1)/boot/grub/stage2 (何も表示されなければインストール成功です)再起動し、(2)のメニューが表示されて、EnterでFreeBSDが起動されればOKです。
# sgdisk -p /dev/sdb (中略) Total free space is 2014 sectors (1007.0 KiB) Number Start (sector) End (sector) Size Code Name 1 2048 524287 255.0 MiB EF00 EFI System 2 524288 786431 128.0 MiB EF02 BIOS boot partition 3 786432 1048575 128.0 MiB 0700 Microsoft basic data 4 1048576 8388607 3.5 GiB 0700 Microsoft basic data 5 8388608 268435455 124.0 GiB 0700 Microsoft basic data 6 268435456 335544319 32.0 GiB 0700 Microsoft basic data 7 335544320 1056964607 344.0 GiB 7F01 ChromeOS root 8 1056964608 1073217535 7.8 GiB 8200 Linux swap 9 1073217536 1073741823 256.0 MiB 8300 Linux filesystem 10 1073741824 2147483647 512.0 GiB 8300 Linux filesystem 11 2147483648 3221225471 512.0 GiB 8300 Linux filesystem 12 3221225472 4294967295 512.0 GiB 8300 Linux filesystem 13 4294967296 5368709119 512.0 GiB 8300 Linux filesystem 14 5368709120 5368709247 64.0 KiB A501 FreeBSD boot 15 5368711168 5370806271 1023.0 MiB A502 FreeBSD swap 16 5370806272 5637144575 127.0 GiB A503 FreeBSD UFS 17 5637144576 5771362303 64.0 GiB A800 Apple UFS 18 5771362304 5855248383 40.0 GiB A902 NetBSD FFS 19 5855248384 5860533134 2.5 GiB FD00 Linux RAIDFreeBSDのブートコードがインストールされなかったので、FreeBSDを起動し 以下のコマンドを実行しました。
# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 14 ada0ところが最初ブートしませんでした。原因は14番目のFreeBSD bootパーティション のサイズを最初1MiB 取っていたためでした。pmbr はbootパーティション丸ごとメモリにロードする仕様になっています。 bootパーティションを64KiBに縮めて無事にFreeBSDが起動できるようになりました。 pmbr, gptboot共、64ビットLBA対応しています。
grub> geometry (hd0) drive 0x80: C/H/S = 1024/255/63, The number of sectors = 5860533168, LBA Partition num: 0, Filesystem type is fat, partition type 0xef00 Partition num: 1, Filesystem type unknown, partition type 0xef02 Partition num: 2, Filesystem type is fat, partition type 0x100 Partition num: 3, Filesystem type is fat, partition type 0x600 Partition num: 4, Filesystem type is ntfs, partition type 0x700 Partition num: 5, Filesystem type is fat, partition type 0xb00 Partition num: 6, Filesystem type is ext2fs, partition type 0x7f01 Partition num: 7, Filesystem type unknown, partition type 0x8200 Partition num: 8, Filesystem type is minix, partition type 0x8300 Partition num: 9, Filesystem type is ext2fs, partition type 0x8300 Partition num: 10, Filesystem type is jfs, partition type 0x8300 Partition num: 11, Filesystem type is reiserfs, partition type 0x8300 Partition num: 12, Filesystem type is xfs, partition type 0x8300 Partition num: 13, Filesystem type unknown, partition type 0xa501 Partition num: 14, Filesystem type unknown, partition type 0xa502 Partition num: 15, Filesystem type is ufs2, partition type 0xa503 Partition num: 16, Filesystem type is ufs2, partition type 0xa800 Partition num: 17, Filesystem type is ffs, partition type 0xa902 Partition num: 18, Filesystem type unknown, partition type 0xfd00パーティション16,17の ufs2, ffs はFreeBSDでnewfsしたものですので、あしからず。
(Linuxで操作。このとき3TBディスクは 2台目のHDD) # dd if=/dev/sdb of=/tmp/mbr-freebsd count=1 # dd if=/tmp/mbr-freebsd of=/dev/sdb14 seek=120 (grubのmenu.lstに追記する。このとき3TBディスクは 1台目のHDD) title FreeBSD 9.1R chainloader (hd0,13)120+1
次のファイルが存在しないかまたは壊れているため、Windows を 起動できませんでした: <Windows root>¥system32¥hal.dll.が出てNG。
# sfdisk -d /dev/sdb WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util sfdisk doesn't support GPT. Use GNU Parted. # partition table of /dev/sdb unit: sectors /dev/sdb1 : start= 1, size= 2047, Id=ee /dev/sdb2 : start= 2048, size= 32127952, Id= 7, bootable /dev/sdb3 : start= 32130000, size= 16065000, Id=82 /dev/sdb4 : start= 48195000, size=112455000, Id=83 # sgdisk -p /dev/sdb Disk /dev/sdb: 5860533168 sectors, 2.7 TiB (中略) Number Start (sector) End (sector) Size Code Name 1 2048 32129999 15.3 GiB 0700 Microsoft basic data 2 32130000 48194999 7.7 GiB 8200 Linux swap 3 48195000 160649999 53.6 GiB 8300 Linux filesystem 4 160650000 1502827279 640.0 GiB 8300 Linux filesystem 5 1502827280 5860533134 2.0 TiB 8300 Linux filesystemMBR第1パーティションIDを ee から 0a に変更した状態で sfdisk, sgdisk, gdisk, parted コマンドで表示すると、
# sfdisk -d /dev/sdb WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util sfdisk doesn't support GPT. Use GNU Parted. # partition table of /dev/sdb unit: sectors /dev/sdb1 : start= 1, size= 2047, Id= a /dev/sdb2 : start= 2048, size= 32127952, Id= 7, bootable /dev/sdb3 : start= 32130000, size= 16065000, Id=82 /dev/sdb4 : start= 48195000, size=112455000, Id=83 # sgdisk -p /dev/sdb Invalid partition data! # gdisk -l /dev/sdb GPT fdisk (gdisk) version 0.8.5 Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: present Found valid MBR and GPT. Which do you want to use? 1 - MBR 2 - GPT 3 - Create blank GPT Your answer: ^C [中断] # parted -l (中略) Warning: /dev/sdb contains GPT signatures, indicating that it has a GPT table. However, it does not have a valid fake msdos partition table, as it should. Perhaps it was corrupted -- possibly by a program that doesn't understand GPT partition tables. Or perhaps you deleted the GPT table, and are now using an msdos partition table. Is this a GPT partition table? Yes/No? ^C [中断] Model: ATA TOSHIBA DT01ACA3 (scsi) Disk /dev/sdb: 3001GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 16.5GB 16.4GB ntfs Microsoft basic data 2 16.5GB 24.7GB 8225MB Linux swap 3 24.7GB 82.3GB 57.6GB ext4 Linux filesystem 4 82.3GB 769GB 687GB ext4 Linux filesystem 5 769GB 3001GB 2231GB xfs Linux filesystem (中略)Hybrid MBRでもないおかしな状態ですので、コマンドによっては色々 警告やアドバイスをしてくれています。
grub> map (hd1) (hd0) grub> chainloader (hd1,1)0+1 grub> boot
grub> geometry (hd0) drive 0x80: C/H/S = 1024/255/63, The number of sectors = 5860533168, LBA Partition num: 0, Filesystem type is exfat, partition type 0x700 Partition num: 1, Filesystem type is nilfs2, partition type 0x8300