(bash) 如何找到文件系统支持的最大文件大小?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21926721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 09:39:24  来源:igfitidea点击:

(bash) How to find the max supported file-size of a filesystem?

linuxbashfilesystemsfusefat32

提问by RashaMatt

(bash) For a particular directory, I need to discover the maximum file sizesupported by that filesystem. The filesystem in question is probably mounted from external USB media, and might be FAT32, NTFS, exfat, or ext2.

(bash) 对于特定目录,我需要发现该文件系统支持的最大文件大小。有问题的文件系统可能是从外部 USB 介质挂载的,可能是 FAT32、NTFS、exfat 或 ext2。

I know I could partially guess the information from mount, but I'd like a cleaner solution - plus in the case of exfat, mountshows the filesystem type as "fuseblk".

我知道我可以部分猜测来自 的信息mount,但我想要一个更清晰的解决方案 - 加上在mountexfat的情况下,将文件系统类型显示为“fuseblk”。

(I am running Linux 3.2.0-4-686-pae #1 SMP Debian 3.2.51-1 i686 GNU/Linux)

(我正在运行 Linux 3.2.0-4-686-pae #1 SMP Debian 3.2.51-1 i686 GNU/Linux)



getconf FILESIZEBITS pathdoes not work for a fuseblkmount of an exfat filesystem: it returns 32, which is inaccurate. So it is not a general solution.

getconf FILESIZEBITS path不适用于fuseblk安装 exfat 文件系统:它返回 32,这是不准确的。所以这不是一个通用的解决方案。

回答by cnicutar

I think you can use getconf /pathfor this. Among the many sizes it prints there is also FILESIZEBITS. APUEsays this about it:

我想你可以用getconf /path这个。在它打印的众多尺寸中,还有FILESIZEBITS. APUE是这样说的:

minimum number of bits needed to represent, as a signed integer value, the maximum size of a regular file allowed in the specified directory

将指定目录中允许的常规文件的最大大小表示为有符号整数值所需的最小位数

There is some concern that getconfdoes not return filesystem-specific information:

有一些问题getconf不会返回特定于文件系统的信息:

getconf isn't in principle capable of answering such a question because it's filesystem dependent.

getconf 原则上不能回答这样的问题,因为它依赖于文件系统。

That is not the case:

事实并非如此:

[cnicutar@lux ~]$ getconf FILESIZEBITS /some/fuseblk/mount
32

[cnicutar@lux ~]$ getconf FILESIZEBITS /
64

回答by Riot

Edit: As the other answer says, you can use getconf FILESIZEBITS /mypathto find out the maximum number of bits the file size may have, and hence the largest size of file supported - cross-reference these against http://en.wikipedia.org/wiki/Integer_%28computer_science%29#Common_integral_data_typesfor an idea of what file size (in bytes) that relates to.

编辑:正如另一个答案所说,您可以使用getconf FILESIZEBITS /mypath找出文件大小可能具有的最大位数,从而找出支持的最大文件大小 - 将这些与http://en.wikipedia.org/wiki交叉引用/Integer_%28computer_science%29#Common_integral_data_types了解相关的文件大小(以字节为单位)。

You can also cross-reference the filesystem against a list such as http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits

您还可以根据列表交叉引用文件系统,例如http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits

df -Tgives you output that may assist in identifying your filesystems accurately.

df -T为您提供可能有助于准确识别文件系统的输出。

It's worth noting that other limits also exist that may be smaller than those imposed by the filesystem, such as the filesize limit specified by ulimit. You can query and set this with ulimit -f, but on most systems it will be "unlimited".

值得注意的是,还存在其他限制,它们可能小于文件系统施加的限制,例如 ulimit 指定的文件大小限制。您可以使用 查询和设置它ulimit -f,但在大多数系统上它将是“无限的”。