File system in linux and unix relationship

Differentiating UNIX and Linux

file system in linux and unix relationship

Linux's file system has quite a few differences from the Windows file On Linux and other UNIX-like operating systems, applications don't lock. A Linux system, just like UNIX, makes no difference between a file and a directory , since a directory is just a file containing names of other files. Programs. Unix-like systems can use a RAM disk or Instead, to gain access to files on another machines without a physical connection. for example, the Linux supermount-ng.

For example, Sun's Solaris is UNIX, but incorporates many tools and extensions designed to get the best out of Sun's own workstation and server hardware. Its history dates back toor further back towhen the GNU project, whose original aims where to provide a free alternative to UNIX, was introduced.

Most UNIX variants run on just one architecture. Because of this history and the heritage of the two products, Linux and UNIX have a common foundation, but are also very different. Many of the tools, utilities, and free software products that are standard under Linux were originally developed as free alternatives to the versions available on UNIX.

file system in linux and unix relationship

Linux often provides support for many different options and applications, picking the best or most popular functionality from the UNIX and free software environment. An administrator or developer who supports Linux systems might find it uncomfortable to move to a commercial UNIX system. However, some details of the systems show significant differences. The remainder of this article covers the details of these differences. Technical differences The developers of commercial editions of UNIX have a specific target audience and platform for their operating system.

The Unix File System

They also have a pretty good idea of what applications they want to support and optimize. Commercial UNIX vendors do everything they can to maintain consistency between different versions.

They have published standards that they follow for their customers. Developers come from many different backgrounds, and therefore have different experiences and opinions. There has not been as strict of a standard set of tools, environments, and functionality within the Linux community.

The Linux Standards Base LSB project was formed in an attempt to alleviate this problem, but it has not provided as much help as hoped.

Differentiating UNIX and Linux

This lack of standards results in noticeable inconsistencies within Linux. It might seem a benefit to some for developers to have the freedom to emulate the best parts of other operating systems, but it can be very confusing when certain elements of Linux emulate different UNIX variants.

These sorts of inconsistencies even exist between different Linux distributions. For example, Gentoo and RedHat have different methods for keeping their systems current with the latest patches and software releases. For a byte allocation, the average unused space is bytes. The size of the allocation unit is chosen when the file system is created. Choosing the allocation size based on the average size of the files expected to be in the file system can minimize the amount of unusable space.

Frequently the default allocation may provide reasonable usage. Choosing an allocation size that is too small results in excessive overhead if the file system will contain mostly very large files. File systems may become fragmented File system fragmentation occurs when unused space or single files are not contiguous. As a file system is used, files are created, modified and deleted.

When a file is created the file system allocates space for the data. Some file systems permit or require specifying an initial space allocation and subsequent incremental allocations as the file grows. As files are deleted the space they were allocated eventually is considered available for use by other files. This creates alternating used and unused areas of various sizes.

This is free space fragmentation. When a file is created and there is not an area of contiguous space available for its initial allocation the space must be assigned in fragments. When a file is modified such that it becomes larger it may exceed the space initially allocated to it, another allocation must be assigned elsewhere and the file becomes fragmented. Filename A filename or file name is used to identify a storage location in the file system. Most file systems have restrictions on the length of filenames.

In some file systems, filenames are not case sensitive i. Most modern file systems allow filenames to contain a wide range of characters from the Unicode character set. However, they may have restrictions on the use of certain special characters, disallowing them within filenames; those characters might be used to indicate a device, device type, directory prefix, file path separator, or file type.

Directory file systems File systems typically have directories also called folders which allow the user to group files into separate collections. This may be implemented by associating the file name with an index in a table of contents or an inode in a Unix-like file system. Directory structures may be flat i. The first file system to support arbitrary hierarchies of directories was used in the Multics operating system.

Metadata[ edit ] Other bookkeeping information is typically associated with each file within a file system. The length of the data contained in a file may be stored as the number of blocks allocated for the file or as a byte count. The time that the file was last modified may be stored as the file's timestamp. File systems might store the file creation time, the time it was last accessed, the time the file's metadata was changed, or the time the file was last backed up. Other information can include the file's device type e.

A file system stores all the metadata associated with the file—including the file name, the length of the contents of a file, and the location of the file in the folder hierarchy—separate from the contents of the file.

