動機
Ubuntu Serverをインストールするとディスクパーティションを自動で設定してくれます。便利ですね。
でも長く使うサーバーは愛着が持てるようにディスクパーティションであってもカスタマイズしたいのです。
環境
SSD 500GB
セクターサイズ:512Byte
セクター数:976773168
SATA6Gb/s接続
目標
こんな感じのパーティションにしたい。
start | end | size | 用途 |
---|---|---|---|
0 | 1 | 1S | Protective MBR |
1 | 33 | 34S | Primary GPT Header |
34 | 204799 | 99.9MiB | EFI system partition |
204800 | 976773133 | Linux filesystem | |
976773134 | 976773167 | 34S | Secondary GPT Header |
parted情報
Disk /dev/sda: 976773168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 34s 204799s 204766s fat32 boot, esp
2 204800s 976773134s 976568335s ext4
gdisk情報
Disk identifier (GUID)
とPartition unique GUID
を変更してキリ番にしてある。
GPT fdisk (gdisk) version 1.0.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Model: WDC WDS500G2B0A
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 8-sector boundaries
Total free space is 0 sectors (0 bytes)
Number Start (sector) End (sector) Size Code Name
1 34 204799 100.0 MiB EF00
2 204800 976773134 465.7 GiB 8300
Command (? for help): i
Partition number (1-2): 1
Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI system partition)
Partition unique GUID: BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB
First sector: 34 (at 17.0 KiB)
Last sector: 204799 (at 100.0 MiB)
Partition size: 204766 sectors (100.0 MiB)
Attribute flags: 0000000000000000
Partition name: ''
Command (? for help): i
Partition number (1-2): 2
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: DDDDDDDD-DDDD-DDDD-DDDD-DDDDDDDDDDDD
First sector: 204800 (at 100.0 MiB)
Last sector: 976773134 (at 465.8 GiB)
Partition size: 976568335 sectors (465.7 GiB)
Attribute flags: 0000000000000000
Partition name: ''
フォーマットする
パーティションのIDもキリ番にする。
> mkfs.vfat -F 32 -S 4096 -i FFFFFFFF -v /dev/sda1
> mkfs.ext4 -b 4096 -m 1 -U dddddddd-dddd-dddd-dddd-dddddddddddd /dev/sda2
> blkid
/dev/sda1: UUID="FFFF-FFFF" BLOCK_SIZE="4096" TYPE="vfat" PARTUUID="bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
/dev/sda2: UUID="dddddddd-dddd-dddd-dddd-dddddddddddd" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="dddddddd-dddd-dddd-dddd-dddddddddddd"
中略
この情報は一回目にインストールしてみたところシステムにパーティションを変更された時の情報です。
上記の様にparted
とgdisk
でパーティションを調整し、mkfs
でフォーマットしてファイルシステムを作成するとうまくいきました。
インストール後
Ubuntu Serverをインストールしてみたところ、ディスクパーティションに変更があった。
start | end | size | 用途 |
---|---|---|---|
0 | 1 | 1S | Protective MBR |
1 | 33 | 34S | Primary GPT Header |
34 | 2047 | 2014S | Free Space |
2048 | 4095 | 1024.0KiB | BIOS boot partition |
2048 | 976771071 | 465.8GiB | Linux filesystem |
976771072 | 976773134 | 2063S | Free Space |
976773134 | 976773167 | 34S | Secondary GPT Header |
parted情報
Disk /dev/sda: 976773168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 2048s 4095s 2048s bios_grub
2 4096s 976771071s 976766976s ext4
gdisk情報
GPT fdisk (gdisk) version 1.0.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Model: WDC WDS500G2B0A
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): ********-****-****-****-************
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 4077 sectors (2.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 4095 1024.0 KiB EF02
2 4096 976771071 465.8 GiB 8300
Command (? for help): i
Partition number (1-2): 1
Partition GUID code: 21686148-6449-6E6F-744E-656564454649 (BIOS boot partition)
Partition unique GUID: ********-****-****-****-************
First sector: 2048 (at 1024.0 KiB)
Last sector: 4095 (at 2.0 MiB)
Partition size: 2048 sectors (1024.0 KiB)
Attribute flags: 0000000000000000
Partition name: ''
Command (? for help): i
Partition number (1-2): 2
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: ********-****-****-****-************
First sector: 4096 (at 2.0 MiB)
Last sector: 976771071 (at 465.8 GiB)
Partition size: 976766976 sectors (465.8 GiB)
Attribute flags: 0000000000000000
Partition name: ''
検証
インストール後にパーティションが変わっていないか確認する。
parted情報
Disk /dev/sda: 976773168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 34s 204799s 204766s fat32 boot, esp
2 204800s 976773134s 976568335s ext4
gdisk情報
GPT fdisk (gdisk) version 1.0.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Model: WDC WDS500G2B0A
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 8-sector boundaries
Total free space is 0 sectors (0 bytes)
Number Start (sector) End (sector) Size Code Name
1 34 204799 100.0 MiB EF00
2 204800 976773134 465.7 GiB 8300
Command (? for help): i
Partition number (1-2): 1
Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI system partition)
Partition unique GUID: BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB
First sector: 34 (at 17.0 KiB)
Last sector: 204799 (at 100.0 MiB)
Partition size: 204766 sectors (100.0 MiB)
Attribute flags: 0000000000000000
Partition name: ''
Command (? for help): i
Partition number (1-2): 2
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: DDDDDDDD-DDDD-DDDD-DDDD-DDDDDDDDDDDD
First sector: 204800 (at 100.0 MiB)
Last sector: 976773134 (at 465.8 GiB)
Partition size: 976568335 sectors (465.7 GiB)
Attribute flags: 0000000000000000
Partition name: ''
blkid情報
> blkid
/dev/sda2: UUID="********-****-****-****-************" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="dddddddd-dddd-dddd-dddd-dddddddddddd"
/dev/sda1: UUID="****-****" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
ファイルシステムのUUIDはインストールする時のフォーマットでランダムなものに変えられてしまった。
ファイルシステムのUUIDを変更するには再度フォーマットしないとならず、そうするとシステムファイルが消えてしまい、またインストールする必要があり、ここはカスタマイズできそうにない。
所見
- 今回のように
ESP(EFI System Partition)
を使う場合マザーボードのCSM(互換モード)
を無効にしないとうまく起動しない - インストール時にパーティションをフォーマットする必要があり(しないと
/
にマウントさせてもらえない)パーティションシステムのUUIDは任意のものから変更されてしまう -
Rufus
でインストールメディアを作る時ターゲットシステム
をUEFI(CSM 無効)にしないとEPSを用いたブート方式でインストールできなかった - インストールする時にマザーボードの
CSM(互換モード)
を無効にするとインストールメディアが起動しなかった - インストール後に
CSM(互換モード)
を有効にしたままだとUbuntu Server
が起動しなかった
参考にしたもの
EFI System Partition
をFAT32
形式フォーマットする時、参考にしました。
システムパーティションをEXT4
形式にフォーマットする時、参考にしました。