Linux File System proficiency Guide

Source: Internet
Author: User
Article Title: Linux File System proficiency guide. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Although the kernel is the core of Linux, files are the main tool used for user interaction with the operating system. This is especially true for Linux, because in UNIX tradition, it uses file I/O mechanisms to manage hardware devices and data files.

Unfortunately, new users often confuse terms that introduce the concept of Linux file systems. The term file system can be used interchangeably in Linux File preparation to refer to several different but related concepts. In addition to the actual disk partition, the file system also refers to the data structure and file management methods in the partition.

This term is also used to refer to the overall structure of files in the system: directory tree. In addition, this term can also refer to each subdirectory in the directory tree, for example, in the/home file system. Some people think that these directories and subdirectories cannot be called true file systems unless they all reside in their respective disk partitions. However, others call it a file system, which undoubtedly adds confusion.

Linux Veterans can understand the meaning of these terms from the context. However, it is difficult for new users to identify such a context at half past one.

The main goal of this article is to provide sufficient background knowledge to help you identify the context of this term. While clarifying the nuances of File System terms, you will also learn how to increase some useful tools from theoretical applications to practical applications.

This article mainly introduces the features of the Linux disk partition and file management system in the 2.4 Linux kernel. In addition, the new features in the 2.6 Linux kernel are introduced.

  Disk Partition Overview

The basic file storage units in Linux and UNIX are disk partitions, which are logical partitions of one or more hard disks. The operating system regards each logical partition as an independent disk. The file and file management system "lives" in the disk partition. Linux processes these disk partitions as devices and uses the file I/O mechanism through special files in the/dev directory.

There are two types of device files: block and character/original. One important difference between the two is that block devices are buffered, and character devices are not buffered because they do not have a file management system. Before the launch of the Oracle Cluster File System (OCFS), using the original device is a common way to improve the performance of Oracle Data File partitioning. (In the subsequent sections of this article, we will detail the original devices .)

The partition table that is stored at the beginning of the disk provides the ing of partitions on the disk. You can use the fdisk command to view the Partition Table of the system.

# Fdisk-l

Disk/dev/hda: 240 heads, 63 sectors, 1940 cylinders.

Units = cylinders of 15120*512 bytes

Device Boot Start End Blocks Id System

/Dev/hda 1 286 2162128 + c Win95 FAT32 (LBA)

/Dev/hda2*288 1940 12496680 5 Extended

/Dev/hda5 288 289 15088 + 83 Linux

/Dev/hda6 290 844 4195768 + 83 Linux

/Dev/hda7 845 983 1050808 + 82 Linux swap

/Dev/hda8 984 1816 6297448 + 83 Linux

/Dev/hda9 1817 1940 937408 + 83 Linux

The name/dev/hda to/dev/hdd in the Partition Table represents the IDE drive 1 to 4, where hda represents drive 1, hdb represents drive 2, and so on. Partitions in the drive are represented by numbers, so/dev/hda5 is the fifth partition on the first IDE drive. A similar naming mode is used for SCSI drives:/dev/sda to/dev/sdd.

The first to fourth partitions are reserved for the primary partition, and the fifth and subsequent partitions are used for the logical partition. Therefore, the partition table shown above contains a drive hda, which contains a primary partition hda1, an extended partition hda2, and five logical partitions/dev/hda5 to/dev/hda9. The file system listed in the name shmfs indicates the shared memory file system that is mounted as a special file system according to the POSIX standard in Linux 2.4.

You may have noticed that LBA is enclosed in brackets in the fdisk list. LBA indicates Logical Block Addressing. It converts the cylindrical, block, and sector modes of a hard disk into linear block numbers for processing.

In Linux, partitions are divided into primary partitions, extended partitions, and logical partitions. The term primary partition is a legacy product of the four partition restrictions on the previous x86 system. Unlike DOS and Windows, Linux can be started from the primary partition or logical partition. A primary partition used as a placeholder for a logical partition is called an extended partition. Extended partitions have partition tables that point to one or more logical partitions (they are only subpartitions of the primary partition. In the above fdisk list, hda2 is an extended partition.

  File Management System Overview

To make the partitioned disk available, you must build a file system on it. In this case, the file system is also called "partition type", "disk-based file system", and "file system type ". In fact, these file systems can be viewed as file management systems, because they reflect their functions by maintaining the metadata on files, make the files on the system consistent.

One of the features of a Linux project is the need to implement compatibility with multiple styles and preferred settings for each available utility, which is most evident in the selection of available file management systems. The Virtual File System (VFS) in the Linux Kernel implements this option. VFS uses a set of basic data structures that can be used by other file management systems. These data structures are super blocks, inode, dentry (or directory files), and data blocks.

Each partition contains a super block to maintain information on the file system in the partition, contains a group of inode with unique numbers in each super block, the number of idle inode, the total number of inode, the total number of data blocks, the number of idle data blocks, and the status of the file system. The file system has two states: Clean (when the file is in the unchanged state) and dirty (when there is a file system change that has not been written to the disk ). An inode in the super block corresponds to a file.

Besides the file name, inode contains all information about the file, including:

· Address

· Type

· Size

· Owner

· Reference of the block where the file data is located

· The last modification and access timestamp of the file.

Run the following command to view the inode of the file:

$ Ls-I

As mentioned above, inode only has a unique number in the super block and each partition has only one super block. This is why hard links cannot span multiple partitions.

The file name is linked to an inode number through the dentry object (the directory file is displayed by the user. The data block stores the actual file data.

Linux supports any file management system that has a VFS-defined basic function set. For file management systems like vfat, Linux projects provide their own device drivers.

You can see from the following output that different file management systems can exist in different partitions of the same system.

# Df-T

Filesystem Type 1 K Blocks Used Available Use % Mounted on

/Dev/hda6 reiserfs 4195632 2015020 2180612 49%/

/Dev/hda5 ext2 14607 3778 10075 8%/boot

/Dev/hda9 reiserfs 937372 202368 735004 22%/home

/Dev/hda8 reiserfs 6297248 3882504 2414744 62%/opt

Shmfs shm 256220 0 256220 0%/dev/shm

/Dev/hda1 vfat 2159992 1854192 305800 86%/windows/C

Currently, the most common file management systems for Oracle users are ext2/ext3, ReiserFS (not supported by Oracle), and OCFS. The following is a summary table of non-Oracle partition main features.

  

Features Ext2 Ext3 ReiserFS3.6 (not supported by Oracle)
Maximum partition size 4 TB 4 TB 16 TB
Maximum File Size 2 GB-4 GB 2 GB-4 GB 8 TB
Block Size 1KB-4KB 1KB-4KB Only 4 kb
Log feature None Yes Yes
Restart After crash Slow Fast Very fast
Tools used to restore files to be cleared Yes Yes None
Data status after crash Good Very good Average
ACL support Yes Yes None
Stability Excellent Good Good

[1] [2] Next page

Related Article

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.