Most file systems store the names of all the files in one directory in one place—the directory table for that directory—which is often stored like any other file. Many file systems put only some of the metadata for a file in the directory table, and the rest of the metadata for that file in a completely separate structure, such as the inode. Most file systems also store metadata not associated with any one particular file. Such metadata includes information about unused regions— free space bitmapblock availability map —and information about bad sectors.

Often such information about an allocation group is stored inside the allocation group itself. Some file systems provide for user defined attributes such as the author of the document, the character encoding of a document or the size of an image. Some file systems allow for different data collections to be associated with one file name. These separate collections may be referred to as streams or forks. Some file systems maintain multiple past revisions of a file under a single file name; the filename by itself retrieves the most recent version, while prior saved version can be accessed using a special naming convention such as "filename;4" or "filename -4 " to access the version four saves ago.

See comparison of file systems Metadata for details on which file systems support which kinds of metadata. File system as an abstract user interface[ edit ] In some cases, a file system may not make use of a storage device but can be used to organize and represent access to any data, whether it is stored or dynamically generated e. Utilities[ edit ] File systems include utilities to initialize, alter parameters of and remove an instance of the file system. Some include the ability to extend or truncate the space allocated to the file system.

Directory utilities may be used to create, rename and delete directory entries, which are also known as dentries singular: Directory utilities may also include capabilities to create additional links to a directory hard links in Unixto rename parent links ". File utilities create, list, copy, move and delete files, and alter metadata.

They may be able to truncate data, truncate or extend space allocation, append to, move, and modify files in-place. Depending on the underlying structure of the file system, they may provide a mechanism to prepend to, or truncate from, the beginning of a file, insert entries into the middle of a file or delete entries from a file.

Utilities to free space for deleted files, if the file system provides an undelete function, also belong to this category. Some file systems defer operations such as reorganization of free space, secure erasing of free space, and rebuilding of hierarchical structures by providing utilities to perform these functions at times of minimal activity.

An example is the file system defragmentation utilities. Some of the most important features of file system utilities involve supervisory activities which may involve bypassing ownership or direct access to the underlying device.

These include high-performance backup and recovery, data replication and reorganization of various data structures and allocation tables within the file system. Restricting and permitting access[ edit ] See also: Computer securityPassword crackingFilesystem-level encryptionand Encrypting File System There are several mechanisms used by file systems to control access to data.

Usually the intent is to prevent reading or modifying files by a user or group of users. Another reason is to ensure data is modified in a controlled way so access may be restricted to a specific program. Examples include passwords stored in the metadata of the file or elsewhere and file permissions in the form of permission bits, access control listsor capabilities.

The need for file system utilities to be able to access the data at the media level to reorganize the structures and provide efficient backup usually means that these are only effective for polite users but are not effective against intruders. Methods for encrypting file data are sometimes included in the file system. This is very effective since there is no need for file system utilities to know the encryption seed to effectively manage the data. The risks of relying on encryption include the fact that an attacker can copy the data and use brute force to decrypt the data.

Losing the seed means losing the data. Maintaining integrity[ edit ] One significant responsibility of a file system is to ensure that, regardless of the actions by programs accessing the data, the structure remains consistent. This includes actions taken if a program modifying data terminates abnormally or neglects to inform the file system that it has completed its activities. This may include updating the metadata, the directory entry and handling any data that was buffered but not yet updated on the physical storage media.

Other failures which the file system must deal with include media failures or loss of connection to remote systems. In the event of an operating system failure or "soft" power failure, special routines in the file system must be invoked similar to when an individual program fails. The file system must also be able to correct damaged structures. These may occur as a result of an operating system failure for which the OS was unable to notify the file system, power failure or reset.

The file system must also record events to allow analysis of systemic issues as well as problems with specific files or directories. User data[ edit ] The most important purpose of a file system is to manage user data. This includes storing, retrieving and updating data. Some file systems accept data for storage as a stream of bytes which are collected and stored in a manner efficient for the media. When a program retrieves the data, it specifies the size of a memory buffer and the file system transfers data from the media to the buffer.

A runtime library routine may sometimes allow the user program to define a record based on a library call specifying a length. When the user program reads the data, the library retrieves data via the file system and returns a record.

Some file systems allow the specification of a fixed record length which is used for all writes and reads. This facilitates locating the nth record as well as updating records. An identification for each record, also known as a key, makes for a more sophisticated file system. The user program can read, write and update records without regard to their location. This requires complicated management of blocks of media usually separating key blocks and data blocks.

