17 February 2020

gptパーティションのパーティション・タイプを修正する

昨年8月末から使っているLenovo ThinkCentre M720qのディスク。gptエントリのパーティション・タイプがすべて0700(Microsoft basic data)となっている。

Linuxのswapやext4のパーティションは、本来8200や8300のはずなので、これを修正することとする。

修正前

$ sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.3
 
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: 1875385008 sectors, 894.3 GiB
Model: CSSD-S6B960CG3VX
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 3B2E892C-236C-4501-BFCA-8408D7839C3B
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 1875384974
Partitions will be aligned on 2048-sector boundaries
Total free space is 2122349 sectors (1.0 GiB)
 
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          534527   260.0 MiB   EF00  EF
   2          534528          567295   16.0 MiB    0C01  Mi
   3          567296       168339455   80.0 GiB    0700  
   4       168339456       170377215   995.0 MiB   0700  
   5       170377216       187154431   8.0 GiB     0700  Basic data partition
   6       187154432       271040511   40.0 GiB    0700  Basic data partition
   7       271040512       354926591   40.0 GiB    0700  Basic data partition
   8       354926592       438812671   40.0 GiB    0700  Basic data partition
   9       438812672       480755711   20.0 GiB    0700  Basic data partition
  10       480755712       963100671   230.0 GiB   0700  Basic data partition
  11       963100672      1445445631   230.0 GiB   0700  Basic data partition
  12      1445445632      1873264639   204.0 GiB   8300  Basic data partition

修正作業

Command (? for help): t
Partition number (1-12): 6
Current type is 'Microsoft basic data'
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'
 
Command (? for help): t
Partition number (1-12): 12
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'
 
Command (? for help): t
Partition number (1-12): 5
Current type is 'Microsoft basic data'
Hex code or GUID (L to show codes, Enter = 8300): 8200
Changed type of partition to 'Linux swap'

修正後

Command (? for help): p
Disk /dev/sda: 1875385008 sectors, 894.3 GiB
Model: CSSD-S6B960CG3VX
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 3B2E892C-236C-4501-BFCA-8408D7839C3B
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 1875384974
Partitions will be aligned on 2048-sector boundaries
Total free space is 2122349 sectors (1.0 GiB)
 
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          534527   260.0 MiB   EF00  EF
   2          534528          567295   16.0 MiB    0C01  Mi
   3          567296       168339455   80.0 GiB    0700  
   4       168339456       170377215   995.0 MiB   0700  
   5       170377216       187154431   8.0 GiB     8200  Basic data partition
   6       187154432       271040511   40.0 GiB    8300  Basic data partition
   7       271040512       354926591   40.0 GiB    0700  Basic data partition
   8       354926592       438812671   40.0 GiB    0700  Basic data partition
   9       438812672       480755711   20.0 GiB    0700  Basic data partition
  10       480755712       963100671   230.0 GiB   0700  Basic data partition
  11       963100672      1445445631   230.0 GiB   0700  Basic data partition
  12      1445445632      1873264639   204.0 GiB   8300  Basic data partition
$ sudo fdisk -l /dev/sda
ディスク /dev/sda: 894.3 GiB, 960197124096 バイト, 1875385008 セクタ
単位: セクタ (1 * 512 = 512 バイト)
セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
ディスクラベルのタイプ: gpt
ディスク識別子: 3B2E892C-236C-4501-BFCA-8408D7839C3B
 
デバイス     開始位置   最後から    セクタ サイズ タイプ
/dev/sda1        2048     534527    532480   260M EFI システム
/dev/sda2      534528     567295     32768    16M Microsoft 予約領域
/dev/sda3      567296  168339455 167772160    80G Microsoft 基本データ
/dev/sda4   168339456  170377215   2037760   995M Microsoft 基本データ
/dev/sda5   170377216  187154431  16777216     8G Linux スワップ
/dev/sda6   187154432  271040511  83886080    40G Linux ファイルシステム
/dev/sda7   271040512  354926591  83886080    40G Microsoft 基本データ
/dev/sda8   354926592  438812671  83886080    40G Microsoft 基本データ
/dev/sda9   438812672  480755711  41943040    20G Microsoft 基本データ
/dev/sda10  480755712  963100671 482344960   230G Microsoft 基本データ
/dev/sda11  963100672 1445445631 482344960   230G Microsoft 基本データ
/dev/sda12 1445445632 1873264639 427819008   204G Linux ファイルシステム

