Linux 快速创建大文件

Linux About 380 words

fallocate

直接分配一个指定容量的真实文件,创建速度很快。

-l,默认单位为字节。也可后跟kmgtpe来指定单位,分别代表KBMBGBTBPBEB

fallocate -l 5G test1.txt

truncate

truncate创建的并不是真实,创建速度很快。

truncate -s 5G test2.txt

dd

实际写入硬盘,创建速度较慢。

dd if=/dev/zero of=test3.txt bs=1G count=5

使用seek参数,并不会实际写入硬盘

dd if=/dev/zero of=test4.txt bs=1G count=5 seek=5G

查看磁盘占用

du -sh看到的是真实磁盘占用。

du -sh test1.txt

ls/ll看到的是虚拟磁盘占用。

ll -h test1.txt
Views: 428 · Posted: 2023-07-21

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh