We recommend that you use a Linux mount file system. For example, you may have some knowledge about the Linux mount file system. Then, we will give a full introduction to the Linux mount file system, I hope to mount a file system for you;
Currently, there are two ways to mount a file system: one is to mount a file through Linux mount, and the other is to automatically mount the file through the/etc/fstab file;
1. mount the disk partition or storage device through the Linux mount file)
The usage of mount files in Linux is also simple. Let's talk about some common commands. The command format for mounting file systems: [root @ localhost beinan] # Linux mount file [-t file system] [-o option] Device directory
Note:-t uses this parameter to specify the type of the file system. In general, you do not have to specify this parameter and sometimes you can recognize it, -t is followed by ext3, ext2, reiserfs, vfat, ntfs, etc. vfat is the parameter used by the fat32 and fat16 partition file systems. If you forget the file system, you can also add auto after-t;
-O: The primary options include permissions, users, disk quotas, and language encoding. However, most of the language encoding options are used in vfat and ntfs file systems. Because there are too many options, for more information, see mount files in man Linux;
A device is a storage device, such as/dev/hda1,/dev/sda1, and cdrom... for the storage devices in your system, you can use fdisk-l or/etc/fstab or dmesg. In general, the optical drive device is/dev/cdrom; the hard drive device is/dev/fd0; the hard drive and the mobile hard drive are subject to the output of fdisk-l;
1) Attach the optical drive and the drive; for example::
- [Root @ localhost beinan] # Linux mount file/dev/cdrom
- [Root @ localhost beinan] # Linux mount file/dev/fd0
The first line is the Linux mount file optical drive. As for the path to the Linux mount file, we can view it through/etc/fstab. Likewise, this is true for the drive/dev/fd0 device; for example, in/etc/fstab/dev/hdc/media/cdrecorder auto users, exec, noauto, managed 0 0
We can be certain that the CD is mounted to the/media/cdrecorder directory by the Linux mount file, but we can also specify the cdrom mount location by ourselves; for example,/mnt/cdrom, so we can also mount the optical drive;
- [Root @ localhost beinan] # mkdir/mnt/cdrom
- [Root @ localhost beinan] # Linux mount file/dev/cdrom/mnt/cdrom
First, create a directory and run the Linux mount FILE command so that the cdrom is mounted to/mnt/cdrom. Then, we can view the information and files on the CD in/mnt/cdrom; you can create this directory as needed. What directory is used is not the most important. It is important that you know what you are doing. For example, we can also build this Directory into a dvdrom, and then mount it with the Linux mount file/dev/cdrom/mnt/dvdrom;
Sometimes our devices are COMBO and support for dvd cd and burning. We 'd better check the optical drive devices in two ways: View/etc/fstab, second, use ls-l. For example, we can view a line similar to the following in/etc/fstab;/dev/hdc/media/cdrecorder auto users, exec, noauto, managed 0 0
Through this, we can know that hdc is a cdrom device and a cdrecorder device. to verify our statement, use ls-l to list files;
- [root@localhost beinan]# ls -lh /dev/dvd*
- lrwxrwxrwx 1 root root 3 2005-09-13 /dev/dvd -> hdc
- [root@localhost beinan]# ls -lh /dev/cdrom
- lrwxrwxrwx 1 root root 3 2005-09-13 /dev/cdrom -> hdc
- [root@localhost beinan]# ls -lh /dev/cdwriter
- lrwxrwxrwx 1 root root 3 2005-09-13 /dev/cdwriter -> hdc
Isn't it clear? The file names of DVDs, cdrom, and cdwriter are all linked to the hdc device. Therefore, the root cause of the optical drive is/dev/hdc. Therefore, we can also mount the optical drive;
- [Root @ localhost beinan] # mkdir/mnt/cdrom
- [Root @ localhost beinan] # Linux mount file/dev/hdc/mnt/cdrom
2) file systems that Mount hard disks and mobile hard disks;
A partition can only be used after a file system is created. As we have mentioned earlier, ext2, ext3, reiserfs, fat32, msdos, and ntfs are widely used in Linux;
[1] mounting a Linux File System;
You do not need to specify the file system encoding for ext2, ext3, and reiserfs. In fact, this function is not available for Linux mount files. If the encoding problem occurs for these Linux file systems, it is generally specified through export LANG; therefore, it is relatively simple to mount these file systems;
First, we need to create a directory to mount the file system. As we mentioned earlier, a partition with a file system must have a mount point to be mounted to the system; this mount point is a directory. For example, we learned through fdisk-l that hda5 is a Linux partition and created a file system, such as the reiserfs file system;
- [root@localhost beinan]# fdisk -l /dev/hda
- Disk /dev/hda: 80.0 GB, 80026361856 bytes
- 255 heads, 63 sectors/track, 9729 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Device Boot Start End Blocks Id System
- /dev/hda1 * 1 765 6144831 7 HPFS/NTFS
- /dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
- /dev/hda3 2806 9729 55617030 5 Extended
- /dev/hda5 2806 3825 8193118+ 83 Linux
- /dev/hda6 3826 5100 10241406 83 Linux
- /dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
- /dev/hda8 5199 6657 11719386 83 Linux
- /dev/hda9 6658 7751 8787523+ 83 Linux
- /dev/hda10 7752 9729 15888253+ 83 Linux
-
We first use fdisk-l to check the partition information: We want to mount the/dev/hda5 partition. For example, the hda5 partition creates the reiserfs file system;
- [Root @ localhost beinan] # mkdir/mnt/hda5/
- Note: Create a mount directory first;
- [Root @ localhost beinan] # chmod 777/mnt/hda5/
- Note: Set the/mnt/hda5 permission to be writable, readable, and executable by any user, so that all users can write data;
- [Root @ localhost beinan] # Linux mount file-t reiserfs/dev/hda5/mnt/hda5
- Note: Use-t reiserfs to specify/dev/hda5 as the reiserfs file system and mount it to the/mnt/hda5 directory;
- [Root @ localhost beinan] # Linux mount file-t auto/dev/hda5/mnt/hda5
- Note: if we do not know the reiserfs File System on hda5, we can use-t auto to determine the system and mount it to/mnt/hda5.
- [Root @ localhost beinan] # Linux mount file/dev/hda5/mnt/hda5
- Note: mount the file/dev/hda5 to/mnt/hda5 in Linux without adding any parameters. The system automatically judges the partition file system;
Is it mounted? We can check it through df-lh;
- [Root @ localhost beinan] # df-lh
- Filesystem capacity in use available % mount point
- /Dev/hda8 11G 8.5G 1.9G 83%/
- /Dev/shm 236 M 0 236 M 0%/dev/shm
- /Dev/hda10 16G 6.9G 8.3G 46%/mnt/hda10
- /Dev/hda5 7.9G 5.8G 2.1G 74%/mnt/hda5
[2] mount a Windows File System. See loading NTFS and FAT32 partitions in Fedora core 4.0.
3) unmount the file system uLinux mount file;
Command usage: [root @ localhost beinan] # examples of uLinux mounting file devices or mount directories: [root @ localhost beinan] # Linux mount file-t auto/dev/hda5/mnt/hda5 Note: mount/dev/hda5;
- Root @ localhost beinan] # df-lh Note: Check whether/dev/hda5 is mounted;
- Filesystem capacity in use available % mount point
- /Dev/hda8 11G 8.5G 1.9G 83%/
- /Dev/shm 236 M 0 236 M 0%/dev/shm
- /Dev/hda10 16G 6.9G 8.3G 46%/mnt/hda10
- /Dev/hda5 7.9G 5.8G 2.1G 74%/mnt/hda5
- [Root @ localhost beinan] # uLinux mount file/dev/hda5 Note: uninstall/dev/hda5
- [Root @ localhost beinan] # df-lh Note: Check whether/dev/hda5 is uninstalled;
- Filesystem capacity in use available % mount point
- /Dev/hda8 11G 8.5G 1.9G 83%/
- /Dev/shm 236 M 0 236 M 0%/dev/shm
- /Dev/hda10 16G 6.9G 8.3G 46%/mnt/hda10
- [Root @ localhost beinan] # uLinux mount file/dev/cdrom Note: uninstall cdrom;
- [Root @ localhost beinan] # uLinux mount file/dev/fd0 Note: detach a soft drive;
Another command is to check whether a partition is mounted. use Linux mount file-s [root @ localhost beinan] # Linux mount file-s
2. automatically mount the file system through the/etc/fstab file
1) Understand fstab
The above describes how to mount the file system of the storage device in Linux mount; now let's talk about how to automatically mount the file system at/etc/fstab; first, we need to check/etc/fstab. It mainly depends on the planning method;
- # This file is edited by fstab-sync - see 'man fstab-sync' for details
- LABEL=/1 / ext3 defaults 1 1
- /dev/devpts /dev/pts devpts gid=5,mode=620 0 0
- /dev/shm /dev/shm tmpfs defaults 0 0
- /dev/proc /proc proc defaults 0 0
- /dev/sys /sys sysfs defaults 0 0
- LABEL=SWAP-hda7 swap swap defaults 0 0
- /dev/hdc /media/cdrecorder auto users,exec,noauto,managed 0 0
The first field is the device name, which indicates a file system. Sometimes we call a mounted file system as a mount partition. In this field, you can also use a partition label; in the example,/LABEL =/1 is the LABEL of the partition installed by the Fedora system. You can use df-lh to view the partition where the partition is located;
- [Root @ localhost beinan] # df-lh
- Filesystem capacity in use available % mount point
- /Dev/hda8 11G 8.5G 1.9G 83%/
- /Dev/shm 236 M 0 236 M 0%/dev/shm
- /Dev/hda10 16G 6.9G 8.3G 46%/mnt/hda10
We can know that LABEL =/1 is the/dev/hda8 LABEL. What command should we use to create the hard disk partition LABEL? For ext3 and ext2 file systems, we can use e2label to set e2label device [newlabel]. For example, if we want to set the/dev/hda5 tag device with the file system as ext3, we should execute the following command:
- [Root @ localhost beinan] # e2label/dev/hda5/5
- [Root @ localhost beinan] # mkdir/mnt/hda5 Note: create a directory for mounting/dev/hda5 partitions;
- [Root @ localhost beinan] # chmod 777/mnt/hda5 Note: Open the permission and all users can read and write;
Then we need to add a/5/mnt/hda5 ext3 defaults 0 0 to/etc/fstab.
Warning: please do not practice in your Linux installation partition, that is, the Linux system/partition), will cause your Linux system to crash; if you want to practice, please test in other partitions; for the reiserfs file system, we should use the [root @ localhost beinan] # reiserfstune-l tag device for example: for example, I set the tag for the reiserfs File System/dev/hda10 to/10; [root @ localhost beinan] # reiserfstune-l/10/dev/hda10 add a line in/etc/fstab;/10/mnt/hda10 reiserfs defaults 0 0
Warning: please do not practice in your Linux installation partition, that is, the Linux system/partition), will cause your Linux system to crash; if you want to practice, please test in other partitions;
Field 2: mount point of the file system;
Field 3: File System Type;
Field 4: Linux mount FILE command options, similar to-o in Linux mount file; defaults includes these options rw, suid, dev, exec, auto, nouser, async; in practice, this by default can also meet our needs; for the meaning of these options, see man Linux mount file;
Field 5: indicates whether the file system requires dump backup. This is a true/false relationship. 1 is required, and 0 is not required;
Field 6: whether to use the fsck disk detection tool to check the file system when the system is started. 1 is required, 0 is not required, and 2 is skipped;
Based on these knowledge, for example, we want to automatically mount/dev/hda5 at startup; we can do the following;
[Root @ localhost beinan] # mkdir/mnt/hda5/Note: Create a mount directory first; [root @ localhost beinan] # chmod 777/mnt/hda5/Note: set the/mnt/hda5 permission to be writable and executable by any user, so that all users can write; then add the following row in/etc/fstab; /dev/hda5/mnt/hda5 reiserfs defaults 0 0 so restart the machine to see the effect;
- Basic usage of Linux mount command and umount command
- Linux mount Command System mounting and image processing
- The most basic commands in the Linux mount command
- Partitions of storage devices in the Linux File System
- Linux uses the actual physical hard disk as the Virtual File System