Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 951
RashaMatt Avatar asked Feb 21 '14 06:02

RashaMatt


People also ask

How do I determine file size in bash?

Another method we can use to grab the size of a file in a bash script is the wc command. The wc command returns the number of words, size, and the size of a file in bytes.


1 Answers

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
like image 74
cnicutar Avatar answered Sep 28 '22 02:09

cnicutar