[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Low cost] Wasabi object storage construction and operation service

[Low cost] Wasabi object storage construction and operation service

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “beSIM”

[Compatible with over 200 countries] Global eSIM “beSIM”

[Compatible with Chinese corporations] Chinese cloud / server construction, operation and maintenance

[Compatible with Chinese corporations] Chinese cloud / server construction, operation and maintenance

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

【超絶入門3分】できた!ディスク使用容量を調べる

こんにちは!
株式会社ビヨンド四国オフィスのペルシャ猫、いのうえです。

かっこよく言えばMSPの私が日々障害対応していくなかでよく使うコマンド「df
ディスクの容量を調べる・管理するコマンド。
ディスクには日々、たくさんのデータが残るため
放っておけば容量がいっぱいいっぱいになってしまいます。
そんな時、使用する「df」コマンドの使い方をペルシャ猫的ざっくり参考書としてご紹介します。

dfコマンド

ディスクの使用状況を調べる。

# df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs          485716       0    485716   0% /dev
tmpfs             503624       0    503624   0% /dev/shm
tmpfs             503624     392    503232   1% /run
tmpfs             503624       0    503624   0% /sys/fs/cgroup
/dev/xvda1       8376300 2864700   5511600  35% /
tmpfs             100728       0    100728   0% /run/user/1000

オプションをつけないと、こういった表示になります。

■-hオプション

# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        475M     0  475M   0% /dev
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           492M  392K  492M   1% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/xvda1      8.0G  2.8G  5.3G  35% /
tmpfs            99M     0   99M   0% /run/user/1000

K、M、G単位で表示してくれるので一目で多く使用しているところがどこなのか判断できます。

■-aオプション

# df -ah
Filesystem      Size  Used Avail Use% Mounted on
sysfs              0     0     0    - /sys
proc               0     0     0    - /proc
devtmpfs        475M     0  475M   0% /dev
securityfs         0     0     0    - /sys/kernel/security
tmpfs           492M     0  492M   0% /dev/shm
devpts             0     0     0    - /dev/pts
tmpfs           492M  392K  492M   1% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
cgroup             0     0     0    - /sys/fs/cgroup/systemd
pstore             0     0     0    - /sys/fs/pstore
cgroup             0     0     0    - /sys/fs/cgroup/devices
cgroup             0     0     0    - /sys/fs/cgroup/net_cls,net_prio
cgroup             0     0     0    - /sys/fs/cgroup/freezer
cgroup             0     0     0    - /sys/fs/cgroup/cpu,cpuacct
cgroup             0     0     0    - /sys/fs/cgroup/memory
cgroup             0     0     0    - /sys/fs/cgroup/pids
cgroup             0     0     0    - /sys/fs/cgroup/perf_event
cgroup             0     0     0    - /sys/fs/cgroup/blkio
cgroup             0     0     0    - /sys/fs/cgroup/hugetlb
cgroup             0     0     0    - /sys/fs/cgroup/cpuset
/dev/xvda1      8.0G  2.8G  5.3G  35% /
systemd-1          -     -     -    - /proc/sys/fs/binfmt_misc
debugfs            0     0     0    - /sys/kernel/debug
mqueue             0     0     0    - /dev/mqueue
hugetlbfs          0     0     0    - /dev/hugepages
sunrpc             0     0     0    - /var/lib/nfs/rpc_pipefs
tmpfs            99M     0   99M   0% /run/user/1000
binfmt_misc        0     0     0    - /proc/sys/fs/binfmt_misc

すべてのディスク容量が表示される。

■-Tオプション

# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  475M     0  475M   0% /dev
tmpfs          tmpfs     492M     0  492M   0% /dev/shm
tmpfs          tmpfs     492M  392K  492M   1% /run
tmpfs          tmpfs     492M     0  492M   0% /sys/fs/cgroup
/dev/xvda1     xfs       8.0G  2.8G  5.3G  35% /
tmpfs          tmpfs      99M     0   99M   0% /run/user/1000

ファイルのタイプを表示する。
マウントしているデバイスを確認することができる。

■-iオプション

# df -i
Filesystem      Inodes IUsed   IFree IUse% Mounted on
devtmpfs        121429   281  121148    1% /dev
tmpfs           125906     1  125905    1% /dev/shm
tmpfs           125906   346  125560    1% /run
tmpfs           125906    16  125890    1% /sys/fs/cgroup
/dev/xvda1     4193216 46429 4146787    2% /
tmpfs           125906     1  125905    1% /run/user/1000

inodeの使用量を表示する。

■ディレクトリを指定する

# df haruka
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1       8376300 2881132   5495168  35% /

harukaディレクトリが格納されている「xvda1」の容量が表示される。

まとめ

MSPにとって必須コマンドと言ってもいいくらい、よく使うコマンドです。
df」コマンドを使いこなすために、今回はオプションをご紹介させていただきました。
ディスクの使用容量や空き状況を定期的に把握することは大事なこと。
ディスク容量がいっぱいになってしまうと、
アップデートができなかったり、ログが残せなくなったりという問題が発生します。
ですから、定期的にディスク容量を確認し、整理することが障害を発生させないために大切です!

今後も、トライアンドエラーとやらを繰り返し、
お気に入りのコマンドや、個人的にもっと理解を深めたいコマンドに関してブログを書いていきます。

日々成長、日々前進。
毎日、私自身をアップデートしていかなければ!!!
最後まで読んでくださって、ありがとうございます。

この記事がお役に立てば【 いいね 】のご協力をお願いいたします!
0
読み込み中...
0 票, 平均: 0.00 / 10
614
X facebook はてなブックマーク pocket
[2024.6.30 CentOS support ended] CentOS server migration solution

[2024.6.30 CentOS support ended] CentOS server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

Akika Inoue

Belongs to the System Solutions Department.
He joined Beyond as a founding member of the Shikoku office.
I jumped into the IT industry with no experience. As an education team, we create curriculum and conduct training for new graduates, mid-career, and existing members.
The main business is server operation and maintenance.
Either way, we value your content.
Also belongs to the Web Content Division and YouTube Team.