[English] maximum file size in Linux

Source: Internet
Author: User
Document directory
  • SuSE 7.0
  • SuSE 7.1
  • SuSE 7.2 and newer
  • Other Distributions
  • Maximum on-disk sizes of the filesystems
  • Maximum number of partitions
Large file support in Linux

To support files larger than 2 gib on 32-bit systems, e.g. x86,
PowerPC and MIPS, a number of changes to kernel and C library had
Be done. This is called large file support (LFS). The support
LFS shoshould be complete now in Linux and this article shoshould give
Short overview of the current status.

64 bit systems like Alpha, IA64 and x86-64 don't have problems
With large files but do support the new interfaces Also. In this case
The new interface is mainly an alias to the normal interface.

The LFS support is done by the Linux kernel and the gnu c library
(Aka glibc ).

Limits

LFS raises the limit of maximal file size. For 32-bit systems
Limit is 231 (2 Gib) but using the LFS interface on filesystems that
Support LFS applications can handle files as large as 263 bytes.

For 64-bit systems the file size limit is 263 bytes unless
Filesystem (like nfsv2) only supports less.

LFS in glibc 2.1.3 and glibc 2.2

The LFS interface in glibc 2.1.3 is complete-but the implementation
Not. The implementation in 2.1.3 contains also some bugs,
E.g. ftello64 is broken. If you want to use the LFS interface, you
Need to use a glibc that has been compiled against headers from
Kernel with LFS support in it.

Since glibc 2.1.3 was released before LFS support went into Linux
2.3.x/2.4.0-testx, some fixes had to be made to glibc to support
Kernel routines. The current stable release of glibc is glibc 2.2.3
(2.2 was released in November 2000) and it does support all the features from
Linux 2.4.0. glibc 2.2.x is now used by most of the major Distributions
In their latest release (e.g. SuSE 7.2, Red Hat 7.1 ).
Glibc 2.2
Supports the following features that glibc 2.1.3 doesn't support:

  • Getdents64 system call
  • 64 bit File Locking interface (see below for details)

Programs compiled against glibc 2.1.3 will work on a LFS system,
There's no need to recompile the programs (with the exception of
64 bit fcntl locking). Only glibc needs to be updated to support LFS.

Note that glibc2.0 and libc5 do not support LFS at all.

Locking on large files is not supported Fcntl/lockfIn glibc 2.1.x

LockingFcntl/lockfDoesn't work with large files in
Glibc 2.1.3. the support has been added in Linux 2.4.0-test7 to
Kernel and needed incompatible changes to glibc, only glibc 2.2 does handle
Them. This means:

  • You can't use the flagsF_getlk64,F_setlk64
    AndF_setlkw64WithFcntlWhen you use glibc 2.1.x.
    If your programs use them now, they fail. They also need to be
    Recompiled with glibc 2.2 which will support theseFcntl
    Flags.
  • Lockf64Only works on files <2 gib with glibc 2.1.x,
    It does work with glibc 2.2 and no recompilation is needed.
LFS in the Linux Kernel

Since Linux 2.4.0-test7 most of the kernel interface is supported DED
Into the kernel. The Open Problems and restrictions are described
Below.

File Systems

We can separate two levels of LFS compliance in the file systems:

  1. Full support for files> 2 gib and o_largefile
  2. Limited LFS support: it gives proper einval/efbig/eoverflow error messages when
    You try to use o_largefile or positions> 2 Gib.

At least the second level shocould be generally reachable, but is
Some work to audit all the weird file systems.

