Deep analysis of the four main parts of the Linux system

Linux systems generally have four main parts:

Kernel, shell, file system, and application. The kernel, shell, and file system together form the basic operating system structure that allows users to run programs, manage files, and use the system. Part of the hierarchy is shown in Figure 1-1.

1, linux kernel

The kernel is the core of the operating system and has many of the most basic functions. It is responsible for managing the system's processes, memory, device drivers, files, and network systems, which determine the performance and stability of the system.

The Linux kernel consists of the following components: memory management, process management, device drivers, file systems, and network management. Figure:

Deep analysis of the four main parts of the Linux system

figure 1

System Call Interface: The SCI layer provides some mechanisms for performing function calls from user space to the kernel. This interface depends on the architecture, even within the same processor family. SCI is actually a very useful function call multiplexing and demultiplexing service. In ./linux/kernel you can find the implementation of SCI and find the architecture-dependent part in ./linux/arch.

2, memory management

Memory and other resources are limited for any computer. In order to allow limited physical memory to meet the large memory requirements of the application, Linux uses a memory management method called "virtual memory." Linux divides memory into "memory pages" that are easy to handle (4KB for most architectures). Linux includes a way to manage available memory and the hardware mechanisms used for physical and virtual mapping.

However, memory management can manage more than 4KB buffers. Linux provides an abstraction for 4KB buffers, such as the slab allocator. This memory management mode uses a 4KB buffer as the base, then allocates structures from it and tracks memory page usage, such as which memory pages are full, which pages are not fully used, and which pages are empty. This allows the mode to dynamically adjust memory usage based on system needs.

In order to support the use of memory by multiple users, sometimes the available memory is consumed. For this reason, pages can be moved out of memory and placed on disk. This process is called swapping because the page is swapped from memory to the hard disk. The source code for memory management can be found in ./linux/mm.

3, process management

A process is actually a running entity of a particular application. In a Linux system, multiple processes can run simultaneously, and Linux achieves "multitasking" by running these processes in turn over short intervals. This short time interval is called a "time slice". The method that causes a process to run in turn is called "process scheduling", and the program that completes the scheduling is called a scheduler.

Process scheduling controls the access of the process to the CPU. When you need to choose the next process to run, the scheduler chooses the most worthwhile process to run. A runnable process is actually a process that only waits for CPU resources. If a process is waiting for other resources, the process is an unrunnable process. Linux uses a relatively simple priority-based process scheduling algorithm to select new processes.

Through the multitasking mechanism, each process can be considered to have only its own computer, which simplifies the writing of the program. Each process has its own separate address space and can only be accessed by this process, so that the operating system avoids mutual interference between processes and the possible harm to the system caused by "bad" programs. In order to accomplish a specific task, it is sometimes necessary to combine the functions of two programs, such as one program outputting text and another program sorting text. To this end, the operating system also provides inter-process communication mechanisms to help accomplish such tasks. Common interprocess communication mechanisms in Linux are signals, pipes, shared memory, semaphores, and sockets.

The kernel provides an application programming interface (API) through SCI to create a new process (fork, exec, or Portable Operating System Interface [POSIX] function), stop processes (kill, exit), and communicate and synchronize between them. (signal or POSIX mechanism).

4, file system

Unlike operating systems such as DOS, a separate file system in a Linux operating system is not identified by a drive letter or drive name (such as A: or C:). In contrast, like the UNIX operating system, the Linux operating system combines separate file systems into a hierarchical tree structure with a single entity representing the file system. Linux mounts a new file system on a directory called a "mount" or "hang" operation, allowing different file systems to be combined. An important feature of the Linux operating system is that it supports many different types of file systems. The most commonly used file system in Linux is Ext2, which is also a native file system for Linux. However, Linux can also support different types of file systems such as FAT, VFAT, FAT32, and MINIX, so that it can easily exchange data with other operating systems. Because Linux supports many different file systems and organizes them into a unified virtual file system.

Virtual File System (VFS): hides the specific details of various hardware, separates the file system operation and the specific implementation details of different file systems, provides a unified interface for all devices, and VFS provides up to Dozens of different file systems. Virtual file systems can be divided into logical file systems and device drivers. Logical file system refers to the file system supported by Linux, such as ext2, fat, etc. Device driver refers to the device driver module written for each hardware controller.

The Virtual File System (VFS) is a very useful aspect of the Linux kernel because it provides a common interface abstraction for file systems. VFS provides a layer of exchange between the SCI and the file systems supported by the kernel. That is, VFS provides a layer of exchange between the user and the file system.

VFS provides a layer of exchange between the user and the file system:

Above VFS is a generic API abstraction for functions such as open, close, read, and write. Below VFS is a file system abstraction that defines how the upper layer functions are implemented. They are plugins for a given file system (more than 50). The source code for the file system can be found in ./linux/fs.

Below the file system layer is the buffer cache, which provides a common set of functions for the file system layer (independent of the specific file system). This caching layer optimizes access to physical devices by keeping the data for a period of time (or then pre-reading the data to make it available when needed). Below the buffer cache is a device driver that implements the interface to a specific physical device.

Therefore, users and processes do not need to know the file system type in which the files are located, but only need to use them as if they were files in the Ext2 file system.

5, device driver

Device drivers are a major part of the Linux kernel. Similar to the rest of the operating system, device drivers run in a highly privileged processor environment, allowing direct manipulation of the hardware, but because of this, any device driver error can cause the operating system to crash. The device driver actually controls the interaction between the operating system and the hardware device.

The device driver provides a set of abstract interfaces that the operating system understands to complete the interaction with the operating system, while the specific operational details related to the hardware are done by the device driver. In general, device drivers are related to the device's control chip. For example, if your computer's hard drive is a SCSI hard drive, you need to use a SCSI driver instead of an IDE driver.

6. Network Interface (NET)

Provides access to a variety of network standards and support for a variety of network hardware. Network interfaces can be divided into network protocols and network drivers. The network protocol part is responsible for implementing every possible network transmission protocol. As we all know, the TCP/IP protocol is the standard protocol of the Internet and a de facto industry standard.

The Linux network implementation supports BSD sockets and supports all TCP/IP protocols. The network portion of the Linux kernel consists of BSD sockets, network protocol layers, and network device drivers. The network device driver is responsible for communicating with the hardware device, and each possible hardware device has a corresponding device driver.

7. linux shell

The shell is the user interface of the system and provides an interface for users to interact with the kernel. It receives the command entered by the user and sends it to the kernel for execution. It is a command interpreter. In addition, the shell programming language has many features of a common programming language. A shell program written in this programming language has the same effect as other applications.

Currently there are mainly the following versions of the shell.

1. Bourne Shell: Developed by Bell Labs. 2. BASH: It is GNU's Bourne Again Shell, the default shell on the GNU operating system. Most Linux distributions use this shell. 3. Korn Shell: The development of Bourne SHell, compatible with Bourne Shell for most of the content. 4. C Shell: It is the BSD version of Sun's Shell.

8. Linux file system

A file system is an organization method in which files are stored on a storage device such as a disk. Linux systems can support a variety of popular file systems such as EXT2, EXT3, FAT, FAT32, VFAT, and ISO9660.

8.1 File Type

The file types below Linux mainly include:

1) Ordinary files: C language meta code, SHELL script, binary executable file, etc. Divided into plain text and binary. 2) Directory files: directories, the only place to store files. 3) Linked files: Files that point to the same file or directory. 4) Device files: related to system peripherals, usually under /dev. Divided into block devices and character devices.

5) Pipeline (FIFO) file: A way to provide process communication. 6) Socket file: This file type is related to network communication.

You can use ls -l, file, stat to view information about the type of the file.

8.2 Linux Directory

The file structure is an organization method in which files are stored on a storage device such as a disk. Mainly reflected in the organization of documents and directories.

The directory provides a convenient and efficient way to manage files.

Linux uses a standard directory structure. At the time of installation, the installer has created a file system and a complete and fixed directory for the user, and specifies the role of each directory and the file type.

The complete directory tree can be divided into small parts, which can be stored separately on their own disks or partitions. In this way, relatively stable parts and frequently changing parts can be stored separately in different partitions, facilitating backup or system management. The main parts of the directory tree are root, /usr, /var, /home, etc. (Figure 2). This layout makes it easy to share parts of the file system between Linux machines.

figure 2

Linux uses a tree structure. The top layer is the root directory, and all other directories are generated from the root directory.

