Basic usage of Linux Mount/umount commands and automatic mount of Boot

Source: Internet
Author: User

Format: Mount [-parameter] [device name] [Mount Point]

Among the parameters commonly used are:

-A installs all file systems that are class-out in the/etc/fstab file.

-F disguises mount, making checks on the device and the directory look, but does not really mount the file system.

-N does not record the installation in the/etc/mtab file.

-R tells the file system to be installed as read-only.

-V Displays the installation information in detail.

-W installs the file system as writable, which is the default for the command.

-T < file system type > Specifies the file system type of the device, which is common:

Ext2 is a commonly used file system for Linux

Msdos MS-DOS FAT, is FAT16

VFAT Windows98 commonly used FAT32

NFS Network File System

ISO9660 CD-ROM standard file system

File system for NTFS Windows NT/2000/XP

Auto automatically detects the file system

-O < options > Specifies options for mounting the file system, some of which can also be written to/etc/fstab. Commonly used are:

Defaults Use default values for all options (auto, Nouser, RW, suid)

Auto/noauto Allow/disallow installation with the –A option

Dev/nodev/Do not interpret special devices on file systems

Exec/noexec Allow/Disallow binary code execution

Suid/nosuid Confirm/Not confirm suid and Sgid bit

User/nouser Allow/Disallow normal users to mount

CODEPAGE=XXX code page

Iocharset=xxx Character Set

RO mount in read-only mode

RW mount in read-write mode

Remount Reinstall a file system that has already been installed

Loop mount "cyclotron device" and "ISO image file"

Note that the mount point must be a directory that already exists, this directory may not be empty, but the previous contents of this directory will not be available after mounting, Umount will return to normal later. When using multiple-o parameters,-O is used only once, and the parameters are separated by commas:

# Mount–o REMOUNT,RW/
For example, to mount the file system in Windows FAT32 D-disk, generally under Linux this partition corresponds to/dev/hda5, depending on the specific partition situation will be different, here is hda5 to illustrate:

# MKDIR/MNT/HDA5//Create hda5 directory as mount point, location and directory name can be customized//

# mount-t Vfat/dev/hda5/mnt/hda5

In general, Linux automatically detects the file system of a partition, unless you specify it, the-t vfat can be omitted.

# MOUNT/DEV/HDA5/MNT/HDA5
This allows access to the/MNT/HDA5 directory for resources in the partition.


1. Why does the partition on Mount not display Chinese file as question mark/garbled?

Display a question mark indicating that there is no recognizable Chinese font in your system, please install the Chinese font first. Make sure your system is already well-displayed in Chinese. Shown as garbled is generally caused by the file system encoding used by the mount default and the actual encoding inconsistencies in the file system. To display Chinese files normally, mount requires the codepage and Iocharset options in the-o parameter. CODEPAGE specifies the code page of the file system, the Chinese code is 936;iocharset specified character set, Simplified Chinese is generally used cp936 or gb2312.

# Mount–o iocharset=gb2312 Codepage=936/dev/hda5/mnt/hda5


Generally speaking, mount–o iocharset=cp936/dev/hda5/mnt/hda5 can solve the problem.

If you have problems with this, try UTF-8 encoding:

# Mount–o Iocharset=utf8/dev/hda5/mnt/hda5



2. Why is the partition normal user not writable after mount up?

Mount with –o umask=000:

# Mount–o umask=000, Iocharset=cp936/dev/hda5/mnt/hda5



3. Why did the files in the partition after mount go into short filenames?

This is the reason why the file system hangs wrong, when the FAT32 is mounted as FAT16, this happens, first Umount, and then re-mount with –t vfat to solve the problem.

# mount–t Vat/dev/hda5/mnt/hda5



4. How do I mount a USB stick and mp3?

If the computer does not have other SCSI devices and USB peripherals, the device path of the inserted USB drive is/dev/sda1, using the command:

# mkdir/mnt/u

# mount/dev/sda1/mnt/u


Mount it.


5. Can I use the ISO file directly?

Yes, this option for mount makes it possible to have a free virtual optical drive under Linux, with the following specific usage:

# Mkdir/mnt/iso

# Mount–o Loop Linux.iso/mnt/iso


Of course, mounting the mount point/mnt/iso is also read-only.


6. How do I automatically mount partitions on boot?

It is cumbersome to enter such a long command for each mount, as long as the partition information is written to the/etc/fstab file to automatically mount the system boot, for example, to add the following line to the/DEV/HDA5 auto mount:

/dev/hda5/mnt/hda5 vfat defaults,iocharset=cp936, rw 0 0



7. How can I mount a samba partition?

# Mkdir/mnt/share

# mount-t Smbfs-o username=root,password=abc,codepage=936,iocharset=gb2312//192.168.1.100/share/mnt/share


