LoginSignup
1
2

More than 3 years have passed since last update.

さくらVPSのスケールアップで/を拡張する

Last updated at Posted at 2020-03-26

「プランをあげたのでストレージ増やしといて」って言われたけど、どうやるんじゃい、ってメモ。

環境

CentOS8のカスタムイメージをでインストールしてます。
パーディションはインストーラのおまかせ。

ガイドに従ってやってみる

CentOS7向けの公式のガイド

を参考に、必要なパッケージをインストールして、パーティションをソート、をします。

sudo su -
yum -y install gdisk
sgdisk -s /dev/vda

この後、ドキュメントでは新規パーティション作ってるんだけど、そうじゃないんだよなあ。。。

とりあえず現状確認。

# gdisk -l /dev/vda
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.
Disk /dev/vda: 419430400 sectors, 200.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): ********-****-****-****-************
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 419430366
Partitions will be aligned on 2048-sector boundaries
Total free space is 314576829 sectors (150.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048            4095   1024.0 KiB  EF02  BIOS
   2            4096         1028095   500.0 MiB   0700  Microsoft
   3         1028096         9416703   4.0 GiB     8200  Linux
   4         9416704        11513855   1024.0 MiB  8300  
   5        11513856       104855551   44.5 GiB    8E00  


# lsblk
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                          11:0    1 1024M  0 rom  
vda                         252:0    0  200G  0 disk 
├─vda1                      252:1    0    1M  0 part 
├─vda2                      252:2    0  500M  0 part 
├─vda3                      252:3    0    4G  0 part 
├─vda4                      252:4    0    1G  0 part /boot
└─vda5                      252:5    0 44.5G  0 part 
  ├─******************-root 253:0    0 40.4G  0 lvm  /
  └─******************-swap 253:1    0  4.1G  0 lvm  [SWAP]

LVM、論理パーティションだからうまく増やせそうなはずなんだけれど、とググりますに

パーティションを広げる

さくらのVPSでストレージ容量増加後にパーティションを拡張する | 己で解決!泣かぬなら己で鳴こうホトトギス

なるほどね。パーティションマップ上で、古いの削除&同じとこに大きいの作成で容量増やすのね。理解。

やってみて、再起動。

gdisk -l /dev/vda
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.
Disk /dev/vda: 419430400 sectors, 200.0 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): ********-****-****-****-************
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 419430366
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            4095   1024.0 KiB  EF02  BIOS
   2            4096         1028095   500.0 MiB   0700  Microsoft
   3         1028096         9416703   4.0 GiB     8200  Linux
   4         9416704        11513855   1024.0 MiB  8300  
   5        11513856       419430366   194.5 GiB   8300  Linux filesystem

パーティションマップ上は増えた。

# lsblk
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                          11:0    1 1024M  0 rom  
vda                         252:0    0  200G  0 disk 
├─vda1                      252:1    0    1M  0 part 
├─vda2                      252:2    0  500M  0 part 
├─vda3                      252:3    0    4G  0 part 
├─vda4                      252:4    0    1G  0 part /boot
└─vda5                      252:5    0 44.5G  0 part 
  ├─******************-root 253:0    0 40.4G  0 lvm  /
  └─******************-swap 253:1    0  4.1G  0 lvm  [SWAP]

が、lsblkだと増えてない。
vda5が増えればいいんだけれど。

物理ボリュームを拡張する

LVMっての、物理ボリューム(PV)ってのの上に論理ボリューム(LV)があるらしく。

先にPhysical volumeを拡張します

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda5
  VG Name               ****************
  PV Size               <44.51 GiB / not usable 0   
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              11394
  Free PE               0
  Allocated PE          11394
  PV UUID               ******-****-****-****-****-****-******
# pvresize /dev/vda5
  Physical volume "/dev/vda5" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized
# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda5
  VG Name               ****************
  PV Size               <194.51 GiB / not usable 16.50 KiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              49794
  Free PE               38400
  Allocated PE          11394
  PV UUID               ******-****-****-****-****-****-******

よしよし。

論理ボリュームを拡張する

もちろん次は論理ボリューム。最大まで大きく。

# lvresize -l +100%FREE /dev/mapper/******************-root
  Size of logical volume ****************/root changed from 40.42 GiB (10348 extents) to 190.42 GiB (48748 extents).
  Logical volume ****************/root successfully resized.

ファイルシステムを拡張する

大きくなったボリュームを、ファイルシステムに認識させる。

# xfs_growfs /
meta-data=/dev/mapper/****************** isize=512    agcount=4, agsize=2648832 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=10595328, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=5173, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 10595328 to 49917952

結果

無事に拡張できました。

# df -h
Filesystem                           Size  Used Avail Use% Mounted on
devtmpfs                             1.9G     0  1.9G   0% /dev
tmpfs                                1.9G     0  1.9G   0% /dev/shm
tmpfs                                1.9G  8.5M  1.9G   1% /run
tmpfs                                1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/******************-root  191G   33G  159G  17% /
/dev/vda4                            976M  138M  772M  16% /boot
tmpfs                                379M     0  379M   0% /run/user/1000
1
2
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
2