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

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

问题描述

如何快速在Linux上创建大文件( Red Hat Linux )系统?

dd 可以完成这项工作,但是要从/dev/zero中读取并编写当您需要一个大小为数百GB的文件进行测试时,将其放入驱动器可能需要很长时间.

我不在乎文件的内容,我只想快速创建它.该怎么办?

使用稀疏文件对此不起作用.我需要为文件分配磁盘空间.

其他答案中的

解决方案

dd是一个很好的解决方案,但为此目的它很慢.在Linux(和其他POSIX系统)中,我们有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 from the other answers is a good solution, but it is slow for this purpose. In Linux (and other POSIX systems), we have fallocate, which uses the desired space without having to actually writing to it, works with most modern disk based file systems, very fast:

For example:

fallocate -l 10G gentoo_root.img

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

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