1
0

定時帰る術-GPTってなんだろうにしたかったけど、やはりわかん

Posted at

まずはみんなさんGPTって何だと思う?(chatgptは別)

GPTの略称はGUID パーティションテーブルってRHEL公式HPにのっている。
名前が超わかりやすいと思って、パーティションテーブルだけで、具体的なファイルシステムがext4なのかxfsなのかはどうでもいいわけ。
設計思想もすごいなぁと思いつつ

実際みてみよう

「gdisk -l /dev/sda」の結果から見ていきましょう
(分かりやすいようにテーブル化にしたけど。。。面倒くさいから二度とやりません)

Number Start (sector) End (sector) Size Code Name
x 0 2047 1MiB
1 2048 1050623 512.0 MiB EF00 EFI System Partition
2 1050624 3358719 1.1 GiB 8300
3 3358720 626835455 297.3 GiB 8300
4 626835456 629143551 1.1 GiB 8300
x 629143552 629145600 1MiB

前提:

①HDD容量:300GB
②LVMは使用しない
③OSインストールする際に、gptで300GBすべて使えるようにする

セクタ計算式:300 * 1024(KB) * 1024(MB) * 1024(GB) / 512=629145600

開始位置と終了位置

御覧の通り開始終了位置はセクタサイズである
開始位置が「2048」になっていて、最後の終了位置が「629145600」じゃないのがおかしいと思う方もいるでしょう。
川口の推測ですが、表示されていないだけで、実際は↓ではないかと
sdaの前後にパーティションテーブルが隠され、1MiBで占用されてると思われる。

パーミッション作成

なんかgdiskはfdisk、partedより使いやすいきがする

開始位置は勝手に計算してくれるし、終了位置は「+5G」にみたいな感じで指定できるので、親切なと思う。
例:
[root@localhost ~]# gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present

Creating new GPT entries.

Command (? for help): p
Disk /dev/sdb: 20971520 sectors, 10.0 GiB
Model: VBOX HARDDISK
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 7B6B64FF-F2C3-47E7-9941-3029FF41458B
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 20971486
Partitions will be aligned on 2048-sector boundaries
Total free space is 20971453 sectors (10.0 GiB)
Number Start (sector) End (sector) Size Code Name

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-20971486, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-20971486, default = 20971486) or {+-}size{KMGTP}: +2048M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

Command (? for help):p
Disk /dev/sdb: 20971520 sectors, 10.0 GiB
Model: VBOX HARDDISK
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 7B6B64FF-F2C3-47E7-9941-3029FF41458B
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 20971486
Partitions will be aligned on 2048-sector boundaries
Total free space is 16777149 sectors (8.0 GiB)

Number Start (sector) End (sector) Size Code Name
1 2048 4196351 2.0 GiB 8300 Linux filesystem

最後

誤操作しないよう、隠されているのが理解はできるけど、なんか表示させる手段がないよう
(どこかにバックアップして、hexdumpで確認していく記事が多く見られるけど、説明とのっている結果が全然違うのもあって、すごいなぁと思って。自分と同じく適当にやっていることヤツもいるんだなぁ)
ということでもし簡単に確認できる方法があったら、まだ投稿しようとおもっている。面白そうだから。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0