拡張パーティションlvmのサイズ変更

拡張パーティションlvmのサイズ変更

lsblkこれはとの私のディスクアーキテクチャですlvs。私がしたいのは、ブロックデバイスのサイズ(100GB)に合わせてsda5タイプを調整することです。Extended/dev/sda

   NAME             MAJ:MIN           RM      SIZE   RO    TYPE    MOUNTPOINT                              
sda              8:0               0       100G   0     disk                                            
|-sda1           8:1               0       243M   0     part    /boot                                   
|-sda2           8:2               0       1K     0     part                                            
`-sda5           8:5               0       49.8G  0     part                                            
|-osiris-root    254:0             0       45.8G  0     lvm     /                                       
`-osiris-swap_1  254:1             0       4G     0     lvm     [SWAP]                                  
sr0              11:0              1       1024M  0     rom                                             
LV               VG                Attr    LSize  Pool  Origin  Data%       Meta%  Move  Log  Cpy%Sync  Convert
root             osiris-wi-ao----  45.76g                                                               
swap_1           osiris-wi-ao----  4.00g   

他のツールや他のツールを使用してpartedこれを行う方法はありますかfdisk?よろしくお願いします。

fdisk -l /dev/sda*出力

Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors 
Units: sectors of 1 * 512 = 512 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes 
Disklabel type: dos 
Disk identifier: 0x00082e2b

Device Boot Start End Sectors Size Id Type 
/dev/sda1 * 2048 499711 497664 243M 83 Linux 
/dev/sda2 501758 104855551 104353794 49.8G 5 Extended 
/dev/sda5 501760 104855551 104353792 49.8G 8e Linux LVM

Disk /dev/sda1: 243 MiB, 254803968 bytes, 497664 sectors 
Units: sectors of 1 * 512 = 512 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes 
Disk /dev/sda2: 1 KiB, 1024 bytes, 2 sectors 
Units: sectors of 1 * 512 = 512 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes 
Disklabel type: dos 
Disk identifier: 0x00000000

Device Boot Start End Sectors Size Id Type 
/dev/sda2p1 2 104353793 104353792 49.8G 8e Linux LVM

Disk /dev/sda5: 49.8 GiB, 53429141504 bytes, 104353792 sectors 
Units: sectors of 1 * 512 = 512 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes

ベストアンサー1

拡張するには、sda5そのコンテナも拡張する必要がありますsda2。コマンドラインツールを使用する最も簡単な方法は、次を使用することですsfdisk

sfdisk /dev/sda

これにより、次の内容と一致する必要がある現在のパーティションテーブルが印刷されますfdisk

Disk image: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe59ec859

Old situation:

Device     Boot  Start       End   Sectors  Size Id Type
image1     *      2048    499711    497664  243M 83 Linux
image2          501758 104855551 104353794 49.8G  5 Extended
image5          501760 104855551 104353792 49.8G 83 Linux

Type 'help' to get more information.

>>>プロンプトですべてのパーティションのオーバーライドを開始します。

2048,497664,83,*

(これは最初のパーティションです:開始セクタ、セクタ長、タイプ、および*起動可能にする)。sfdisk答える

Created a new DOS disklabel with disk identifier 0x03408377.
Created a new partition 1 of type 'Linux' and of size 243 MiB.
      image1 :         2048       499711 (243M) Linux

そしてプロンプトimage2sda2)。入力する

501758,,5

セクター501758から始まり、その後の出力sfdiskで使用可能なすべてのスペースを占める拡張パーティションを作成するように指示します。sfdisk

Created a new partition 2 of type 'Extended' and of size 99.8 GiB.
      image2 :       501758    209715199 (99.8G) Extended

の場合は、image3次のように入力してください。

501760

sfdiskすると出力されます

Created a new partition 5 of type 'Linux' and of size 99.8 GiB.
      image5 :       501760    209715199 (99.8G) Linux

そしてプロンプトをimage6表示します。必要ありませんので、次のように入力してください。

quit

sfdiskこれにより、新しいパーティションテーブルが印刷され、それをディスクに書き込むかどうかを尋ねられます。

New situation:

Device     Boot  Start       End   Sectors  Size Id Type
image1     *      2048    499711    497664  243M 83 Linux
image2          501758 209715199 209213442 99.8G  5 Extended
image5          501760 209715199 209213440 99.8G 83 Linux

Do you want to write this to disk? [Y]es/[N]o: 

開始セクタがすべて一致し、sda1まだ正常であると確信している場合は、[ YWrite Partition Table](パーティションテーブルの書き込み)をクリックしてシェルに戻ります。

完了したら実行してください。

pvresize /dev/sda5

LVM PVのサイズを変更すると、新しく割り当てられたディスク容量を使用できます(新しいLVまたは既存のLV拡張)。

おすすめ記事