1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

OCP 4.11でRHCOSの/sysrootのサイズを拡張する

Last updated at Posted at 2022-12-13

概要

色々検索をしていたら、OCPのRHCOSの/sysrootをインストール後に拡張している記事がいくつかあったので試しにやってみました。
(あくまでもちょっとした検証環境で、ノードの内蔵ディスクのサイズが足りなくなったけどOCPクラスタを再作成までしたくない時などには今回の対応は使えるかもしれません。)

環境

OCPのバージョンは4.11.16です。

[root@bastion-01 ~]# oc version
Client Version: 4.11.16
Kustomize Version: v4.5.4
Server Version: 4.11.16
Kubernetes Version: v1.24.6+5157800
[root@bastion-01 ~]#

ベアメタルのUPIの方法でOCPクラスタを導入しています。
(ベアメタルのUPIですが、ノード自身はVMwareの仮想マシンで作成しています。)

元々、コントロールプレーンやワーカーノードのディスクの最小要件は100GBですが、今回は検証環境が潤沢にあるわけではなかったので、40GBぐらいにしていました。
(参考) OCP 4.11 Docs / インストール / 11.3.3.2. クラスターインストールの最小リソース要件

一応最小要件に近づけるために、例として以下のnodeの内蔵ディスクのサイズを40GBから100GBに増やし/sysrootを拡張してみました。

Server vCPU Memory Disk notes
infra #1 24 48GB 40GB -> 100GB infra node
infra #2 24 48GB 40GB -> 100GB infra node
infra #3 24 48GB 40GB -> 100GB infra node

参考リンク

以下のリンクなどを参考にしました。

Red Hat Customer Portal / Community / Discussion / Unable to extend disk size of /sysroot
Red Hat Customer Portal / Community / Discussion / Extend Disk on Red Hat CoreOS

手順

現在の状況の確認

対象のノードのRHCOSの /sysroot のサイズは40GBとなっています。

[root@bastion-01 ~]# ssh core@infra-01 -- lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   40G  0 disk
|-sda1   8:1    0    1M  0 part
|-sda2   8:2    0  127M  0 part
|-sda3   8:3    0  384M  0 part /boot
`-sda4   8:4    0 39.5G  0 part /sysroot
[root@bastion-01 ~]#
[root@bastion-01 ~]# ssh core@infra-01 -- df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs   24G     0   24G   0% /dev
tmpfs          tmpfs      24G  168K   24G   1% /dev/shm
tmpfs          tmpfs      24G   48M   24G   1% /run
tmpfs          tmpfs      24G     0   24G   0% /sys/fs/cgroup
/dev/sda4      xfs        40G   11G   30G  26% /sysroot
tmpfs          tmpfs      24G  4.0K   24G   1% /tmp
/dev/sda3      ext4      364M  106M  236M  31% /boot
tmpfs          tmpfs     4.8G  4.0K  4.8G   1% /run/user/1000
[root@bastion-01 ~]#

ノードの仮想ディスクの拡張

OCPクラスタをシャットダウンします。
OCP 4.11 Docs / バックアップおよび復元 / 2. クラスターの正常なシャットダウン / 2.2. クラスターのシャットダウン

(Infra nodeなどTaintを付与しているノードがある際などにoc debug nodeができなかったりすることがあるので、以下ではRHCOSにsshで接続してshutdownコマンドを発行しました。)

[root@bastion-01 ~]# for node in $(oc get nodes -o jsonpath='{.items[*].metadata.name}'); do ssh core@${node} sudo shutdown -h 1; done

vCenterにログインし、仮想ディスクのサイズを増やしたい仮想マシンの設定から、仮想ディスクの容量を増やします。
今回は対象のノードの仮想ディスク1を40GBから100GBに変更しました。

変更前

変更後

対象ノードの仮想マシンの設定の変更が完了したら、仮想マシンの電源をオンにします。

2022-12-13-23-41-35.png

OCPクラスターが正常に稼働したことを確認します。

[root@bastion-01 ~]# oc get node
NAME         STATUS   ROLES    AGE    VERSION
infra-01     Ready    infra    154d   v1.24.6+5157800
infra-02     Ready    infra    154d   v1.24.6+5157800
infra-03     Ready    infra    154d   v1.24.6+5157800
master-01    Ready    master   154d   v1.24.6+5157800
master-02    Ready    master   154d   v1.24.6+5157800
master-03    Ready    master   154d   v1.24.6+5157800
storage-01   Ready    infra    8d     v1.24.6+5157800
storage-02   Ready    infra    8d     v1.24.6+5157800
storage-03   Ready    infra    8d     v1.24.6+5157800
worker-01    Ready    worker   154d   v1.24.6+5157800
worker-02    Ready    worker   154d   v1.24.6+5157800
[root@bastion-01 ~]#

/dev/sdaは100Gになりましたが、/sysroot/dev/sda4はまだ40GBのままです。

[root@bastion-01 ~]# ssh core@infra-01 -- lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  100G  0 disk
|-sda1   8:1    0    1M  0 part
|-sda2   8:2    0  127M  0 part
|-sda3   8:3    0  384M  0 part /boot
`-sda4   8:4    0 39.5G  0 part /sysroot
[root@bastion-01 ~]#