Microsoft's DOS and Windows also use a tree structure, but the root of such a tree structure in DOS and Windows is the disk drive letter. There are several partitions with several tree structures. The relationship between them is juxtaposed. of. At the top are different disks (partitions) such as C, D, E, F, etc.

But in Linux, no matter how many disk partitions the operating system manages, there is only one such directory tree. Structurally, tree directories on individual disk partitions are not necessarily side-by-side.

8.3 Linux disk partition

First, the primary partition, extended partition and logical partition:

Linux partitions are different from windows. Hard disks and hard disk partitions are represented as devices in Linux.

There are three types of hard disk partitions: primary partition, extended partition, and logical partition.

The partition of the hard disk is mainly divided into a primary partition (Primary Partion) and an extended partition (Extension Partion), and the sum of the number of the primary partition and the extended partition cannot be greater than four.

Primary Partion: Can be used immediately but cannot be partitioned.

Extension Partion: It must be partitioned before it can be used, which means it must be sub-partitioned.

Logical Partition: A partition created by an extended partition. There is no limit to the number of logical partitions.

An extended partition is nothing more than a "container" of logical partitions. In fact, only primary partitions and logical partitions store data.

Second, the identity of the hard disk partition under Linux

The identifier of the hard disk partition is generally identified by /dev/hd[az]X or /dev/sd[az]X, where [az] represents the hard disk number and X represents the partition number in the hard disk.

Block number identification of the entire hard disk partition: use hda, hdb, sda, sdb, etc. to identify different hard disks under Linux;

among them:

IDE interface hard disk: expressed as /dev/hda1, /dev/hdb ...;

The hard disk of the SCSI interface and the hard disk of the SATA interface are represented as /dev/sda, /dev/sdb ... ... ;

Partition in the hard disk: If the value of X is 1 to 4, it means the primary partition of the hard disk (including the extended partition); the logical partition starts from 5, for example, /dev/hda5 is definitely a logical partition;

E.g:

Use hda1, hda2, hda5, hda6 to identify different partitions. Among them, the letter a represents the first hard disk, b represents the second hard disk, and so on. The number 1 represents the first partition of a hard disk, 2 represents the second partition, and so on. 1 to 4 correspond to the Primary Partition or the Extension Partition. Starting from 5, the corresponding logical partition (Logical Partition) of the hard disk. If a hard disk has only one primary partition, the logical partition is numbered starting from 5, which should be especially noted.

Summary: A hard disk partition must first confirm which hard disk is in, and then confirm which partition in the hard disk it is on.

For the /dev/hda similar representation, it is not a problem; we can find out whether the hard disk is /dev/hda or /dev/hdb on Linux via fdisk -l;

[root@localhost ~]# fdisk -l

Disk /dev/hda: 80.0GB, 80026361856bytes

255heads, 63sectors/track, 9729cylinders

Units = cylinders of16065 * 512 = 8225280bytes

Device Boot Start EndBlocks IdSystem

/dev/hda1 * 19707791493+ 7HPFS/NTFS

/dev/hda2971972970356667+ 5Extended

/dev/hda5971291515623181bW95 FAT32

/dev/hda6291641319767488+ 83linux

/dev/hda7413255901171938683linux

/dev/hda8559168069767488+ 83linux

/dev/hda9680796572290062683linux

/dev/hda1096589729578308+ 82linux swap / Solaris

Please note that the first line, Disk /dev/hda: 80.0 GB, 80026361856 bytes, this means that there is only one hard disk device /dev/hda in the machine, the size is 80.0G; the following is the partition of the hard disk, each partition has Detailed information is not detailed here;

The relationship between disk partitions and directories under Linux is as follows:

– Any partition must be mounted to a directory.

– The directory is a logical distinction. Partitioning is a physical distinction.

– Disk Linux partitions must be mounted to a specific directory in the directory tree for read and write operations.

– The root directory is where all Linux files and directories are located, and you need to mount the previous disk partition.

8.4 The function of the linux main directory.