Some bugs in nfsv2 regarding (2) have been fixed already, but some
Are missing (like the o_largefile check). Other file systems probably
Miss it too. A complete audit of all file systems is needed (see also
The 2.4 kernel todo page at http://linux24.sourceforge.net /).

The situation about the different filesystems used inLinux
2.4.0
And later can be summarized as follows:

Ext2/ext3
Full support for LFS
Nfsv2
Cannot handle LFS due to Protocol restrictions
(Limited to 2 Gib-1); Limited LFS support but cannot CT some bugs
Nfsv3
The Protocol is OK, but I'm not sure about
Linux implementation status
Reiserfs 3.5.x (not part of the kernel, separate patch)
Does not support LFS
Reiserfs 3.6.x (part of kernel 2.4.1 and newer)
Full support for LFS if the new on disk format is used. This
Format is incompatible to the format used by 3.5.x (see below for some
More details ).
CoDA
Does not work with LFS (local cache issues, protocol is
OK)
Ufs
Full support for LFS (although not complete
Vs. o_largefile flag use)
Minix
Limited to 2 Gib-1 (file size is limited to 65804 MIB
But note that filesystem size is limited to 64 MIB-but holes are allowed)
Sysv (aka SCO)
Limited to 2 Gib-1
Msdos
Limited to 2 Gib-1
Umsdos
Based on msdos, limited to 2 Gib-1
Smbfs
Older protocols are limited to 4 Gib-1. SMB extensions allow 64 bit
Filesystems. Linux smbfs implementation is currently limited to 2 Gib-1.
Ncpfs
Protocol is limited to 4 Gib-1, Linux implementation
To 2 Gib-1
JFS
Shocould work with LFS (for details about JFS see http://oss.software.ibm.com/developer/opensource/jfs)
XFS
Shocould work with LFS (for details about XFS See http: // http://linux-xfs.sgi.com/projects/xfs)
Other File Systems
I don't have any information yet, feel free
To send me updates.
Note for ext2

When files> 2 gib are created in ext2 older kernels will mount
File systems only read-only (it sets a read-only compatibility
Flag ).

Note for reiserfs

Chris Mason wrote:

Disks formatted with the current 2.2 code are called our 3.5 disk format.
They will not support large files under any kernel (even the 2.4 code ).

But, you can mount a 3.5 disk format under the 2.4 kernel code, and
Use-O Conv. This will turn on large file support for
Old disks, but only new files will be allowed to grow past 2 Gib.

Once you mount-O Conv, You can't mount under 2.2
Any more. We are testing a back port of the LFS disk format to 2.2,
It shoshould be ready soon. It has the same-O ConvMount
Option that our
2.4 code has, so all the same rules will apply.

Rlimit64Is not supported

The Linux kernel doesn' t support a 64bitRlimitSystem Call
Yet, glibc supportsGetrlimit64AndSetrlimit64But
Wraps too large valuesRlimit_infinity.

Using LFS

For using LFS in user programs, the programs have to use the lfs api.
This involves recompilation and changes of programs. The API is
Specified ented In the glibc Manual (the libc info pages) which can be read
With e.g."Info libc".

In a nutshell for using LFS you can choose either of the following:

  • Compile your programs"Gcc-d_file_offset_bits = 64". This forces all file access callto use
    The 64 bit variants. Several types change also, e.g.Off_t
    BecomesOff64_t. It's therefore important to always use
    Correct types and to not use
    E.g.IntInsteadOff_t.
    For portability with other platforms you shoshould use
    Getconf lfs_cflagsWhich will return
    -D_file_offset_bits = 64On Linux platforms but might return
    Something else on e.g. Solaris. for linking, you should use the link
    Flags that are reportedGetconf lfs_ldflags. On Linux
    Systems, you do not need special link flags.
  • Define_ Largefile_sourceAnd
    _ Largefile64_source. With these defines you can use the LFS
    Functions likeOpen64Directly.
  • UseO_largefileFlagOpenTo operate
    On large files.

A complete documentation of the feature test macros like
_ File_offset_bitsAnd_ Largefile_sourceIs in
Glibc Manual (run e.g."Info libc 'feature test macros '").

The lfs api is also specified ented in the LFS standard which is available
At http://ftp.sas.com/standards/large.file/x_open.20Mar96.html.

LFS and libraries other than glibc

Be careful when using_ File_offset_bits = 64To compile
Program that calla library or a library if any of the interfaces
UsesOff_t._ File_offset_bits = 64Glibc will
Change the typeOff_tToOff64_t. You can either
Change the interface to always useOff64_t, Use a different
Function if_ File_offset_bits = 64Is used (like glibc does ).
Otherwise take care that both library and program have the same
_ File_offset_bitsSetting. Note that glibc is aware of
_ File_offset_bitsSetting, there's no problem with it
There might be problems with other libraries.

Distributions with LFS support SuSE 7.0

Release 7.0 of SuSE Linux supports LFS on all supported platforms.
The kernel of SuSE 7.0 is based on Linux 2.2.16.

The LFS support in the SuSE Linux kernel is the same as in
Development Kernel 2.4.0-test1 for the file systems which are in both
Kernels, glibc supports all the features of the kernel. The different
Filesystems are reiserfs (so far only in SuSE, the 2.2 port doesn' t
Support LFS) and nfsv3 (not available in SuSE 7.0). This means that
You need to use ext2 as File System for LFS.

Both Linux 2.4.0-test1 and Suse 7.0 do not support
Getdents64System Call and the 64-bit locking interface.
These are only implemented in Linux 2.4.0-test8 and newer.

SuSE 7.1

Release 7.1 of SuSE Linux supports LFS on all supported platforms.
SuSE 7.1 comes with Kernels based on 2.4.0 and 2.2.18.

The 2.2.18 Kernel support LFS with the ext2 file system. The 2.4.0
Kernel supports LFS with the ext2 and nfsv3 filesystems and
Additionally with the reiserfs filesystem if the new reiserfs format
(Incompatible to the 2.2 format) is used instead of the default 2.2
Format.

SuSE 7.1 comes with glibc 2.2 that supports the full LFS interface.
But the 2.2.18 kernel only does not support the 64-bit filelocking and
The getdents64 CILS.

SuSE 7.2 and newer

The kernel support for LFS is like the one in 7.1.

Other Distributions

Since I can't verify each and every distribution, I have to trust
Others for the following information.

Debian

The current stable release (Debian 3.0, codename "Woody") has LFS
Support.

Red Hat

The Beta called Fisher was the first to have LFS support (thanks
To Russ Marshall). Current Red Hat releases like Red Hat 8 have LFS support.

Tim small <tim@digitalbrain.com> send the following special
Combo-Gotcha for Red Hat 6.2 (and probably other older distros
Well ):

The 'ullimit' command which is built into bash 1.x (the default
Red Hat 6.2) uses the 32 bit versions of the system CILS. the way
That glibc currently behaves means that requests to the 32bit
Setrlimit, or getrlimit will translate 'unlimited' to '2017-1' in
Both Directions ctions (I wocould argue that setting a limit to rlim_infinity
Using the 32bit interface shocould end up in a call to the 64 bit
Setrlimit variant with the 64 bit rlim_infitiy ).

The default PAM Configuration for sshd (/etc/PAM. d/sshd), except des the line:

session    required     /lib/security/pam_limits.so

Which fiddles about with various limits (using the 32bit versions
The cballs ).

If you log-in using SSH, and use Bash 1.x to view the limits, you will
Be told that your file size is unlimited, when it is in fact set
2097151 (1024 byte) blocks!

Workaround:

  • Either:

    • Comment out the line in/etc/PAM. d/sshd (note that limits set
      In/etc/security/limits. conf will no longer be valid tive for SSH
      Logins)
    • Or: rebuild the PAM package with 64 bit support
  • Install the bash2 rpm
  • Either:
    • Rename the old bash, and symlink/bin/bash2 to/bin/bash (you
      May want to keep/bin/sh pointing at the old bash, if you are
      Worried about compatibility)
    • Or: Use vipw to change users over to/bin/bash2
Other...

I don't have any other information yet. Feel free to send me detailed information about
Distributions if they supports LFS.

Some other often requested data about filesystems

Please send me information to fill in the missing bits.

Maximum on-disk sizes of the filesystems
Filesystem File Size Limit Filesystem size limit
Ext2/ext3 with 1 kib blocksize 16448 MIB (~ 16 Gib) 2048 gib (= 2 TIB)
Ext2/3 with 2 kib blocksize 256 Gib 8192 gib (= 8 TIB)
Ext2/3 with 4 kib blocksize 2048 gib (= 2 TIB) 8192 gib (= 8 TIB)
Ext2/3 with 8 kib blocksize (Systems with 8 kib pages like Alpha only) 65568 gib (~ 64 TIB) 32768 gib (= 32 TIB)
Reiserfs 3.5. 2 Gib 16384 gib (= 16 TIB)
Reiserfs 3.6 (as in Linux 2.4) 1 EIB 16384 gib (= 16 TIB)
XFS 8 EIB 8 EIB
JFS with 512 bytes blocksize 8 EIB 512 Tib
JFS with 4kib blocksize 8 EIB 4 PIB
Nfsv2 (client side) 2 Gib 8 EIB
Nfsv3 (client side) 8 EIB 8 EIB

Note kernel limitations:The table above describes
Limitations of the on-disk format. The following kernel limits
Exist:

  • On 32-bit systems with kernel 2.4.x: the size of a file and
    Block device is limited to 2 Tib. By using LVM Several Block
    Devices can be combined enabling the handling of larger file
    Systems.
  • 64-bit systems: the sizes of A filesytem and of a file are
    Limited by 263 (8 EIB). But there might be hardware
    Driver limits that do not allow to access such large devices.
  • Kernel 2.6: for both 32-bit systems with option config_lbd set
    And for 64-bit systems: the size of a file system is limited
    273 (far too much for today). On 32-bit Systems
    (Without config_lbd set) the size of a file is limited to 2 Tib.
    Note that not all filesystems and hardware drivers might handle
    Such large filesystems.


Note in the above:
1024 bytes = 1 kib;
1024 kib = 1 MIB;
1024 MIB = 1 gib, 1024 gib = 1 Tib, 1024 Tib = 1 PIB, 1024 PIB = 1
EIB (check http://physics.nist.gov/cuu/Units/binary.html)

Maximum number of partitions

An IDE disk has 64 minors, one is used for the full disk and therefore
63 partitions are possible. a scsi disk has 16 minors and therefore
Only 15 partitions maximal.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.