技術系

ubntuの容量不足でGUIが立ち上がらなくなったが、ディスク容量の拡張で改善した話

タイトルの内容ですが容量不足となりaptコマンドもエラーが起きてしまいGUIも起動できなくなりました。これはまずい!

ubntuサーバは以前の投稿で建てたVM上のマシンになります。

aptコマンドでいろいろミドルウェア入れると思うのですが、ギリギリを攻めすぎたのかインストール途中で容量いっぱいのエラーが出てしまい、VM側の容量を拡張しようと思い、停止して再起動したらこの通り。

いくつかのプロセスがエラーとなりGUIが立ち上がってきません。

VM側コンソールの画面ですがこんな感じでずっと止まったまま。

ubntu:~$ sudo apt update
[sudo] ubntu のパスワード:
ヒット:1 http://security.ubuntu.com/ubuntu noble-security InRelease
エラー:1 http://security.ubuntu.com/ubuntu noble-security InRelease
  Splitting up /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_noble-securit                                                                                                             y_InRelease into data and signature failed
ヒット:2 http://jp.archive.ubuntu.com/ubuntu noble InRelease
エラー:2 http://jp.archive.ubuntu.com/ubuntu noble InRelease
  Splitting up /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_noble_InRel                                                                                                             ease into data and signature failed
ヒット:3 http://jp.archive.ubuntu.com/ubuntu noble-updates InRelease
エラー:3 http://jp.archive.ubuntu.com/ubuntu noble-updates InRelease
  Splitting up /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_noble-updat                                                                                                             es_InRelease into data and signature failed
ヒット:4 http://jp.archive.ubuntu.com/ubuntu noble-backports InRelease
エラー:4 http://jp.archive.ubuntu.com/ubuntu noble-backports InRelease
  Splitting up /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_noble-backp                                                                                                             orts_InRelease into data and signature failed
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
パッケージはすべて最新です。
W: 署名照合中にエラーが発生しました。リポジトリは更新されず、過去のインデックス                                                                                                              ファイルが使われます。GPG エラー: http://security.ubuntu.com/ubuntu noble-securi                                                                                                             ty InRelease: Splitting up /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_n                                                                                                             oble-security_InRelease into data and signature failed
W: 署名照合中にエラーが発生しました。リポジトリは更新されず、過去のインデックス                                                                                                              ファイルが使われます。GPG エラー: http://jp.archive.ubuntu.com/ubuntu noble InRe                                                                                                             lease: Splitting up /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_noble_                                                                                                             InRelease into data and signature failed
W: 署名照合中にエラーが発生しました。リポジトリは更新されず、過去のインデックス                                                                                                              ファイルが使われます。GPG エラー: http://jp.archive.ubuntu.com/ubuntu noble-upda                                                                                                             tes InRelease: Splitting up /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dist                                                                                                             s_noble-updates_InRelease into data and signature failed
W: 署名照合中にエラーが発生しました。リポジトリは更新されず、過去のインデックス                                                                                                              ファイルが使われます。GPG エラー: http://jp.archive.ubuntu.com/ubuntu noble-back                                                                                                             ports InRelease: Splitting up /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_di                                                                                                             sts_noble-backports_InRelease into data and signature failed
W: http://jp.archive.ubuntu.com/ubuntu/dists/noble/InRelease の取得に失敗しまし                                                                                                              た  Splitting up /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_noble_InR                                                                                                             elease into data and signature failed
W: http://jp.archive.ubuntu.com/ubuntu/dists/noble-updates/InRelease の取得に失                                                                                                              敗しました  Splitting up /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_n                                                                                                             oble-updates_InRelease into data and signature failed
W: http://jp.archive.ubuntu.com/ubuntu/dists/noble-backports/InRelease の取得に                                                                                                              失敗しました  Splitting up /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists                                                                                                             _noble-backports_InRelease into data and signature failed
W: http://security.ubuntu.com/ubuntu/dists/noble-security/InRelease の取得に失敗                                                                                                             しました  Splitting up /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_noble                                                                                                             -security_InRelease into data and signature failed
W: いくつかのインデックスファイルのダウンロードに失敗しました。これらは無視され                                                                                                              るか、古いものが代わりに使われます。
ubntu@ubntu:~$ date
2025年  3月  5日 水曜日 16:38:53 JST
ubntu@ubntu:~$ sudo apt install --reinstall ubuntu-keyring
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
アップグレード: 0 個、新規インストール: 0 個、再インストール: 1 個、削除: 0 個、                                                                                                             保留: 0 個。
11.1 kB のアーカイブを取得する必要があります。
この操作後に追加で 0 B のディスク容量が消費されます。
E: /var/cache/apt/archives/ に充分な空きスペースがありません。

ディスクの確認をSSHからログインして確認する

幸いにもsshは生きているようなのでCLIから容量を確保する。

VMの設定でHDDを20GB→25GBに拡張を行った。起動している場合には変更できないので停止させてから拡張作業を行う。

ちなみにVMのスナップショットが残っていたせいでVmware WORKSTATION PROから拡張ができなかったので過去のスナップショットをすべて削除して実行した。

