gdiskを使用してLVMパーティションのサイズを変更する

gdiskを使用してLVMパーティションのサイズを変更する

2 つの論理ボリュームで LVM を使用します。

  • まず、LVをルートディレクトリにマウントします。/
  • 2番目のLVは/var/logディレクトリにマウントされます。

これら2つのLVは物理ボリューム/ dev / sda3に基づいています。 /dev/sda デバイスは GPT パーティションテーブルを使用します。

私の意図は、ディスク上のすべての利用可能なメモリを占有するように/ dev / sda3パーティションのサイズを変更することです。

gdiskこれを行うには、次のコマンドを使用しました。

これは私の現在のパーティションテーブルです。

Command (? for help): p
Disk /dev/sda: 4294967296 sectors, 2.0 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 546DEB45-C1DE-402B-BB51-4011AC159B4F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 4294967262
Partitions will be aligned on 8-sector boundaries
Total free space is 4188012544 sectors (2.0 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34          614433   300.0 MiB   EF00
   2          614434        17386294   8.0 GiB     8200
   3        17386295       106954718   42.7 GiB    8E00

これが3番目のパーティションのサイズを変更する方法です。

Command (? for help): d
Partition number (1-3): 3

Command (? for help): n
Partition number (3-128, default 3): 3
First sector (17386295-4294967262, default = 17386296) or {+-}size{KMGTP}:
Last sector (17386296-4294967262, default = 4294967262) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to 'Linux LVM'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
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.

実際、3番目のパーティションのサイズは次のとおりです。

Command (? for help): p
Disk /dev/sda: 4294967296 sectors, 2.0 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 546DEB45-C1DE-402B-BB51-4011AC159B4F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 4294967262
Partitions will be aligned on 8-sector boundaries
Total free space is 1 sectors (512 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34          614433   300.0 MiB   EF00
   2          614434        17386294   8.0 GiB     8200
   3        17386296      4294967262   2.0 TiB     8E00  Linux LVM

パーティションテーブルへの新しい変更をカーネルに伝える必要があります。

私が知っている3つのオプションがあります。

partprobe:

Error: Partition(s) 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.

partx -uv /dev/sda:

partition: none, disk: /dev/sda, lower: 0, upper: 0
/dev/sda: partition table type 'gpt' detected
/dev/sda: partition #1 resized
/dev/sda: partition #2 resized
/dev/sda: partition #3 resized
partx: /dev/sda: updating partition #3 failed: Invalid argument
partx: /dev/sda: error updating partition 3

reboot: マシンが修復されないため、KDB シェルに入りました。

質問:私は何が間違っていましたか? /dev/sda3パーティションのサイズを大きくする正しい方法は何ですか?

ちなみに、(以前に使用した2TiBの代わりに)100GiBなどのより小さなディスクを使用する場合、コマンドは次のようになりますpartx -uv /dev/sda布材エラーは発生しません(partprobeまだ文句を言っています)。これをどのように説明しますか?

ご協力ありがとうございます!

ベストアンサー1

結果からわかるように、gdisk開始区間の前後に違いがあります。

3 17386295 106954718 42.7GiB 8E00

そして

3 17386296 4294967262 2.0TiB 8E00 Linux LVM

これにより、LVMがPVに関する正しい情報を認識しないため、問題が発生します。これを修正してみてください(開始セクタを17386295に設定)。これにより、PVが復元され、パーティションの可視性が復元されます。

おすすめ記事