/bin binary executable command /dev device special file /etc system management and configuration file /etc/rc.d startup configuration file and script /home user home directory base point, such as user user's home directory is /home/user, You can use ~user to represent the /lib standard programming library, also known as the dynamic link shared library, which acts like the .dll file/sbin system management command in windows. Here is the temporary file that the system administrator uses for the hypervisor/tmp public. Storage point / root System administrator's home directory (hehe, privileged class) / mnt The system provides this directory for users to temporarily mount other file systems. /lost+found This directory is usually empty, the system is abnormally shut down and leaving a "homeless" file (what is called under Windows.) is here in the /proc virtual directory, which is the mapping of system memory. You can access this directory directly to get system information. /var The overflow area of ​​some large files, such as the log file /usr of the various services, the most widely used directories and applications and files are almost in this directory. Which contains: /usr/X11R6 The directory where the X window is stored /usr/bin Many applications /usr/sbin Some supervisors of the superuser /usr/doc linux documentation /usr/include Required for developing and compiling applications under linux Header file /usr/lib Commonly used dynamic link library and package configuration file /usr/man help documentation /usr/src source code, linux kernel source code is placed in /usr/src/linux /usr/local/ Bin locally added command /usr/local/lib locally added library

8.5 linux file system

The file system refers to the physical space where the file exists. Each partition in the Linux system is a file system and has its own directory hierarchy. Linux will form a system's total directory hierarchy in a certain way, separate file systems belonging to different partitions. An operating system can't do without the operation of files, so it is necessary to own and maintain its own file system.

File system type:

Ext2 : File system ext3 used in early Linux: upgraded version of ext2, with log function RAMFS: memory file system, fast NFS: network file system, invented by SUN, mainly used for remote file sharing MS-DOS: MS- DOS file system VFAT: File system FAT for Windows 95/98 operating system: File system NTFS for Windows XP operating system: File system for Windows NT/XP operating system HPFS: File system PROC for OS/2 operating system: Virtual Process File System ISO9660: File System for Most Discs ufsSun: File System NCPFS for OS: File System SMBFS for Novell Servers: Samba Shared File System XFS: Advanced Log File System Developed by SGI Support for large capacity files JFS: IBM's AIX uses the file system ReiserFS: File system based on balanced tree structure udf: Rewritable data CD file system

2. File system features:

After the disk partition is completed, it needs to be formatted before the operating system can use the partition. The purpose of formatting is to make the file system format available to the operating system (ie the file system type we mentioned above).

The file system that each operating system can use is not the same. For example, the file system used by Microsoft operating systems before Windows 98 is FAT (or FAT16), and the version of Windows 2000 and later has the so-called NTFS file system. As for the orthodox files of Linux. The system is Ext2 (Linux second extended file system, ext2fs). In addition, by default, the Windows operating system does not recognize Ext2 for Linux.

In the traditional disk and file system application, a partition can only be formatted into a file system, so we can say that a filesystem is a partition. But because of the use of new technologies, such as the LVM and software raid we often hear, these technologies can format a partition into multiple file systems (such as LVM), and can also combine multiple partitions into one file. System (LVM, RAID)! So, at the moment we are no longer said to format for partition when formatting, usually we can call a data that can be mounted as a file system instead of a partition!

So how does the file system work? This is related to the file data of the operating system. The file data of the newer operating system usually contains a lot of attributes, such as the file permissions (rwx) and file attributes (owner, group, time parameters, etc.) of the Linux operating system, in addition to the actual content of the file. The file system usually stores the two parts of the data in different blocks, the permissions and attributes are placed in the inode, and the actual data is placed in the data block block. In addition, there is a superblock that records the overall information of the entire file system, including the total amount of inodes and blocks, usage, and remaining amount.

For a disk partition, after being designated as the corresponding file system, the entire partition is divided into blocks of 1024, 2048 and 4096 bytes. According to the different use of the block, it can be divided into:

Superblock: This is the first space in the entire file system. It includes basic information about the entire file system, such as block size, total amount of inode/block, usage, remaining amount, pointers to spatial inodes and data blocks, and so on.

Inode block (file index node): File system index, which records the attributes of the file. It is the most basic unit of the file system, and it is the bridge connecting the file system to any subdirectory and any file. There is only one inode block per subdirectory and file. It contains the basic properties of the file in the file system (length of the file, creation and modification time, permissions, ownership), location of the data, etc. Under Linux, you can view the inode information of the file through the "ls -li" command. . Hard links and source files have the same inode.

Block: The content of the actual recorded file. If the file is too large, it will occupy multiple blocks. To improve directory access efficiency, Linux also provides a dentry structure that expresses the correspondence between paths and inodes. It describes the path information and connects to the node inode, which includes various directory information, as well as inodes and superblocks.

Just like a book has a cover, a table of contents, and a body. In the file system, the super block is equivalent to the cover, from the cover can know the basic information of the book; the inode block is equivalent to the directory, from the directory can know the location of each chapter content; and the data block is equivalent to the body of the book , recording the specific content.

Linux orthodox file systems (such as ext2, 3, etc.) will partition the hard disk into super blocks, inode table blocks and data block data areas. A file consists of a super block, an inode, and a data area block. The Inode contains the attributes of the file (such as read and write attributes, owner, etc., and pointers to the data block), and the data area block is the file content. When viewing a file, it first finds the file attributes and data storage points from the inode table, and then reads the data from the data block.

Ext2 file system diagram

We will illustrate the inode and block block diagrams. As shown in the following figure, the file system first formats the inode and block blocks, assuming that the attributes and permission data of a file are placed in the inode 4 (below) In the small square, and this inode records the actual placement point of the file data as the two block numbers 2, 7, 13, 15 , at this time our operating system can arrange the reading order of the disk accordingly, one can The tone reads out the contents of the four blocks! Then the data is read as shown by the arrow in the figure below.

This method of data access is called indexed allocation. Is there any other custom file system that can be compared? Yes, that is our usual flash disk (flash memory), the file system used by the flash disk is generally FAT format. FAT This file system does not have an inode, so FAT has no way to read all the blocks of this file from the beginning. Each block number is recorded in the previous block and is read in a way similar to the following:

In the above figure, we assume that the data of the file is sequentially written into the four block numbers 1->7->4->15, but this file system has no way to know the number of the four blocks in one breath. He has to have one. Once you have read the block, you will know where the next block is. If the block in which the same file data is written is too scattered, then our disk read head will not be able to read all the data in one round of the disk, so the disk will be rotated a few more times to be fully read. The contents of this file!

I often hear the so-called "defragmentation"? The reason for the need for defragmentation is that the file written by the file is too discrete, and the performance of the file read will be very poor. At this time, you can merge the blocks to which the same file belongs by defragmentation, so that reading the data will be easier! Of course, FAT's file system needs to be defragmented frequently. Does Ext2 need disk reorganization?

Since Ext2 is an indexed file system, it is basically not necessary to defragment often. However, if the file system is used for too long, often delete/edit/add files, it may still cause the file data to be too discrete. You may need to refactor at this time. However, to be honest, the bird brother did not defragment the Ext2/Ext3 file system on the Linux operating system! It doesn't seem to be needed! ^_^

You can use the ln command to create a new connection to an existing file without copying the contents of the file. The connection has a soft connection and a hard connection, and the soft connection is also called a symbol connection. Their respective characteristics are:

Hard link: Both the original file name and the connection file name point to the same physical address. The directory cannot have a hard connection; a hard connection cannot span a file system (cannot span different partitions) and the file has only one copy on the disk, saving disk space;

Since deleting files must be successful when the same index node is unique, it can prevent unnecessary accidental deletion.

Symbolic connection: The symbolic connection of a file created with the ln -s command is a type of linux special file. As a file, its data is the path name of the file to which it is connected. Similar to the shortcuts under windows.

You can delete the original file and save the connection file without preventing the accidental deletion.

The content of this paragraph is too abstract, and the nodes are arrays. I have tried to be popular and popular, and I can't add examples to demonstrate. If everyone is still in the fog, I have no choice but to remember it. I will slowly understand and understand it in practical applications in the future. This is also a way for me to learn.

8.6 representation of the file system in the kernel

'

Kernel data structure

The VFS subsystem of the Linux kernel can be illustrated as follows:

Deep analysis of the four main parts of the Linux system

File and IO: Each process saves a file descriptor table in the PCB (Process Control Block). The file descriptor is the index of this table. Each entry has a pointer to the opened file. Now we have To be clear: the opened file is represented in the kernel by the file structure, and the pointer in the file descriptor table points to the file structure.

The File Status Flag (member f_flags of the file structure) and the current read and write position (member f_pos of the file structure) are maintained in the file structure. In the above figure, both Process 1 and Process 2 open the same file, but correspond to different file structures, so there can be different File Status Flags and read and write locations. The more important members of the file structure are f_count, which means the Reference Count. As we will see later, system calls such as dup and fork will cause multiple file descriptors to point to the same file structure, for example, fd1 and Fd2 refers to the same file structure, then its reference count is 2, when close (fd1) does not release the file structure, but only reduce the reference count to 1, if close (fd2), the reference count Will reduce to 0 while releasing the file structure, which really closes the file.

Each file structure points to a file_operations structure. The members of this structure are function pointers that point to kernel functions that implement various file operations. For example, in the user program, a file descriptor is read. Read enters the kernel through the system call, and then finds the file structure pointed to by the file descriptor, finds the file_operations structure pointed to by the file structure, and calls the read member pointed to by it. Kernel functions to complete user requests. In the user program, lseek, read, write, ioctl, open and other functions are called. Finally, the kernel function pointed to by the kernel calls the members of file_operations to complete the user request.

The release member in the file_operations structure is used to complete the close request of the user program. The reason is called release instead of close because it does not necessarily close the file, but reduces the reference count. Only the reference count is reduced to 0 to close the file. For regular files opened on the same file system, the steps and methods of file operations such as read and write should be the same. The function called should be the same, so the file structure of the three open files in the figure points to the same file. A file_operations structure. If you open a character device file, then its read and write operations must be different from regular files. Instead of reading and writing disk data blocks, you can read and write hardware devices, so the file structure should point to different file_operations structures, each of which The file manipulation function is implemented by the driver of the device.

Each file structure has a pointer to the dentry structure, and "dentry" is an abbreviation for the directory entry. The parameters we pass to the functions of open, stat, etc. are a path, such as /home/akaedu/a, which needs to find the inode of the file according to the path. In order to reduce the number of reads, the kernel caches the tree structure of the directory, called dentry cache, where each node is a dentry structure, as long as the dentry search along the various parts of the path, from the root directory / find the home directory, Then find the akaedu directory and find the file a. The dentry cache only saves the most recently accessed directory entries. If the directory entry you are looking for is not in the cache, it will be read from disk to memory.

Each dentry structure has a pointer to the inode structure. The inode structure holds the information read from the disk inode. In the example above, there are two dentry, which represent /home/akaedu/a and /home/akaedu/b, respectively, which all point to the same inode, indicating that the two files are hard links to each other. The inode structure holds information read from the inode of the disk partition, such as owner, file size, file type, and permission bits. Each inode structure has a pointer to the inode_operations structure, which is also a set of function pointers to some kernel functions that perform file directory operations.

Unlike file_operations, inode_operations points to functions that do not operate on a file, but functions that affect the layout of files and directories, such as adding deleted files and directories, tracking symbolic links, etc., and inode structures belonging to the same file system. Can point to the same inode_operations structure.

The inode structure has a pointer to the super_block structure. The super_block structure holds information read from the superblock of the disk partition, such as file system type, block size, and so on. The s_root member of the super_block structure is a pointer to dentry, indicating where the root directory of the file system is mounted. In the example above, the partition is mounted to the /home directory.

The file, dentry, inode, and super_block structures form the core concept of VFS. For the ext2 file system, there are also concepts of inode and super block in the disk storage layout, so it is easy to establish a correspondence with the concept in VFS. Other file system formats come from non-UNIX systems (such as Windows FAT32, NTFS), there may be no such concept as inode or super block, but in order to mount to Linux system, you have to harden the driver in Linux. Look at the FAT32 and NTFS partitions and find that the permission bits are wrong. All files are rwxrwxrwx, because they don't have the concept of inode and permission bits, which is hard to make.

8.6 Mounting the file system

Each partition in the Linux system is a file system with its own directory hierarchy. Linux will form a system's total directory hierarchy in a certain way, separate file systems belonging to different partitions. The term "in a certain way" as used herein refers to the mounting.

Hang the top-level directory of one file system to a subdirectory of another file system, making them a whole, called a mount. Call this subdirectory a mount point.

For example, to read a formatted partition, CD or software device on the hard disk, you must first map these devices to a directory, which is called a "mount point". These devices can only be read. After the mount, the physical partition details are masked, and the user has only a unified logical concept. Everything is a file.

Note: 1. The mount point must be a directory.

2. A partition is mounted on an existing directory. This directory may not be empty, but the previous contents of this directory will not be available after mounting.

The same is true for the mounting of file systems created by other operating systems. However, it should be understood that the format of the file system used by CDs, floppy disks, and other operating systems is different from the file system format used by Linux. The CD is ISO9660; the floppy disk is fat16 or ext2; Windows NT is fat16, NTFS; Windows98 is fat16, fat32; Windows2000 and WindowsXP are fat16, fat32, NTFS. Before mounting, you need to know whether Linux supports the file system format to be mounted.

Mount the mount command, its format: mount [-parameter] [device name] [mount point] Commonly used parameters are

-t Specifies the file system type of the device (what file type is mentioned) -o specifies the options when mounting the file system. Some are also available in /etc/fstab. Commonly used

Codepage=XXX Code page iocharset=XXX Character set ro Mount rw in read-only mode Mount nouser in read-write mode Make general users unable to mount user Allow general users to mount devices

E.g:

1. Mount the file system of windows:

1) First we use sudo fdisk -l to view the mounted device, for example, the bottom: /dev/hda52) mkdir create a directory, the directory here is to hang in the directory, you have to mount the E disk to this directory :mk /mnt/winc3)Windows and linux are not a file system. In general, Linux does not mount the windows file system, so you have to manually mount: # mount -t vfat /dev/hda5 /mnt/winc ( -t Vfat pointed out that the file system fat32 here can now read and write these files in /mnt/winc and other directories.

2. Mount the CD: # mk /mnt/cdrom

# mount -t iso9660 /dev/cdrom /mnt/cdrom (The names of the shutdown disks are generally cdrom, this command is generally common)

3. Virtual machine shared folder: For example, under VirtualBox, the host is Windows, and Ubuntu is Guest. There are three steps:

1). 首先要安装虚拟电脑工具包:在VirtualBox的菜单里选择”设备”->”安装虚拟电脑工具包”,你会发现在Ubuntu桌面上多出一个光盘图标,这张光盘默认被自动加载到了文件夹/media/cdom0,而且/cdrom自动指向这个文件夹。默认设置下文件管理器会自动打开这张光盘,可以看到里面有个”VBoxLinuxAdditions.run”文件。打开一个命令行终端,依次输入”cd /cdrom”和”sudo sh ./VBoxLinuxAdditions.run”,不含双引号,开始安装工具包。安装完毕,会用英文提示要重启Ubuntu,建议立刻重启。重启后,比较明显的变化是鼠标是共享模式,并且剪贴板也和Windows共享了。如果有这些变化,说明虚拟电脑工具包已经装成功。

2). 下一步设置共享文件夹。

在共享文件夹设置窗口中,单击右侧的”添加一个共享文件夹”,路径选择你想要共享的Windows文件夹,共享名任取一个自己喜欢的,比如”myshare”,选项read-only是指是否只允许ubuntu读这个文件夹,请根据需要选择这个选项。

3). 在ubuntu下挂载这个共享文件夹:sudo mount -t vboxsf myshare /media/share其中”myshare”是之前取的共享文件夹的名字,”/media/share”是要挂载到的目标文件.

8.7 自动挂载windows分区

每次开机访问windows分区都要运行mount命令显然太烦琐,为什么访问其他的linux分区不用使用mount命令呢?

其实,每次开机时,linux自动将需要挂载的linux分区挂载上了。那么我们是不是可以设定让linux在启动的时候也挂载我们希望挂载的分区,如windows分区,以实现文件系统的自动挂载呢?

这是完全可以的。在/etc目录下有个fstab文件,它里面列出了linux开机时自动挂载的文件系统的列表。我的/etc/fstab文件如下:

/dev/hda2 / ext3 defaults 1 1/dev/hda1 /boot ext3 defaults 1 2none /dev/pts devpts gid=5,mode=620 0 0none /proc proc defaults 0 0none /dev/shm tmpfs defaults 0 0/dev/hda3 swap swap defaults 0 0/dev/cdrom /mnt/cdrom iso9660 noauto,codepage=936,iocharset=gb2312 0 0/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0/dev/hdb1 /mnt/winc vfat defaults,codepage=936,iocharset=cp936 0 0/dev/hda5 /mnt/wind vfat defaults,codepage=936,iocharset=cp936 0 0

在/etc/fstab文件里,第一列是挂载的文件系统的设备名,第二列是挂载点,第三列是挂载的文件系统类型,第四列是挂载的选项,选项间用逗号分隔。第五六列不知道是什么意思,还望高手指点。

在最后两行是我手工添加的windows下的C;D盘,加了codepage=936和iocharset=cp936参数以支持中文文件名。参数defaults实际上包含了一组默认参数:

rw 以可读写模式挂载suid 开启用户ID和群组ID设置位dev 可解读文件系统上的字符或区块设备exec 可执行二进制文件auto 自动挂载nouser 使一般用户无法挂载async 以非同步方式执行文件系统的输入输出操作

大家可以看到在这个列表里,光驱和软驱是不自动挂载的,参数设置为noauto。(如果你非要设成自动挂载,你要确保每次开机时你的光驱和软驱里都要有盘,呵呵。)

8.8 .软连接、硬链接

可以用ln命令对一个已经存在的文件再建立一个新的连接,而不复制文件的内容。连接有软连接和硬连接之分,软连接又叫符号连接。它们各自的特点是:

硬连接:是给文件一个副本,原文件名和连接文件名都指向相同的物理地址。目录不能有硬连接;硬连接不能跨越文件系统(不能跨越不同的分区)文件在磁盘中只有一个拷贝,节省硬盘空间;

修改其中一个,与其连接的文件同时被修改。如果删除其中任意一个其余的文件将不受影响。

由于删除文件要在同一个索引节点属于唯一的连接时才能成功,因此可以防止不必要的误删除。

符号连接(软连接):用ln -s命令建立文件的符号连接符号连接是linux特殊文件的一种,作为一个文件,它的数据是它所连接的文件的路径名。类似windows下的快捷方式。

当然删除这个连接,也不会影响到源文件,但对连接文件的使用、引用都是直接调用源文件的。

具体关系可以看下图:

图5:软链接和硬链接

从图上可以看出硬链接和软链接的区别:

1:硬链接原文件和新文件的inode编号一致。而软链接不一样。

2:对原文件删除,会导致软链接不可用,而硬链接不受影响。

3:对原文件的修改,软、硬链接文件内容也一样的修改,因为都是指向同一个文件内容的。

8.9.文件目录管理命令

磁盘和文件空间:fdisk df du

文件目录与管理: cd pwd mkdir rmdir ls cp rm mv

查看文件内容 cat、tac、more、less、head 、tail

文件目录与权限:chmod chown chgrp umask

文件查找:which、whereis、locate、find、find

9. linux 应用

标准的Linux系统一般都有一套都有称为应用程序的程序集,它包括文本编辑器、编程语言、X Window、办公套件、Internet工具和数据库等。

10. linux内核参数优化

内核参数是用户和系统内核之间交互的一个接口,通过这个接口,用户可以在系统运行的同时动态更新内核配置,而这些内核参数是通过Linux Proc文件系统存在的。因此,可以通过调整Proc文件系统达到优化Linux性能的目的。

Vape Pen 1600 Puffs

Cigfun vape box is a new developed disposable vape pen. The housing used two-color injection mold, blue sky and white, green and white, watermelon and white, purple and white, those are really attractive color design.


The mouthpiece is more comfortable to mouth and tongue, mesh coil vaporizer, 1.2ohm resistance, let you get big vapor and excellent e liquid taste. The innovative vaporizer technology keeps the same flavor from A to Z.


5ml juicy flavor pod capacity, 850mah cobalt battery, giving non-rechargeable feature.

Special made e juice, premium quality, no harmful substance when heating.

Grape Ice/ Energy Ice/ Blueberry Ice/ Watermelon Ice/ Cool Mint/ Banana Ice/ Cherry Ice/ Watermelon ice...more is coming! Customize supported!


Axiswell is the world's leading manufacturer of Vape Pens. Our business covers ENDS (Electronic Nicotine Delivery Systems) and other vaping devices, such as disposable vape, refillable vape pen, pod system, CBD vape pen, cbd pods, etc. We maintain factory price, good quality, providing vapers safe and competitive price vaping products.

Moreover, we're dedicated to establishing a healthy and sustainable environment for the whole vaping industry.

1500 Puffs Disposable Vape,1600 Puffs Vape,E Cigarette 1600 Puffs,Disposable E Cig 1500 Puffs,1500 Puff Bars

Shenzhen Axiswell Technology Co., Ltd , https://www.medhealthycare.com

Posted on