Attaching and detaching disks in Linux
In Linux, each file system has independent inode, block, and super block information. This file system can be used only when it is mounted to a directory tree, the operations that combine the file system with the directory tree are called mounting, and the opposite is detaching.
That is to say, the mount point must be a directory, while the directory is the entry to the disk partition (that is, the file system.
Pay attention to the following three points during mounting:
1. A single file system should not be repeatedly mounted to different mount points (directories;
2. Multiple file systems should not be mounted in a single directory.
# The two points are similar to the relationship between windows disks and drive letters.
3. The directory used as the mount point should theoretically be an empty directory
# If the directory is not empty, after the file system is mounted, the contents in the directory will disappear temporarily until the mounted device is detached.
The following are the specific operations:
Running Environment: Ubuntu Kylin14.04.1 LTS
Kernel version: Linux 3.20.- 32-generic
The next operation requires the root permission. If it is a newly installed Ubuntu, perform the following operations to set the root password:
1. Press Ctrl + ALT + F1 ~ on the graphic interface ~ F6 (F1 ~ Any one of F6 can) enter the command line mode, and enable Terminal on the desktop.
2. Run sudo passwd root.
3. Enter the current user password
4. Enter the root user password twice as prompted.
Uninstall:
1. Run the su root command to switch to the root user.
2. Run df-h to display all the current file systems. During ubuntu kylin installation, the sda device is automatically mounted to us.
Except for mounting sda9 to the/directory, all others are automatically mounted to the media/lkx/directory.
# The local host is linux + win7 + windows xp, And the ubuntu kylin automatic mounting function is too powerful, so the other two NTFS format system partitions are also mounted. Theoretically, partitions of other systems should not be mounted in one system!
Figure
/Dev/sda1 16G 7.2G 7.9G 48%/media/lkx/B6FC23AAFC2363B9 Windows xp Partition
/Dev/sda7 45G 33G 12G 74%/media/lkx/win7 partitions for win7
3. Next we will unmount all sda1, sda7, and sda6.
Run
Umount sda1
Umount sda7
Umount sda6
# "No message is good news" in Linux, so there is no prompt after uninstallation. An error will be reported only when the parameter is incorrect.
View other devices in the system after uninstallation
Run df-h to check that the three devices have been uninstalled.
Mount operation:
We just uninstalled/dev/sda6 --> soft. Now we mount it to the test folder under the root directory.
First, perform some initialization operations.
Cd/
Mkdir test
Direct Mount
Mount/dev/sda6/test
View results
Df-h
The disk has been mounted.
After attaching the disk, we can access the file system from the directory to view the data.
Run
Cd test
Ls-l
Understanding the concept of mounting in a Linux File System can compare it to assigning a drive letter to a new disk in a windows system. Only the drive letter can be used to access data on the disk, but there are still some differences, in windows, a directory is available only when a disk is available. In linux, a file system (Disk) can be mounted to a directory, which is determined by the features of the ext2/3 file system, for more details, refer to laruence's Linux private house dish
"Laruence Linux basic learning for Private food (third edition)" PDF version
This article permanently updates the link address: