在Linux系统上快速创建一个大文件? [英] Quickly create a large file on a Linux system?

查看:631
本文介绍了在Linux系统上快速创建一个大文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何快速 在Linux上创建一个大文件( Red Hat Linux )系统? dd 将完成这项工作,但从 / dev读取/ zero 并且写入驱动器可能需要很长时间,当您需要一个文件数百GB的大小来测试...如果你需要反复这样做,时间真的加起来。 / p>

我不在乎文件的内容,我只是想要快速创建它。这样做如何?



使用稀疏文件将无法正常工作。我需要将文件分配给磁盘空间。

解决方案

dd 一个很好的解决方案,但是这个目的很慢。在Linux中,我们有 fallocate 。例如:

  fallocate -l 10G gentoo_root.img 


How can I quickly create a large file on a Linux (Red Hat Linux) system? dd will do the job, but reading from /dev/zero and writing to the drive can take a long time when you need a file several hundreds of GBs in size for testing... If you need to do that repeatedly, the time really adds up.

I don't care about the contents of the file, I just want it to be created quickly. How can this be done?

Using a sparse file won't work for this. I need the file to be allocated disk space.

解决方案

dd is a good solution, but it is slow for this purpose. In Linux, we have fallocate.

For example:

fallocate -l 10G gentoo_root.img

这篇关于在Linux系统上快速创建一个大文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