What is the maximum size a single file can be on Ubuntu?
For most installations of Ubuntu Linux, a single file can be as large as the capacity of the physical drive it's on. Most installations of Ubuntu 7.04 use the ext3 file system with a 4 KiB block size which can support a single file of 2TiB in size (which is indeed larger than most hard-drive's capacity at the time of this writing).
Wikipedia says that the ext3 file system's max file size is between 16GiB and 64TiB. The maximum file size can vary because a file system's block size can vary arbitrarily among partitions that have been formatted.
To determine the maximum file size, you must first determine your file system's block size. The table below indicates what the maximum file size will be for common block sizes:
|Block size||Max file size||Max filesystem size|
So how do you determine the block size of a file system?
- Determine the "device path" Linux uses to refer to the formatted partition for which you're trying to determine the maximum file size.
- Use dumpe2fs to determine that file system's block size.
Find the device path:
Each formatted partition of a hard drive has its own file system. During a Linux installation, each partition is assigned a device name that is used to refer to that partition. Additionally, during installation, a special file is created using this device name as its file name. Linux places this file in the directory hierarchy at /dev.
So, the device path will be the dev folder's path (/dev) plus the file name (examples: /dev/hda1 or /dev/sda1). Each formatted partition of each hard drive will have its on "device file" located in the /dev folder.
You can see a list of device files by entering the following command in a terminal session:
cd /dev; ls |less
However, doing this lists many device files. Which one represents the file system for which you trying to determine its block size?
The following command will list (1) all hard drives and (2) the device path of each formatted partition on each hard drive:
sudo sfdisk -l
Here's what I get when I enter the command above:
Disk /dev/sda: 14593 cylinders, 255 heads, 63 sectors/track Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sda1 0+ 2431 2432- 19535008+ 83 Linux /dev/sda2 2432 14592 12161 97683232+ 5 Extended /dev/sda3 0 - 0 0 0 Empty /dev/sda4 0 - 0 0 0 Empty /dev/sda5 2432+ 2549 118- 947772 82 Linux swap / Solaris /dev/sda6 2550+ 14592 12043- 96735366 83 Linux Disk /dev/sdb: 30401 cylinders, 255 heads, 63 sectors/track Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sdb1 0+ 30400 30401- 244196001 83 Linux /dev/sdb2 0 - 0 0 0 Empty /dev/sdb3 0 - 0 0 0 Empty /dev/sdb4 0 - 0 0 0 Empty
So, on my laptop you can see that Linux named my internal hard drive sda, and each of its formatted partitions are named sda plus a number (sda1, sda6, etc.). I'm not sure why it lists so many sda devices; sda1, sda5, and sda6 make sense to me because when I installed Linux on this laptop's 120 gig drive, I intended to divide the hard drive into 3 partitions: one for the operating system (20 gigs), one for my file repository (99 gigs), and one swap partition (1 gig). I do not know why Linux created the device names sda2, sda3 or sda4; sda3 and sda4 are empty, and sda2 seems to claim blocks that overlap sda6.
The second drive listed (sdb) is my external hard drive. It contains one formatted partition that Linux named sdb1. So its device path is /dev/sdb1.
Notice where it says "blocks of 1024 bytes". This is not the file system's block size; it is the hard disk's block size. The file system's block size can be a multiple of the hard disk's block size. So this is not what we use to determine maximum file size.
If you are still unclear about which device represents which file system. Try using the df command:
For me, that command produces this:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 19228276 3739596 14511932 21% / varrun 387548 152 387396 1% /var/run varlock 387548 0 387548 0% /var/lock procbususb 387548 128 387420 1% /proc/bus/usb udev 387548 128 387420 1% /dev devshm 387548 0 387548 0% /dev/shm lrm 387548 33788 353760 9% /lib/modules/2.6.20-16-generic/volatile /dev/sda6 95215560 86704412 3674380 96% /home /dev/sdb1 240362656 134401288 93751568 59% /media/x1
Notice the "Mounted on" column; this indicates where the file system is mounted to the directory hierarchy. Notice that the "Mounted on" location is different from the location to where that file system's device file is located. So, each formated partition has a file system and each file system has a device file located in the /dev folder, but that's not the path to where files are stored on that file system. During a Linux installation, you can specify a path where you want each file system to facilitate storage. Above, you can see that /dev/sda1 facilitates storage for files and folders placed in the root folder /. However, it doesn't necessarily facilitate storage for all sub folders, because any file system can be mounted to a folder subordinate to root. For example, the /dev/sda6 device is mounted at /home. So, sda1 doesn't facilitate storage for /home, sda6 does. To determine which device is facilitating storage for a particular path location, look for the "Mounted on" path that most specifically specifies the path location you're questioning.
Discover Your File System's Block Size
By now, you should know the device path of the file system of which you are wanting to know maximum file size. Now you can use the dumpe2fs command to discover its block size:
sudo /sbin/dumpe2fs /dev/sdb1 | grep "Block size"
Replace "/dev/sdb1" (above) with the device path of your file system.
For me, this command produces the following:
dumpe2fs 1.40-WIP (14-Nov-2006) Block size: 4096
Now that I know the block size of the file system, I can now cross reference it with the table (shown earlier) and see that the maximum file size is 2TiB. So, in my case, the maximum file size of my ext3 file system exceeds the capacity of the hard drive its on. Now I know I can do a tar backup of my /home directory (sda6) to my external hard drive (sdb1) without worry of file size limitations.
Tell others about
About the Author
Comments? Questions? Email Here