適用対象: ✔️ Linux VM
この記事では、Azure Linux仮想マシンで2 TBを超えるデータ ディスクのマスター ブート レコード (MBR) パーティションのサイズを変更できない問題の解決策を提供します。
重要
この記事は、サポートされている 保証済みの Linux ディストリビューションに適用されます。
現象
fdisk
コマンドを実行して MBR パーティションのサイズを変更すると、次の警告メッセージが表示されます。
このディスクのサイズは 8.8 TB です。 DOS パーティション テーブル形式は、512 バイト セクターで 2 TB を超えるボリュームのドライブでは使用できません。 parted(1) と GUID パーティション テーブル形式 (GPT) を使用します。
コマンド サンプルを次に示します。
sudo fdisk /dev/sdd
コマンド出力のサンプルを次に示します。
WARNING: The size of this disk is 8.8 TB (8796093022208 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help):
Command (m for help): d
Selected partition 1
Partition 1 is deleted
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-4294967295, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4294967294, default 4294967294):
Using default value 4294967294
Partition 1 of type Linux and of size 2 TiB is set <--- HERE
Command (m for help): p
Disk /dev/sdd: 8796.1 GB, 8796093022208 bytes, 17179869184 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x7024d1b6
Device Boot Start End Blocks Id System
/dev/sdd1 2048 4294967294 2147482623+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
新しいサイズを確認するには、次の手順に従います。
次のコマンドを実行して、パーティション テーブルの変更をオペレーティング システム (OS) に通知します。
sudo partprobe /dev/sdd
次のコマンドを実行して、パーティション
/dev/sdd1
の新しいサイズを確認します。sudo lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,RO,MOUNTPOINT
コマンド出力は、パーティションのサイズが 2 TB のみに変更されたことを示しています。 コマンド出力の例を次に示します。
NAME TYPE FSTYPE LABEL SIZE RO MOUNTPOINT sda disk 32G 0 ├─sda1 part vfat 500M 0 /boot/efi ├─sda2 part xfs 500M 0 /boot ├─sda3 part xfs 31G 0 / └─sda4 part 2M 0 sdb disk 256G 0 └─sdb1 part ext4 256G 0 /mnt sdd disk 8T 0 └─sdd1 part ext4 2T 0 /appext4
原因
パーティションの境界とパーティション (ファイル システム) の種類の情報を含む MBR には、2^32 セクターのアドレス指定制限があります。 MBR パーティション データ構造内の 32 ビット アドレス制限により、ディスクとパーティションのサイズが制限されます。
512 バイトセクターの場合、MBR パーティションのアドレス制限は 2 TB です。 新しい 4Kn デバイスの場合、各論理セクターは 2^32 x 4,096 バイトまたは 16 TB です。
ソリューション
GUID パーティション テーブル (GPT) にはセクター アドレスの制限がないため、2 TB 以上のデータ ディスクには GPT を使用することをお勧めします。
データ ディスクで GPT を使用する 2 つの方法を次に示します。
ディスク上のデータの完全バックアップを作成し、GPT を再作成します。
パーティションの種類を MBR から GPT に変更する
重要
- 変更を行う前に、データ ディスクの スナップショット を取得します。
- この変更は、OS ディスクではなく、データ ディスクでのみ可能です。 OS ディスク上で実行すると、ブートできない状態になります。
- Red Hat の場合、 データを失うことなく MSDOS ラベルを GPT に変換することはできません。
手順 1: 現在のパーティション テーブルの種類を特定する
次のいずれかのツールを使用して、現在のデータ ディスクが MBR または GPT であるかどうかを確認します。
手順 2: パーティションを再作成する
Note
このセクションでは、 gdisk
ツールを使用して、パーティションを例として再作成します。
linux 仮想マシンにインストールされていない場合は、
gdisk
ツールをインストールします。sudo yum install gdisk -y
データ ディスクの現在のサイズを確認します。
sudo gdisk -l /dev/sdd | grep Disk | grep sectors
Disk /dev/sdd: 17179869184 sectors, 8.0 TiB
仮想マシンで実行されているアプリケーションを停止し、ファイル システムのマウントを解除します。
sudo systemctl stop myapp.service sudo umount /appext4
Note
myapp.service
と/appext4
の両方がエントリの例です。 それに応じて置き換えます。- データ ディスクのサイズを増やす必要がある場合は、Azure アカウントを使用して今すぐ行うことができます。 Azure portal でディスクのサイズを変更する場合、ダウンタイムが必要です。 詳細については、「 Azure マネージド ディスクの拡張」を参照してください。
gdisk
コマンドを使用して、パーティション番号 1 を再作成します。sudo gdisk /dev/sdd
GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present *************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing q if you dont want to convert your MBR partitions to GPT format! *************************************************************** Command (? for help): p --> PRINT PARTITION TABLE Disk /dev/sdd: 17179869184 sectors, 8.0 TiB Logical sector size: 512 bytes Disk identifier (GUID): 8A3DAD49-6916-4BC5-836B-2F90C5161C05 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 17179869150 Partitions will be aligned on 2048-sector boundaries Total free space is 12884903870 sectors (6.0 TiB) Number Start (sector) End (sector) Size Code Name 1 2048 4294967294 2.0 TiB 8300 Linux filesystem Command (? for help): d --> DELETE PARTITION TABLE Using 1 Command (? for help): n --> CREATE NEW PARTITION TABLE Partition number (1-128, default 1): --> PARTITION 1 First sector (34-17179869150, default = 2048) or {+-}size{KMGTP}: 2048 --> SAME 1th SECTOR AS THE ORIGINAL PARTITION Last sector (2048-17179869150, default = 17179869150) or {+-}size{KMGTP}: --> HIT ENTER TO USE THE WHOLE SPACE, IN THIS CASE 8 TB 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 --> PRINT PARTITION TABLE Disk /dev/sdd: 17179869184 sectors, 8.0 TiB Logical sector size: 512 bytes Disk identifier (GUID): 8A3DAD49-6916-4BC5-836B-2F90C5161C05 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 17179869150 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 17179869150 8.0 TiB 8300 Linux filesystem Command (? for help): w --> APPLY CHANGES Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): Y --> "Y" TO APPLY OK; writing new GUID partition table (GPT) to /dev/sdd. Warning: The kernel is still using the old partition table. The new table will be used at the next reboot. The operation has completed successfully.
パーティション スタイルが GPT に変更されていることを確認します。
sudo gdisk -l /dev/sdd | grep -A4 '^Partition table scan:'
Partition table scan: MBR: protective BSD: not present APM: not present GPT: present
次のコマンドを実行して、パーティションのサイズを確認します。
sudo lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,RO,MOUNTPOINT
NAME TYPE FSTYPE LABEL SIZE RO MOUNTPOINT sda disk 32G 0 ├─sda1 part vfat 500M 0 /boot/efi ├─sda2 part xfs 500M 0 /boot ├─sda3 part xfs 31G 0 / └─sda4 part 2M 0 sdb disk 256G 0 └─sdb1 part ext4 256G 0 /mnt sdd disk 8T 0 └─sdd1 part ext4 2T 0 /appext4
自動的にマウントされたファイル システムのマウントを解除し、修復します。
sudo umount /appext4 sudo fsck.ext4 -fy /dev/sdd1
e2fsck 1.42.9 (28-Dec-2013) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdd1: 6728/134217728 files (0.2% non-contiguous), 8849024/536870655 blocks
ファイル システムを再マウントします。
sudo mount /appext4
ファイル システムのサイズを変更します。
ファイル システムが
ext4
されている場合は、次のコマンドを実行します。sudo resize2fs /dev/sdd1
resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/sdd1 is mounted on /appext4; on-line resizing required old_desc_blocks = 256, new_desc_blocks = 1024 The filesystem on /dev/sdd1 is now 2147483387 blocks long.
ファイル システムが
XFS
されている場合は、次のコマンドを実行します。sudo xfsgrowfs /dev/sdd1
新しいサイズを確認します。
sudo lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,RO,MOUNTPOINT
NAME TYPE FSTYPE LABEL SIZE RO MOUNTPOINT sda disk 32G 0 ├─sda1 part vfat 500M 0 /boot/efi ├─sda2 part xfs 500M 0 /boot ├─sda3 part xfs 31G 0 / └─sda4 part 2M 0 sdb disk 256G 0 └─sdb1 part ext4 256G 0 /mnt sdc disk 1T 0 └─sdc1 part LVM2_member 1T 0 └─vgtest1-lvol1 lvm ext4 500G 0 sdd disk 8T 0 └─sdd1 part ext4 8T 0 /appext4 sde disk 1T 0
サードパーティの情報に関する免責事項
この資料に記載されているサードパーティ製品は、マイクロソフトと関連のない他社の製品です。 明示的か黙示的かにかかわらず、これらの製品のパフォーマンスや信頼性についてマイクロソフトはいかなる責任も負わないものとします。
お問い合わせはこちらから
質問がある場合やヘルプが必要な場合は、サポート要求を作成するか、Azure コミュニティ サポートにお問い合わせください。 Azure フィードバック コミュニティに製品フィードバックを送信することもできます。