RHCOSの/sysrootの拡張

/sysrootの拡張手順は Red Hat Customer Portal / Community / Discussion / Unable to extend disk size of /sysroot のリンクを参照すると、OCP 4.11でも以下のコマンドで成功したようです。
ですので今回もこのコマンドを実際にやってみました。

(実行コマンド)

sudo su
growpart /dev/sda 4
sudo su -
unshare --mount
mount -o remount,rw /sysroot
xfs_growfs /sysroot

Infra node #1にSSHでログインして、上述のコマンドを実行してみました。
(通常はoc debug node <node>の方が良いと思います。)

(出力例)

[root@bastion-01 ~]# ssh core@infra-01
Red Hat Enterprise Linux CoreOS 411.86.202211072153-0
  Part of OpenShift 4.11, RHCOS is a Kubernetes native operating system
  managed by the Machine Config Operator (`clusteroperator/machine-config`).

WARNING: Direct SSH access to machines is not recommended; instead,
make configuration changes via `machineconfig` objects:
  https://docs.openshift.com/container-platform/4.11/architecture/architecture-rhcos.html

---
Last login: Tue Jul 12 14:40:46 2022 from 172.16.100.11
[core@infra-01 ~]$
[core@infra-01 ~]$ sudo su
[root@infra-01 core]#
[root@infra-01 core]# growpart /dev/sda 4
CHANGED: partition=4 start=1050624 old: size=82835423 end=83886047 new: size=208664543 end=209715167
[root@infra-01 core]#
[root@infra-01 core]# sudo su -
Last login: Tue Dec 13 14:54:19 UTC 2022 on pts/0
[root@infra-01 ~]#
[root@infra-01 ~]# unshare --mount
[root@infra-01 ~]#
[root@infra-01 ~]# mount -o remount,rw /sysroot
[root@infra-01 ~]#
[root@infra-01 ~]# xfs_growfs /sysroot
meta-data=/dev/sda4              isize=512    agcount=50, agsize=208895 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=0 inobtcount=0
data     =                       bsize=4096   blocks=10354427, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 10354427 to 26083067
[root@infra-01 ~]#
[root@infra-01 ~]# exit
logout
[root@infra-01 ~]# exit
logout
[root@infra-01 core]# exit
exit
[core@infra-01 ~]$
[core@infra-01 ~]$ exit
logout
Connection to infra-01 closed.
[root@bastion-01 ~]#

RHCOSの/sysrootの拡張の確認

/sysrootが拡張されたか確認します。
/dev/sdaが、100GBで、/dev/sda4/sysrootも100Gになったことが確認できました。

[root@bastion-01 ~]# ssh core@infra-01 -- lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  100G  0 disk
|-sda1   8:1    0    1M  0 part
|-sda2   8:2    0  127M  0 part
|-sda3   8:3    0  384M  0 part /boot
`-sda4   8:4    0 99.5G  0 part /sysroot
[root@bastion-01 ~]#
[root@bastion-01 ~]# ssh core@infra-01 -- df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs   24G     0   24G   0% /dev
tmpfs          tmpfs      24G  168K   24G   1% /dev/shm
tmpfs          tmpfs      24G   48M   24G   1% /run
tmpfs          tmpfs      24G     0   24G   0% /sys/fs/cgroup
/dev/sda4      xfs       100G   19G   82G  19% /sysroot
tmpfs          tmpfs      24G  4.0K   24G   1% /tmp
/dev/sda3      ext4      364M  106M  236M  31% /boot
tmpfs          tmpfs     4.8G  4.0K  4.8G   1% /run/user/1000
[root@bastion-01 ~]#

所感

(サポートされるかはわかりませんが)、検証環境でちょっとノードの/sysrootを拡張するのは、意外と簡単にできました。
わざわざOCPのクラスタの再作成までしなくて済んだので良かったです。

1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?