1
0

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.

ext4 ディスクの空き領域を回復する

Last updated at Posted at 2022-10-16

EPGStation を使った録画システムのディスクがいっぱいになってしまったので、いらないファイルを削除してちょっと整理。

空いたかな? と思ったら・・・

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/sda3       7.3T  6.9T     0 100% /
...

Avail 0 のまま。何故かな?

環境

# cat /etc/issue
Ubuntu 20.04.4 LTS \n \l

予約ブロック

tune2fs で見てみると


$ sudo tune2fs -l /dev/sda3
tune2fs 1.45.5 (07-Jan-2020)
Filesystem volume name:   <none>
Last mounted on:          /
...
Filesystem OS type:       Linux
Inode count:              244174848
Block count:              1953374720
Reserved block count:     97668736
Free blocks:              96948076
Free inodes:              242932556
First block:              0
Block size:               4096
Fragment size:            4096
...

こちらでは


Free blocks:              96948076

となってますね。

これは Reserved block count が


Reserved block count:     97668736

とありますが、
man tune2fs とすると、以下のような説明がありました。

DESCRIPTION
tune2fs allows the system administrator to adjust various tunable file system parameters on Linux ext2, ext3, or ext4 file systems. The current values of these options can be displayed by using the -l option to tune2fs(8) program, or by using the dumpe2fs(8) program.

Reserved block は root の稼働環境をキープするために デフォルトでは5% 予約されているそうです。今使っているディスクは 8TBytes なので、400GBytes ぐらいですね。

さっきの作業では、

/dev/sda3       7.3T  6.9T     0 100% /

とありますが、おそらく利用可能として表示しているのは Reserved block を引いた値ということでしょうか。
Reserved block の割合を下げる方法もあるらしいですが、今回は設定はこのままで更に不要ディスクを整理して空き領域を広げます。
今までの作業ではちょうど400Gぐらい空けていたので、もうちょっとがんばればいいことになります。

その後、
「拡張子の異なる同じファイルを削除するワンライナー」
https://qiita.com/nanbuwks/items/7f09b7aaed9ae17c4c1e#comment-8b55ed21b6de59a66bce

などを行い無事 Avail が確保できました。

# df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/sda3       7.3T  3.0T  3.9T  44% /

予約ブロックの割合を変更する

試しに、予約ブロックの割合を 5% から 3% に変更してみました。

# tune2fs -m 3 /dev/sda3
tune2fs 1.45.5 (07-Jan-2020)
Setting reserved blocks percentage to 3% (58601241 blocks)

すぐに終了。うまくいったかな?


# tune2fs -l /dev/sda3
tune2fs 1.45.5 (07-Jan-2020)
Filesystem volume name:   <none>
Last mounted on:          /
...
Filesystem OS type:       Linux
Inode count:              244174848
Block count:              1953374720
Reserved block count:     58601241
Free blocks:              738221457
Free inodes:              242933316
First block:              0
Block size:               4096
...

無事変更になったようです。
df の値も調べてみました。

# df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/sda3       7.3T  3.0T  4.1T  43% /
...

予約ブロック分は
Size-Used-Avail=0.2T
となっていて、大体3%ぐらいになっているようです。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?