Very efficient algorithms can be developed with pyramid structure for locating records. All files and directories appear under the root directory, even if they are stored on different physical devices e. To the Linux kernel, however, the filesystem is flat.

Linux filesystems: definition, structure, selection, optimization

That is, it does not 1 have a hierarchical structure, 2 differentiate between directories, files or programs or 3 identify files by names. Instead, the kernel uses inodes to represent each file.

An inode is actually an entry in a list of inodes referred to as the inode list. Each inode contains information about a file including 1 its inode number a unique identification number2 the owner and group associated with the file, 3 the file type for example, whether it is a regular file or a directory4 the file's permission list, 5 the file creation, access and modification times, 6 the size of the file and 7 the disk address i.

The inode numbers for the contents of a directory can be seen by using the -i option with the familiar ls i. Here filesystems is used as a variant of the first meaning, referring to the parts of the entire hierarchy of directories. Linux Native Filesystems Every native Linux filesystem implements a basic set of common concepts that were derived from those originally developed for Unix.

Native means that the filesystems were either developed originally for Linux or were first developed for other operating systems and then rewritten so that they would have functions and performance on Linux comparable or superior to those of filesystems originally developed for Linux.

Additional native filesystems are in various stages of development. Linux's first filesystem was minix, which was borrowed from the Minix OS. Linus Torvalds adopted this filesystem because it was an efficient and relatively bug-free piece of existing software that postponed the need to design a new filesystem from scratch. However, minix was not well suited for use on Linux hard disks for several reasons, including its maximum partition size of only 64MB, its short filenames and its single timestamp.

But minix can be useful for floppy disks and RAM disks because its low overhead can sometimes allow more files to be stored than is possible with other Linux filesystems. The Extended File System, ext, was introduced in April, With a maximum partition size of 2GB and a maximum file name size of characters, it removed the two biggest minix limitations. However, there still was no support for the separate access, inode modification and data modification timestamps.

Also, its use of linked lists to keep track of free blocks and inodes caused the lists to become unsorted and the filesystem to become fragmented. It was a rewrite of ext which features 1 improved algorithms that greatly improved its speed, 2 additional date stamps such as date of last access, date of last inode modification and date of last data modification and 3 the ability to track the state of the filesystem.

Ext2 maintains a special field in the superblock that indicates the status of the filesystem as either clean or dirty. A dirty filesystem will trigger a utility to scan the filesystem for errors. Ext2 also features support for a maximum file size of 4TB 1 terabyte is gigabytes. Consequently, it has completely superseded ext, support for which has been removed from the Linux kernel. Ext2 is the most portable of the native Linux filesystems because drivers and other tools exist that allow accessing ext2 data from a number of other operating systems.

However, as useful as these tools are, most of them have limitations, such as being access utilities rather than true drivers, not working with the most recent versions of ext2, not being able to write to ext2 or posing a risk of causing filesystem corruption when writing to ext2. Journaling Filesystems The lack of a journaling filesystem was often cited as one of the major factors holding back the widespread adoption of Linux at the enterprise level.

However, this objection is no longer valid, as there are now four such filesystems from which to choose. Journaling filesystems offer several important advantages over static filesystems, such as ext2. In particular, if the system is halted without a proper shutdown, they guarantee consistency of the data and eliminate the need for a long and complex filesystem check during rebooting. The term journaling derives its name from the fact that a special file called a journal is used to keep track of the data that has been written to the hard disk.

In the case of conventional filesystems, disk checks during rebooting after a power failure or other system crash can take many minutes, or even hours for large hard disk drives with capacities of hundreds of gigabytes. Moreover, if an inconsistency in the data is found, it is sometimes necessary for human intervention in order to answer complicated questions about how to fix certain filesystem problems.

file system in linux and unix relationship

Such downtime can be very costly with big systems used by large organizations. In the case of a journaling filesystem, if power supply to the computer is suddenly interrupted, a given set of updates will have either been fully committed to the filesystem i. This is far quicker than a scan of the entire hard disk, and it guarantees that the structure of the filesystem is always self-consistent.

With a journaling filesystem, a computer can usually be rebooted in just a few seconds after a system crash, and although some data might be lost, at least it will not take many minutes or hours to discover this fact.