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

ddコマンドでファイルを作成しようとしたらメモリが足りなくてプロセスkillされた

Posted at

ファイルを作成するコマンドの一つにddコマンドがある。

ddコマンドを用いて\tmpに1GBのファイルを作成しようとしたところ、以下のようになった。

[root@concentrate tmp]# dd bs=1000000000 count=1 if=/dev/zero of=file2
Killed
[root@concentrate tmp]#

Killed(プロセスkill)が発生している。
容量の問題化と思い、容量を確認したが、容量は5.8GB空いている。

[root@concentrate tmp]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 475M 0 475M 0% /dev
tmpfs 483M 0 483M 0% /dev/shm
tmpfs 483M 468K 483M 1% /run
tmpfs 483M 0 483M 0% /sys/fs/cgroup
/dev/xvda1 8.0G 2.3G 5.8G 29% /
tmpfs 97M 0 97M 0% /run/user/1000
[root@concentrate tmp]#

メモリに原因があると思ったので、vmstatコマンドを裏で実行させながら再度コマンドを実行したところ、
vmstatの出力が以下のようになった。

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 853328 0 45940 0 0 0 0 47 96 0 1 99 0 0
2 1 0 282916 0 17324 0 0 3492 132 266 311 0 30 35 1 34 ←この直後にkilled
0 0 0 868240 0 32648 0 0 13245 0 225 966 1 2 86 10 1

つまり、ファイルを作成する際、一時的にメモリに書き出して、作成し終わった段階でファイルとして保存しているような動きをしていることが分かった。(今更)

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