The Filesystem Tree
The Unix and Linux filesystem is based on the Filesystem Heirarchy Standard (FHS). (You can research it at http://www.pathname.com/fhs/ .)
There are no C: drives, D: drives or any other lettered drives. Instead, all disks are mounted into a common filesystem tree. You can even mount other computers into this tree. Everyone shares the same filesystem (which is why permissions are so important).
See the Partitioning section of the Installation page for information about setting up partitions.
See the excellent Novell page, File System Primer, at http://wiki.novell.com/index.php/File_System_Primer#File_System_Comparison
Review the list on the page above, then note these filesystems not included in the Novell list:
Additional Unix/Linux Filesystems | |
Type | Description |
bfs | Boot filesystem – used at startup on most Unix systems |
cdfs | Compact Disk filesystem – one way to access CD data as normal files |
iso9660 | “The” CD-ROM filesystem, based on an ISO standard |
udf | Universal Disk Format filesystem – used during the creation and burning of CDs |
minix | The original proto-Linux filesystem |
msdos | FAT 16-bit filesystem (not FAT32) |
vfat | FAT compatible filesystem with long filename support |
VxFS | HP-UX filesystem |
For a more comprehensive list of filesystem types, see Guide to Linux Filesystem Mastery by Sheryl Calish at http://www.oracle.com/technology/pub/articles/calish_filesys.html
Learn about Journaling File Systems from Steve Best’s article at
http://www.linux-mag.com/content/view/1167
Journaling File Systems in particular benefit from performance tuning: See Steve Best’s article “Tuning Journaling File Systems” at
http://www.linux-mag.com/id/2927/
You’re likely to need to make a file system on (format) a floppy, if it’s new (is there still such a thing?). Use the mkfs command. For a “Linux-only” floppy, you could use ext2 as your file system:
mkfs -t ext2 /dev/fd0
If it needs to be usable under Windows, use FAT instead:
mkfs -t msdos /dev/fd0
If you don’t specify, you’ll get ext2:
mkfs /dev/fd0
Formatting a Partition (creating a filesystem)
Filesystem Creation Commands Command Purpose Usage mkfs Makes filesystems of most types mkfs -t ext2 mkfs.msdos
mkdosfs
mkfs.vfatCreate a DOS FAT filesystem mkdosfs /dev/fd0 mkfs.ext2
mke2fsCreates an ext2 filesystem mkfs.ext2 /dev/hda2 mkfs.ext3
mke2fs -jCreate an ext3 (journaled) filesystem mkfs.ext3 /dev/hda2 mkisofs Creates a CD-ROM filesystem mkisofs -o iso_file starting_directory mkfs.reiserfs
mkreiserfsCreata a REISERFS filesystem mkreiserfs /dev/hda3
ext2 and ext3
Use tune2fs to “adjust tunable filesystem parameters” on ext2 and ext3 filesystems. These include:
- The number of mounts between filesystem checks
- The maximum time between filesystem checks
- Set the volume label
- Reserve blocks for the filesystem or by group
- Add journaling, which turns an ext2 filesystem into an ext3 filesystem.
See man tune2fs for details before using this command.
fsck
fsck is the generic filesystem check utility. There are actually whole families of filesystem check utilities, specific to certain filesystems. fsck is actually a “pass-through” utility that invokes the filesystem-specific checkers, which have names like fsck.fstype.
See a typically excellent page at SS64.com:
http://ss64.com/bash/fsck.html
for a simple rundown. Of course see man fsck for full details (which will refer you through to filesystem-specific details).
fsck wants you to provide a filesystem type. If you don’t it assumes ext2.
fsck -t ext3 /dev/hda1
Filesystem-specific Check Commands Command Purpose Usage e2fsck Checks ext2 and ext3 filesystems e2fsck /dev/fd0 badblocks
e2fsck -cChecks ext2 and ext3 filesystems for bad blocks badblocks /dev/fd0
e2fsck -c /dev/fd0reiserfsck Checks REISERFS filesystems reiserfsck /dev/hdc1 reiserfsck -c Checks REISERFS filesystems for bad blocks reiserfsck -c /dev/hdc1 mkisofs Creates a CD-ROM filesystem mkisofs -o iso_file starting_directory mkfs.reiserfs
mkreiserfsCreata a REISERFS filesystem mkreiserfs /dev/hda3
fsck only performs a quick check unless you specify the -f “full” option:
fsck -f -t ext3 /dev/hda1
Common fsck Options Option Description -f Full check -a Automatically repair errors -A Check all filesystems marked with a 1 or 2 in /etc/fstab -Cf Do a full check and display progress line -AR Check all filesystems marked with a 1 or 2 in /etc/fstab, except the / filesystem -V Verbose output
Note that you can only check unmounted filesystems. Be particularly clear that you can’t fsck the root filesystem while it’s mounted (that is, while your system’s running). (See http://www.cs.uu.nl/wais/html/na-dir/unix-faq/unixware/qt-faq.html – search for fsck when you arrive.)
While the defaults can vary, an ext2 or ext3 filesystem will force a check every 20-40 mounts (which usually means reboots), or every 180 days, whichever comes first. This is one place you can use tune2fs:
tune2fs -i 90d /dev/fd0
The command above, for instance, changes the check interval to 90 days (90d). You can use seconds (the default), days (d), weeks (w) or months (m). A setting of 0 disables interval-based testing.
If fsck can’t repair a file, it places it in the lost+found directory, giving the file its inode number for its name.
Disk Usage
The df (disk free space) command is the first tool to know. It gives you a fast audit of free space. Use it by itself:
df
or with human-readable output:
df -h
in HP-UX:
ddf
Perhaps more useful is the du (directory usage) command. Specify a directory to analyse:
du /usr
Or just get a summary:
du -s /usr
Make it human-readable:
du -hs /usr
Check used and available inodes on ext2 and ext3 filesystems with dumpe2fs. To keep it readable, always use the -h option:
dumpe2fs -h /dev/hda1