If the Chinese display is not normal, try UTF-8 encoding. Of course, you can write to the fstab to implement automatic mounting.


8. What does Mount--bind mean?

Mount--bind is to mount the contents of one directory to another directory, using the

# Mount--bind Olddir newdir


This command makes it especially convenient for you to set up FTP to share a directory. If you want to cancel the Mount command:

# Mount--move Olddir newdir

Can.

If Mount--bind also wants to write to Fstab, the format is as follows:

Olddir newdir None bind 0 0



9. Why does the Umount show device busy?

This is because there is a program is accessing the device, the simplest way is to let the program to access the device to quit and then Umount. There may be times when users do not clear exactly what program is accessing the device, and if the user is not anxious to umount, it can be used:

# umount-l/mnt/hda5


To uninstall the device. The option –l is not immediately umount, but umount after the directory is idle. You can also use the command PS aux to see the device's program PID, and then use the command kill to kill the process of occupying the device, so umount very relieved.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Boot mount and/etc/fstab format

When we mount the disk, we can use the label of the disk as the mount point of the mounted disk, in addition to the Code of the disk (/DEV/HDXX). Basically, that is the/etc/fstab file settings, Label to do as the basis for disk mount, so there are good and bad:
Pros: No matter how hard the drive code is changed, regardless of whether you plug the hard drive into that IDE interface (IDE1 or IDE2 or master or slave, etc.), because the system is through the Label, the disk inserted in that interface will have no effect.
Disadvantage: If two hard disks are plugged in, just two hard disk labels are duplicated, it is miserable ~ because the system will not be able to determine that the disk partition slot is correct!

Boot Mount/etc/fstab and/etc/mtab:
Some limitations of the system mount:
The root directory/must be mounted, and will have to be mounted before the other mount point.
Other mount point must be an established directory that can be arbitrarily specified, but must adhere to the required System directory architecture principles
All mount point can be mounted only once at the same time.
All partition can only be mounted once within the same time.
To uninstall, you must first move the working directory outside of Mount point (and its subdirectories).

[Email protected] ~]# Cat/etc/fstab
# Device mount_point filesystem parameters Dump fsck
label=//ext3 defaults 1 1 (Mount with header name)
/dev/hda5/home ext3 Defaults 1 2
/dev/hda3 swap swap defaults 0 0
/dev/hdc/media/cdrom Auto pamconsole,exec,noauto,managed 0 0
/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


In fact, this/etc/fstab is to use mount to mount a device to the system of a certain mount point, the need to release the content of the instruction, the content is written into the/etc/fstab inside, and let the system boot on the active mount. So what are the parameters required when mount orders? is not the "device code, mount point, File System category, parameters," and so on, and our/etc/fstab added two additional functions, namely, the Backup command dump execution or not, and whether to boot the FSCK scan disk.
The previous 4 are already very familiar with, each file system also has many parameters can be added, such as Chinese code iocharset=big5,codepage=950, of course, there are a lot of common parameters, specifically can be seen in the detailed introduction of Mount, Specifically, the latter 2: Dump and fsck.

Can be played by the dump backup directive:
In Linux, you can use the dump command to make a backup of the system. And the dump command will be for the/etc/fstab set value, to choose whether to take the partition backup action! 0 means do not do dump backup, 1 represents the action to dump. 2 also represents to do dump backup action, however, the partition is less important than 1.

Whether to test the sector with FSCK:
During the boot process, the system preset will verify that the filesystem in our partition is complete (clean) with fsck. However, some filesystem do not need to be tested, such as virtual memory swap, or special file systems such as/proc and/sys, and so on. So, in this field, we can set whether to test the filesystem with fsck. 0 is not to test, 1 is to test, 2 is to be tested, but 1 will be more early test! In general, the root directory is set to 1, the other to test the filesystem are set to 2.

In general, when we edit the/etc/fstab, in order to avoid possible errors, usually with the MOUNT-A (analog boot automatic mount operation) This command to test to see it! This is a very important test action Oh!

/etc/fstab is the boot profile, however, the actual filesystem is recorded in the/etc/mtab and/proc/mounts two files. Each time we change the filesystem, we will also change the two files! However, in case of the data you entered in the/etc/fstab error, resulting in the failure to successfully boot success, and into the single maintenance mode, then the/but read only state, of course, you can not modify/etc/fstab, also cannot update/etc/mtab, it's OK, Use the following trick:

[Email protected] ~]# mount-n-o REMOUNT,RW/


Plus-n does not update/etc/mtab, plus-o provides additional parameter settings. Take advantage of this action, hehe! Your/will be able to read and write, then nature can update the contents of the file.

Basic usage of Linux Mount/umount commands and automatic mount of Boot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.