AWSとかならそんなことないんだけどなぁ...

その後VMを起動し、sshでログインを行いディスクの状況を確認する。

/dev/mapper/ubuntu--vg-ubuntu--lvの使用率が100パーセントとなっていることが確認できる。

ubntu@ubntu:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              387M  1.6M  386M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  9.8G  9.5G     0 100% /
tmpfs                              1.9G     0  1.9G   0% /dev/shm
tmpfs                              5.0M  8.0K  5.0M   1% /run/lock
/dev/sda2                          1.8G  103M  1.6G   7% /boot
tmpfs                              387M   96K  387M   1% /run/user/100

ロジカルボリューム(LV) sizeを確認する。10GB確保されているようだ。

ubntu@ubntu:~$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                9pKUVw-Hi2y-s2n8-jwT9-s6qX-eLGX-Z9M9rF
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2025-03-05 10:33:51 +0900
  LV Status              available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

VG(ボリュームグループ)の空き容量を確認する。

ubntu@ubntu:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               18.22 GiB
  PE Size               4.00 MiB
  Total PE              4665
  Alloc PE / Size       2560 / 10.00 GiB
  Free  PE / Size       2105 / 8.22 GiB
  VG UUID               V2znez-TUlk-cqW4-ZWKq-GUTV-ri1M-TcfFEu

Free PE / Sizeが 2105 / 8.22 GiBということでLVMを8.22GiB拡張可能ということがわかる。

ロジカルボリュームの拡張

以下のコマンドでロジカルボリューム(LV)の拡張を行う。ロジカルボリュームが10GiB~18.22GiBまで拡張された。

ubntu@ubntu:~$ sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 10.00 GiB (2560 extent                                                                                                             s) to 18.22 GiB (4665 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

ファイルシステムのタイプの確認を行う。

ubntu@ubntu:~$ lsblk -f
NAME FSTYPE FSVER LABEL                           UUID                                                                                                                                                FSAVAIL FSUSE% MOUNTPOINTS
loop0
     squash 4.0                                                                                                                                                                                             0   100% /snap/bare/5
loop1
     squash 4.0                                                                                                                                                                                             0   100% /snap/core22/1748
loop2
     squash 4.0                                                                                                                                                                                             0   100% /snap/firefox/5836
loop3
     squash 4.0                                                                                                                                                                                             0   100% /snap/snapd/23545
loop4
     squash 4.0                                                                                                                                                                                             0   100% /snap/gnome-42-2204/202
loop5
     squash 4.0                                                                                                                                                                                             0   100% /snap/gtk-common-themes/1535
loop6
     squash 4.0                                                                                                                                                                                             0   100% /snap/thunderbird/663
sda                                                                                                                                                                                          
tqsda1
x                                                                                                                                                                                            
tqsda2
x    ext4   1.0                                   5549c4d4-453e-4981-ab9b-57f76b                                                                                                             1139cc      1.5G     6% /boot
mqsda3
     LVM2_m LVM2                                  DmkUmk-lZsG-ayxW-VJHP-VuiW-wjp                                                                                                             Y-dueG8I
  mqubuntu--vg-ubuntu--lv
     ext4   1.0                                   81054b4b-270a-49a0-89aa-560e29                                                                                                             266de9         0    97% /
sr0  iso966 Jolie Ubuntu-Server 24.04.1 LTS amd64 2024-08-27-15-39-37-00

もし ext4 ファイルシステムを使っている場合は以下のコマンドを実行

sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

もし XFS ファイルシステムを使っている場合は以下のコマンドを実行

sudo xfs_growfs /

今回はext4システムのため以下を実行

ubntu@ubntu:~$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing require                                                                                                             d
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 4776960 (4k) blocks long.

実行後アップデートは問題なく実行できた。

ubntu@ubntu:~$ sudo apt update
ヒット:1 http://security.ubuntu.com/ubuntu noble-security InRelease
ヒット:2 http://jp.archive.ubuntu.com/ubuntu noble InRelease
ヒット:3 http://jp.archive.ubuntu.com/ubuntu noble-updates InRelease
ヒット:4 http://jp.archive.ubuntu.com/ubuntu noble-backports InRelease
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
パッケージはすべて最新です。

ディスクの状況をもう一度確認してみる。

ubntu@ubntu:~$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              387M  1.6M  386M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   18G  9.5G  7.5G  56% /
tmpfs                              1.9G     0  1.9G   0% /dev/shm
tmpfs                              5.0M  8.0K  5.0M   1% /run/lock
/dev/sda2                          1.8G  103M  1.6G   7% /boot
tmpfs                              387M   96K  387M   1% /run/user/1000

ロジカルボリュームは18GBまで増えており使用率も56%まで減った。

VMを再起動してみる。何とか起動が成功した。

デフォルトのインストールの20GBだとGUIを入れるとかなりギリギリだということがわかりました。

ubntuの容量不足及びGUIの起動が失敗するときはこの投稿を参考にしていただけたら幸いです。

-技術系

S