as long as the disk is the formula, it seems that it is the right thing, almost no one to ask why. A lot of experienced students have had this experience, that is, Fengfenghuohuo from a friend borrowed a full HD island Love action film of the mobile hard disk, after dark cool still want to leave some later to taste slowly, but there are some good quality of the film (size more than 4G) replication failure. Cross-Examine the reasons are often laughed at by experts: "What age you still use FAT32, hurriedly change NTFS it." "I think this time you have to ask, why not FAT32 and NTFS can do it?"
because they are different file systems with different capabilities and different abilities. fat32 is in Windows95 era began to adopt the file system, to now have someone in use (such as a USB flash drive), can be said to accompany our growing file system. FAT is the abbreviation for File Allocation table, which can be literally seen as a class table-like filesystem. Because the attribute used to describe the file size is a 32-bit, the maximum number of individual files that the . and ntfs Microsoft is specifically designed for NT systems, with a single file size of up to 2 T. NTFS is now supported for both Windows XP and Windows 7, which are most commonly used. As for how NTFS manages files a little less, because Microsoft has always been a "secret".
Linux also has its own filesystem-style, called extn(n=2, 3, 4). If you want to trace the origins of Extn, it is actually more ancient than FAT32 and NTFS. The Extn file system must contain the INODE data structure to represent a file and store various properties and permissions for the file. As for the actual data, it is placed in the block area of the information block. In addition, the Extn file system has a super block, which records the overall information of the entire file system, including the total amount, usage, and amount of the inode and data block.
Use stat-f filename You can view the Inode and data block usage of the system.
-F,--file-system
Display file system Status instead of file status
[Email protected]:/work/windows$ stat-f/work/workspace/so/main
File: "/work/workspace/so/main"
The following output is not related to the main file
id:1371e0e3c96e0461 file name Length: 255 type: EXT2/EXT3
Block Size: 4096 base block Size: 4096
Blocks: total: 23151106 free: 14056882 available: 12880870
Inodes: Total: 5881856 idle: 5836277
The data block, like the Inode, has a unique number, and the inode only needs to record these numbers to locate any piece of data for the entire file. We assume that there is an inode numbered 3, and that the data for the file it represents is placed in the several data blocks numbered 2, 5, 6, 8, 13, and 20. Then the process of reading this file is shown in Figure 1.
Figure 1 Extn file system Read data process
The file system using this method of data access is called an "indexed file system". How does it differ from the FAT32 that many people grow up with? Figure 2 shows the process.
Figure 2 FAT32 File system Read data process
Through the comparison of two graphs, we can clearly see that the Extn through the inode can get the location of the file data at a time, you can arrange the reading order of the disk, as far as possible to ensure that the disk only a lap of the case to read all the contents. The FAT32 only knows where the next data block will be until the corresponding data block is read in. If the data block of a file is scattered, it will be difficult to ensure that the disk is only rotated one lap to read all the information, and sometimes even a lot more laps to finish reading the data.
This is the "disk fragmentation" issue that we are very familiar with. Because of the long time to create, delete, read and write files, it is difficult to guarantee the location of the data block of the same file adjacent. Due to the read and write characteristics of FAT32, the performance of reading and writing will drop sharply when the data block is not adjacent. Therefore, in order to improve the disk performance of Windows system, it is very necessary to do "defrag" frequently.
For Linux , this file system basically does not need to defragment the disk. And you basically can't find the tools of the class. However, after long-time use of Linux system, there will be a problem of file data is too fragmented. Even if you can do a good job of planning, but a little bit of performance will have some impact, but not the use of FAT32 windows so serious. It is also true that a Linux system that has been in use for a long time can become slower due to disk fragmentation problems. Just don't need to care too much about it.
I. FILE-related
1. Node (inode)
In a Linux file system, files stored in a disk partition, regardless of type, have a number, which is the node number.
Can be viewed through ls-i .
2. Atime/ctime/mtime access Time/change time/modification time
The difference between the latter 2 is that CTime keeps track of both file attributes and data, and mtime only relates to file data.
For example, modifying the contents of a. sh file mtime change, but only the permissions of the. sh file, such as chmod a+x test.sh,ctime, change
stat filename allows you to view the Inode node information for a file:
3. Links
It is divided into soft links (symbolic links) and hard links. Either way, the synchronization of the linked file is maintained; You can use relative paths to link files.
A. Soft links (symbolic connections)
Ln -S Source Mesh
A shortcut to a class in Windows, which is actually a text file that contains the location information of the linked file, but differs from the node number of the linked file ; supports cross-partition links
Since it is a shortcut, its size is not the size of the linked file, but only a few bytes.
The stat command views the source files and the results of the soft links as follows:
[Email protected]:/work/workspace$ stat client.c
File: "Client.c"
size:686 blocks:8(indicates that a few data blocks were used in order to store the file, the result is not strict size/512) IO block:4096 Ordinary file
device:809h/2057d inode:131252 links:1
Access: (0644/-rw-r--r--) Uid: (1000/weiyuzhang) Gid: (1000/weiyuzhang)
access:2012-09-20 10:26:40.466391743 +0800
modify:2012-09-18 17:33:15.405397461 +0800
change:2012-09-20 10:25:06.786254344 +0800
[Email protected]:/work/workspace$ Stat Fake
File: "Fake", "client.c"
size:8 blocks:0 IO block:4096 Symbolic Link
device:809h/2057d inode:131318 links:1
Access: (0777/lrwxrwxrwx) Uid: (1000/weiyuzhang) Gid: (1000/weiyuzhang)
access:2012-09-20 10:24:12.236174347 +0800
modify:2012-09-20 10:24:11.486173237 +0800
change:2012-09-20 10:24:11.486173237 +0800
You can also see that by adding a soft connection, the Links in the stat information do not increase
B. Hard links
LN Source Mesh
Link by node number, that is, multiple file names point to the same node number, Windows does not have this feature;
Its function is to allow a file to have multiple valid path names to prevent accidental deletion. Deleting only one link does not affect the node itself and other links, and only the data block of the file will be released if the last link is deleted. That is, the condition that the file is really deleted is that all the hard-linked files associated with it are deleted.
Only within the same partition, otherwise prompt:
"Ln: Create a hard link" test "="/work/out ": Invalid cross-device connection"
The stat command looks at the source files and the results of the hard links as follows:
[Email protected]:/work/workspace$ stat client.c
File: "client.c"
size:686 blocks:8 io block:4096 normal file
device:809h/2057d< Span style= "White-space:pre" > inode:131252 links:2
Access: (0644/-rw-r--r--) uid: (1000/ Weiyuzhang) Gid: (1000/weiyuzhang)
access:2012-09-20 10:26:40.466391743 +0800
modify:2012-09-18 17:33:15.405397461 +0800
change:2012-09-20 10:25:06.786254344 +0800
[Email protected]:/work/workspace$ stat fake2
File: "Fake2"
size:686 blocks:8 IO block:4096 Normal file
device:809h/2057d inode:131252 links:2
Access: (0644/-rw-r--r--) Uid: (1000/weiyuzhang) Gid: (1000/weiyuzhang)
access:2012-09-20 10:26:40.466391743 +0800
modify:2012-09-18 17:33:15.405397461 +0800
change:2012-09-20 10:25:06.786254344 +0800
In addition, thesecond column of the LL command output also shows the number of hard links for the corresponding file .
[Email protected]:/tmp$ ll
Total Dosage 68
DRWXRWXRWT root root 4096 November 26 14:46.
Drwxr-xr-x root root 4096 November 9 16:42.. /
DRWX------ 2 weiyuzhang weiyuzhang 4096 November 09:10 com.google.chrome.x8ra1c/
DRWX------ 2 weiyuzhang weiyuzhang 4096 November 09:16 crx_75daf8cb7768/
prw-rw-r-- 1 weiyuzhang weiyuzhang 0 November 10:06 fifo|
4. Edit the file
In addition to VI, there is also a common tool is the nano.
In the list of commands that are valid at the bottom of it, ^ represents Control.
5. Touch
The access time and change time to update the file, although the contents of the file are not actually edited.
6. Compression and decompression
Provides two methods of compression for gzip and bzip2.
Tar zcvf archive.tar. GZ [File1 file2 ...]
Tar Jcvf Archive.tar. bz2 [File1 file2 ...]
7. Mounting
In the/dev directory, some of the available devices are storage devices, such as the floppy drive or CD-ROM. Accessing the content they provide is not a simple CD into the drive, and the storage drive needs to be mounted to the file system. In other words, the drive needs to be attached to a fixed directory.
Mount/dev/md1/mnt/alexdrive
Attach the drive/dev/md1 to the existing directory/mnt/alexdrive in the system. Once the drive is mounted, you can access the drive using any instruction from the file system.
View the drive names that are enabled, available through df-h.
In modern Linux distributions, some common devices, such as CD-ROMs and USB drives, can be automatically mounted by the system.
In addition, the mount instruction without parameters can output every mounted drive in the system and the file system used.
For example, inserting a USB flash drive can be seen through the Mount command:
......
/DEV/SDB1 on/media/username/pendrive type VFAT (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8= 1,SHOWEXEC,FLUSH,UHELPER=UDISKS2)
This is the result of automatic mounting of the system. /DEV/SDB1 is the drive name that corresponds to the USB flash drive. You can use umount/dev/sdb1 to cancel the mount. However, if you open the file again, it will be automatically mounted.
If you want a drive to mount automatically at boot time, or simply set a directory as the default mount point for a drive, you need to modify the/etc/fstab file.
8. File Search
A. locate & updatedb
Locate filename
This command is associated with updatedb and is completely dependent on the index, and if you create a new file, you cannot find it using locate unless you have performed updatedb
UpdateDB requires root access and is typically performed regularly through cron.
Linux file Instructions