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

2

6

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

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

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


getconf FILESIZEBITS path does not work for a fuseblk mount of an exfat filesystem: it returns 32, which is inaccurate. So it is not a general solution.

Vladikavkaz answered 21/2, 2014 at 6:17 Comment(0)
D
5

I think you can use getconf /path for this. Among the many sizes it prints there is also FILESIZEBITS. APUE says this about it:

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 getconf does not return filesystem-specific information:

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

That is not the case:

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

[cnicutar@lux ~]$ getconf FILESIZEBITS /
64
Dissent answered 21/2, 2014 at 6:24 Comment(5)
getconf isn't in principle capable of answering such a question because it's filesystem dependent. Perhaps you're thinking of PATH_MAX which is the max length of a path.Ketonuria
@Ketonuria I disagree. In my example getconf prints information specific to the filesystem so your "it's filesystem dependent" argument has no standing.Dissent
Having just seen your edits, i stand corrected - FILESIZEBITS wasn't in the documentation i was looking at.Ketonuria
@Ketonuria I added what I have for various filesystemsDissent
Or just getconf FILESIZEBITS /pathDunlavy
K
2

Edit: As the other answer says, you can use getconf FILESIZEBITS /mypath to 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_types for an idea of what file size (in bytes) that relates to.

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

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

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".

Ketonuria answered 21/2, 2014 at 6:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.