10
2

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 5 years have passed since last update.

inodeを使い切ってみる

Posted at

検証のために inode を枯渇させて見た時の自分メモ

inodeとは

inode

inode(アイノード)は、ext2などのUnix系ファイルシステムで古くから使われているデータ構造である。inode にはファイル、ディレクトリなどのファイルシステム上のオブジェクトに関する基本情報が格納される。

iノード(inode)とは

ext2や、ext3、ext4というファイルシステムの上で、ファイルやディレクトリを管理するためのデータの事をiノード(inode)といいます。ファイルには、実データの他に、作成者、グループ、作成日時、サイズ等々の属性的な情報が存在しますが、この属性的な情報の部分をiノード(inode)はデータとしてもちます。

ファイルシステムを作成した時に、ファイルの実際のデータが記録されるデータ領域とともにiノード(inode)領域というものが作成され、この領域へiノード(inode)の情報が書き込まれます。

検証環境

  • amzn2-ami-hvm-2.0.20180810-x86_64-gp2(ami-08847abae18baa040)
$echo $SHELL
/bin/bash

やってみる

# df -i オプションを付与することで各ファイルシステムの inode使用状況が確認出来る
$ df -i
ファイルシス   Iノード I使用   I残り I使用% マウント位置
devtmpfs        118400   291  118109     1% /dev
tmpfs           122812     1  122811     1% /dev/shm
tmpfs           122812   346  122466     1% /run
tmpfs           122812    16  122796     1% /sys/fs/cgroup
/dev/nvme0n1p1 4193216 38672 4154544     1% /
tmpfs           122812     1  122811     1% /run/user/1000

$cd /dev/shm/

# ファイルを一つ作ると残りが減る
$touch hoge
$df -i |grep shm
tmpfs           122812     2  122810     1% /dev/shm

# 大量にファイルを作る
$for i in {1..122808}; do touch ${i}.txt; done

# 残り1
$df -i |grep shm
tmpfs           122812 122811       1   100% /dev/shm
$touch poyo

# エラー。No space left on deviceとなる
$touch poyoyon
touch: `poyoyon' に touch できません: No space left on device

# inodeを使い切っているがディスク容量としては使い切ってない
$df -i |grep shm
tmpfs           122812 122812       0   100% /dev/shm
$df |grep shm
tmpfs               491248       0  491248    0% /dev/shm

やってみたあとで以下の類似記事があることも分かった

inode (アイノード) を枯渇させてみる

10
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
10
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?