パーティション名について

WindowsやLinuxではあまり用いられない「パーティション名」は、変更してもしなくてもよいようだ。

$ sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.3
 
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present
 
Found valid GPT with protective MBR; using GPT.
 
Command (? for help): c
Partition number (1-12): 5
Enter name: Linux swap
 
Command (? for help): c
Partition number (1-12): 6
Enter name: Linux filesystem
 
Command (? for help): c
Partition number (1-12): 12
Enter name: Linux filesystem
 
Command (? for help): p
Disk /dev/sda: 1875385008 sectors, 894.3 GiB
Model: CSSD-S6B960CG3VX
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 3B2E892C-236C-4501-BFCA-8408D7839C3B
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 1875384974
Partitions will be aligned on 2048-sector boundaries
Total free space is 2122349 sectors (1.0 GiB)
 
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          534527   260.0 MiB   EF00  EF
   2          534528          567295   16.0 MiB    0C01  Mi
   3          567296       168339455   80.0 GiB    0700  
   4       168339456       170377215   995.0 MiB   0700  
   5       170377216       187154431   8.0 GiB     8200  Linux swap
   6       187154432       271040511   40.0 GiB    8300  Linux filesystem
   7       271040512       354926591   40.0 GiB    0700  Basic data partition
   8       354926592       438812671   40.0 GiB    0700  Basic data partition
   9       438812672       480755711   20.0 GiB    0700  Basic data partition
  10       480755712       963100671   230.0 GiB   0700  Basic data partition
  11       963100672      1445445631   230.0 GiB   0700  Basic data partition
  12      1445445632      1873264639   204.0 GiB   8300  Linux filesystem

参考資料

パーティション・タイプの一覧はこちら

Command (? for help): t
Partition number (1-12): 6
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): L
0700 Microsoft basic data  0c01 Microsoft reserved    2700 Windows RE          
3000 ONIE boot             3001 ONIE config           3900 Plan 9              
4100 PowerPC PReP boot     4200 Windows LDM data      4201 Windows LDM metadata
4202 Windows Storage Spac  7501 IBM GPFS              7f00 ChromeOS kernel     
7f01 ChromeOS root         7f02 ChromeOS reserved     8200 Linux swap          
8300 Linux filesystem      8301 Linux reserved        8302 Linux /home         
8303 Linux x86 root (/)    8304 Linux x86-64 root (/  8305 Linux ARM64 root (/)
8306 Linux /srv            8307 Linux ARM32 root (/)  8400 Intel Rapid Start   
8e00 Linux LVM             a000 Android bootloader    a001 Android bootloader 2
a002 Android boot          a003 Android recovery      a004 Android misc        
a005 Android metadata      a006 Android system        a007 Android cache       
a008 Android data          a009 Android persistent    a00a Android factory     
a00b Android fastboot/ter  a00c Android OEM           a500 FreeBSD disklabel   
a501 FreeBSD boot          a502 FreeBSD swap          a503 FreeBSD UFS         
a504 FreeBSD ZFS           a505 FreeBSD Vinum/RAID    a580 Midnight BSD data   
a581 Midnight BSD boot     a582 Midnight BSD swap     a583 Midnight BSD UFS    
a584 Midnight BSD ZFS      a585 Midnight BSD Vinum    a600 OpenBSD disklabel   
a800 Apple UFS             a901 NetBSD swap           a902 NetBSD FFS          
a903 NetBSD LFS            a904 NetBSD concatenated   a905 NetBSD encrypted    
a906 NetBSD RAID           ab00 Recovery HD           af00 Apple HFS/HFS+      
af01 Apple RAID            af02 Apple RAID offline    af03 Apple label         
Press the  key to see more codes: