Hard and soft connections to the Title:linux file system
date:2018-02-06t20:26:25+08:00
Tags: ["File System"]
Categories: ["Linux"]
To better illustrate what the file links are, let's start by talking about how Linux is managed on disk.
The file system format of Linux is called Extn (n=2,3,4), is a file system based on Inode (index node), is a data structure of all UNIX-like systems is also the core of the file system, each newly created file will be assigned an inode, And each file has a unique inode number. The inode can be simply interpreted as a pointer to the physical location where the file resides, and the attributes of the file are also stored in the inode.
Extn file system Read data process
The inode is just the location where the file is saved, and the actual file is saved in the data block area.
The Inode numbered 3 is a link to the file.
When we use the ls -l
command to view the file information, where the number of connections is the number of inode, we can ln
establish a hard link for the same file to establish multiple connections, it can make the same file can have a different path, and can be malicious delete, but there are the following points to note:
- Using a
ln
hard link is a direct reference to the inode of the target file, and all attributes, including the file's permission information, are also referenced together.
- It just replicates the inode, does not replicate the data block information, so the extra disk footprint is small, but also makes the hard link only available in the same partition.
To establish a soft connection needs to add -s
parameters, the soft connection equivalent to Windows shortcuts, can be built in any location, and the target Inode file attributes are not the same, there is no connection number +1, and can not play the role of backup, delete the original file after the soft connection will be invalidated.
Hard and soft connections for Linux file systems