73
65

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.

Linux で任意のサイズのファイルを作る

Posted at

基本的に以下に書いてありましたが、メモ。

以下は 1GByte のファイルを作る例

# 1Gbyte のファイルを作成
$dd if=/dev/zero of=1G.dummy bs=1M count=1000

# 確認
$ls -lh |grep 1G
-rw-rw-r--. 1 ec2-user ec2-user 1000M  4月  6 04:44 1G.dummy

以下は 9MByte のファイルを作る例

# 9Mbyte のファイルを作成
$dd if=/dev/zero of=test9M bs=1M count=9

# 確認
$ls -lh |grep 9M
-rw-rw-r--. 1 ec2-user ec2-user  9.0M  4月  6 04:43 test9M

man ddを見るとなるほどという感じ。

$man dd

       if=FILE
              read from FILE instead of stdin
              
       bs=BYTES
              read and write up to BYTES bytes at a time
              
       count=N
              copy only N input blocks
              
       of=FILE
              write to FILE instead of stdout

bs と count オプションを変えれば任意のサイズのファイルが作成できる。

73
65
3

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
73
65

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?