Directory structure and what is contained in the directories /var This fs contains spool directories such as those for mail and printing. In addition, it contains the error log directory. If your machine is a server and develops a chronic error, those msgs can fill the partition. Server computers ought to have /var in a different partition than /. /usr This is where most executable binaries go. In addition, the kernel source tree goes here, and much documentation. /tmp Some programs write temporary data files here. Usually, they are quite small. However, if you run computationally intensive jobs, like science or engineering applications, hundreds of megabytes could be required for brief periods of time. In this case, keep /tmp in a different partition than /. /home This is where users home directories go. If you do not impose quotas on your users, this ought to be in its own partition. /dev This is where device drivers are located. /proc This is non-existant (virtual), it must exist but never attempt to back this up. Typical directory size on a general purpose ISP as of 12 Sep 2002 3225 bin 80 dev 5544 etc 601897 home 12835 lib 12 lost+found 0 proc (n/a) 6546 sbin 0 tmp 528428 usr 27660 var Same ISP as of 4 Aug 2002 5659 bin 80 dev 12755 etc 634664 home 23923 lib 12 lost+found 0 proc 7719 sbin 0 tmp 827492 usr 70803 var --- EXT2fs, the current file system standard. Modern kernel and Ext2fs now limit disk size to 4 TB per partition. Ext2fs provides long file names. It uses variable length directory entries. The maximal file name size is 255 characters. Ext2fs reserves some blocks for the super user (root). Normally, 5% of the blocks are reserved. This allows the administrator to recover easily from situations where user processes fill up filesystems. Always skipping filesystem checks may sometimes be dangerous, so Ext2fs provides two ways to force checks at regular intervals. A mount counter is maintained in the superblock. Each time the filesystem is mounted in read/write mode, this counter is incremented. When it reaches a maximal value (also recorded in the superblock), the filesystem checker forces the check even if the filesystem is ``Clean''. A last check time and a maximal check interval are also maintained in the superblock. These two fields allow the administrator to request periodical checks. When the maximal check interval has been reached, the checker ignores the filesystem state and forces a filesystem check. More information on EXT2 can be found at: http://e2fsprogs.sourceforge.net/ext2intro.html --- formatting a partition mkfs.ext2 (or mke2fs) /dev/hdb1 note: add the -c option before /dev/hdb1 to check for bad blocks. --- formatting a partition for use as swap mkswap /dev/hdb5 To activate the swap area: swapon /dev/hda5 note: add the -c option before /dev/hdb5 to check for bad blocks. for more information see: http://www.tldp.org/HOWTO/mini/Hard-Disk-Upgrade/mount.html --- Mounting a partition for use... mount /dev/sda1 /opt important mount options -t vfstype The argument following the -t is used to indicate the file system type. The file system types which are currently supported are: adfs, affs, autofs, coda, coherent, cramfs, devpts, efs, ext, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, ntfs, proc, qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, ums dos, vfat, xenix, xfs, xiafs. For most types all the mount program has to do is issue a simple mount system call, and no detailed knowledge of the filesystem type is required. The type iso9660 is the default. If no -t option is given, or if the auto type is specified, the superblock is probed for all filesystem type (adfs, bfs, cramfs, ext, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, ntfs, qnx4, reiserfs, romfs, ufs, vxfs, xfs, xiafs are supported). If this probe fails, mount will try to read the file /etc/filesystems, or, if that does not exist, /proc/filesystems. All of the filesystem types listed there will be tried, except for those that are labeled "nodev" (e.g., devpts, proc and nfs). --- Fragmentation Noncontiguous placement of blocks in a file is bad for performance, since files are often accessed in a sequential manner. It forces the operating system to split a disk access and the disk to move the head. This is a common problem with MS-DOS file systems. In conjunction with the abysmal buffer cache used by MS-DOS, the effects of file fragmentation on performance are very noticeable. DOS users are accustomed to defragging their disks. None of these habits should be carried over to Linux and ext2. Linux native file systems do not need defragmentation under normal use and this includes any condition with at least 5% of free space on a disk. There is a defragmentation tool for ext2 called defrag, but users are cautioned against use (casual or otherwise). note: The MS-DOS file system is also known to lose large amounts of disk space due to internal fragmentation. For partitions larger than 256 MB, DOS block sizes grow so large that they are no longer useful (This has been corrected to some extent with FAT32). So unlike DOS there is no need to split up large disks into multiple partitions to keep block size down as the block size is small to begin with (usually 1 to 4kb). --- You can calculate the number of files on your disk by the number of allocated inodes on a disk. Use one of the below commands. dumpe2fs /dev/sda2 du -i /dev/sda2 for more information see: http://www.tldp.org/HOWTO/mini/Partition/formating.html --- Important definitions SUPER BLOCK The super block owes its name to its heritage, from when the first data block of a disk or partition was used to hold meta information about the partition itself. The super block is now detached from the concept of data block, but it still contains information about each mounted file system. The actual data structure in Linux is called struct super_block and holds various housekeeping information, like mount flags, mount time and device block size. The kernel keeps a static array of such structures to handle up to 64 mounted file systems. INODE An inode is associated with each file. Such an ``index node'' holds all the information about a named file except its name and its actual data. The owner, group, permissions and access times for a file are stored in its inode, as well as the size of the data it holds, the number of links and other information. The idea of detaching file information from file name and data is what allows the implementation of hard-links--and the use of ``dot'' and ``dot-dot'' notations for directories without any need to treat them specially. An inode is described in the kernel by a struct inode. DIRECTORY The directory is a file that associates inodes to file names. The kernel has no special data structure to represent a directory, which is treated like a normal file in most situations. Functions specific to each file system type are used to read and modify the contents of a directory independently of the actual layout of its data. FILE The file itself is associated with an inode. Usually files are data areas, but they can also be directories, devices, fifos (first-in-first-out) or sockets. An ``open file'' is described in the Linux kernel by a struct file item; the structure holds a pointer to the inode representing the file. file structures are created by system calls like open, pipe and socket, and are shared by father and child across fork. --- misc output... --- sample output of /etc/fstab note: This file is user definable and is not automatically created/updated. /dev/hda1 / ext2 defaults 1 1 /dev/hda2 swap swap defaults 0 0 /dev/hda3 /var ext2 defaults,nosuid 2 2 /dev/hda4 /home ext2 defaults,usrquota,grpquota,grpid 3 3 none /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=0620 0 0 --- sample output of /etc/mtab note: This file is automatically created/updated, no not exit. /dev/hda1 / ext2 rw 0 0 none /proc proc rw 0 0 /dev/hda3 /var ext2 rw,nosuid 0 0 /dev/hda4 /home ext2 rw,usrquota,grpquota,grpid 0 0 none /dev/pts devpts rw,gid=5,mode=0620 0 0 --- sample output of fdisk Disk /dev/hda: 16 heads, 63 sectors, 39693 cylinders Units = cylinders of 1008 * 512 bytes Device Boot Start End Blocks Id System /dev/hda1 1 1524 768095+ 83 Linux /dev/hda2 1525 1785 131544 82 Linux swap /dev/hda3 1786 2192 205128 83 Linux /dev/hda4 2193 39693 18900504 83 Linux --- sample output of du -ks Filesystem 1k-blocks Used Available Use% Mounted on /dev/hda1 743466 567384 176082 76% / /dev/hda3 198601 27679 170922 14% /var /dev/hda4 18134247 602121 17532126 3% /home --- Sample output from an ext2 dump on /dev/hda1 Filesystem volume name: Last mounted on: Filesystem UUID: 5bb9cf72-1a52-11d6-8427-0010e001b611 Filesystem magic number: 0xEF53 Filesystem revision #: 0 (original) Filesystem features: (none) Filesystem state: not clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 192512 Block count: 768095 Reserved block count: 0 Free blocks: 176082 Free inodes: 160663 First block: 1 Block size: 1024 Fragment size: 1024 Blocks per group: 8192 Fragments per group: 8192 Inodes per group: 2048 Inode blocks per group: 256 Last mount time: Thu Jun 20 09:15:58 2002 Last write time: Fri Sep 13 15:03:15 2002 Mount count: 5 Maximum mount count: 20 Last checked: Sat Mar 23 19:56:22 2002 Check interval: 15552000 (6 months) Next check after: Thu Sep 19 20:56:22 2002 Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) Group 0: (Blocks 1 -- 8192) Block bitmap at 5 (+4), Inode bitmap at 6 (+5) Inode table at 7 (+6) 4231 free blocks, 1644 free inodes, 20 directories Free blocks: 323-333, 335-341, 347-355, 440, 1161, <>