Linux mount (Mount) command detailed

Source: Internet
Author: User

This article describes the use of the Mount command, as well as tips on how to image files, removable hard disks and USB drives.

One, Mount command (Mount)

How to use the Attach (Mount) command.

Command format:
The code is as follows:

Mount [-t vfstype] [-O options] Device dir

which
1.-t vfstype Specifies the type of file system that is not normally specified. Mount will automatically select the correct type. Common types are:
Disc or disc Image: iso9660
DOS FAT16 file system: MSDOS
Windows 9x FAT32 file system: VFAT
Windows NT NTFS file system: NTFS
Mount Windows file network share: SMBFS
UNIX (LINUX) file network share: NFS

The 2.-o options are primarily used to describe the way devices or files are hooked up. The commonly used parameters are:
Loop: Used to attach a file as a hard disk partition on the system
RO: Hook device with read-only method
RW: Mount device with read-write mode
Iocharset: Specifies the character set used to access the file system
3.device the device to mount (Mount).
Mount point of the 4.dir device on the system.

Second, attach the disc image file
It is easier to make and use disc mirroring under a Linux system than a Windows system, without having to borrow any third-party packages.

1. Make disc image file from CD-ROM. Put the disc in the CD drive and execute the command below.

 The code is as follows:
#cp/dev/cdrom/home/sunky/mydisk.iso or
#dd if=/dev/cdrom Of=/home/sunky/mydisk.iso

Description
Perform any of the commands above to make a disc image of the disc in the current CD-ROM:/home/sunky/mydisk.iso.

2. Make the files and directories into a disc image file, execute the following command.


The code is as follows:
#mkisofs-R-j-v mydisk-o/home/sunky/mydisk.iso/home/sunky/mydir

Description
This command will/home/sunky/mydir all directories and files in the directory, made into a disc image file/home/sunky/mydisk.iso, the disc is labeled as: Mydisk.

3. Mounting of the disc image file (Mount)


 The code is as follows:
#mkdir/mnt/vcdrom

Description: Create a directory to use as a mount point


 The code is as follows:
#mount-o loop-t iso9660/home/sunky/mydisk.iso/mnt/vcdrom

Description: Use the directory/mnt/vcdrom to access all files in the disk image file Mydisk.iso.

Third, mount the removable hard drive

For Linux systems, the USB interface's removable hard disk is treated as a SCSI device.
Before inserting a removable hard disk, you should first use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partition.


 The code is as follows:
[Root at Pldyrouter/]# fdisk-l
disk/dev/sda:73 Dot 4 GB, 73407820800 bytes
255 heads, Sectors/track, 8924 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 4 32098+ de Dell Utility
/dev/sda2 * 5 2554 20482875 7 Hpfs/ntfs
/dev/sda3 2555 7904 42973875 -up Linux
/dev/sda4 7905 8924 8193150 f Win95 Ext ' d (LBA)
/dev/sda5 7905 8924 8193118+, Linux swap

From the above information, it is known that the system has a SCSI hard disk/DEV/SDA and its four disk partition/DEV/SDA1-/DEV/SDA4,/DEV/SDA5 is partition/DEV/SDA4 logical partition.
After the removable hard drive, then use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partition situation


The code is as follows:
[Root at Pldyrouter/]# fdisk-l
disk/dev/sda:73 Dot 4 GB, 73407820800 bytes
255 heads, Sectors/track, 8924 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 4 32098+ de Dell Utility
/dev/sda2 * 5 2554 20482875 7 Hpfs/ntfs
/dev/sda3 2555 7904 42973875 -up Linux
/dev/sda4 7905 8924 8193150 f Win95 Ext ' d (LBA)
/dev/sda5 7905 8924 8193118+, Linux swap
disk/dev/sdc:40.0 GB, 40007761920 bytes
255 heads, Sectors/track, 4864 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDC1 1 510 4096543+ 7 Hpfs/ntfs
/DEV/SDC2 511 4864 34973505 F Win95 Ext ' d (LBA)
/DEV/SDC5 511 4864 34973473+ b Win95 FAT32

From the above information, there is a SCSI hard disk/DEV/SDC and its two disk partition/DEV/SDC1?,/DEV/SDC2, where/DEV/SDC5 is the logical partition of the/DEV/SDC2 partition.

You can use the following command to hook up/DEV/SDC1 and/DEV/SDC5.


 The code is as follows:
#mkdir-P/MNT/USBHD1
#mkdir-P/MNT/USBHD2



Description
Create a directory to use as a mount point


 The code is as follows:
#mount-T ntfs/dev/sdc1/mnt/usbhd1
#mount-T vfat/dev/sdc5/mnt/usbhd2



Description
For NTFS-formatted disk partitions, you should use the-T NTFS parameter, and the-T VFAT parameter should be used for disk partitions in FAT32 format.
If the kanji file name is displayed as garbled or not displayed, you can use the following command format:


 The code is as follows:
#mount-T ntfs-o iocharset=cp936/dev/sdc1/mnt/usbhd1
#mount-T vfat-o iocharset=cp936/dev/sdc5/mnt/usbhd2



Using the Fdisk partition command and the Mkfs file system creation command under the Linux system, the partition of the removable hard disk can be made into the ext2, ext3 format peculiar to the Linux system.
This makes it much easier to use it under Linux.

Use the following command to hook up directly:


 The code is as follows:
#mount/dev/sdc1/mnt/usbhd1

Four, attach USB flash drive

As with the USB interface of a removable hard disk, the USB stick is also treated as a SCSI device for Linux systems.
Use the same method as moving the hard disk. Before inserting a USB flash drive, you should first use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partition.


 The code is as follows:
[Root at Pldyrouter root]# fdisk-l
disk/dev/sda:73 Dot 4 GB, 73407820800 bytes
255 heads, Sectors/track, 8924 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 4 32098+ de Dell Utility
/dev/sda2 * 5 2554 20482875 7 Hpfs/ntfs
/dev/sda3 2555 7904 42973875 -up Linux
/dev/sda4 7905 8924 8193150 f Win95 Ext ' d (LBA)
/dev/sda5 7905 8924 8193118+, Linux swap

After inserting the USB drive, use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partition.


 The code is as follows:
[Root at Pldyrouter root]# fdisk-l
disk/dev/sda:73 Dot 4 GB, 73407820800 bytes
255 heads, Sectors/track, 8924 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 4 32098+ de Dell Utility
/dev/sda2 * 5 2554 20482875 7 Hpfs/ntfs
/dev/sda3 2555 7904 42973875 -up Linux
/dev/sda4 7905 8924 8193150 f Win95 Ext ' d (LBA)
/dev/sda5 7905 8924 8193118+, Linux swap
disk/dev/sdd:131 MB, 131072000 bytes
9 Heads, sectors/track, 888 cylinders
Units = Cylinders of 288 * 147456 bytes
Device Boot Start End Blocks Id System
/DEV/SDD1 * 1 889 127983+ b Win95 FAT32
Partition 1 has different physical/logical endings:
phys= (8, +) logical= (888, 7, +)

The system has a SCSI hard disk/DEV/SDD and a disk partition/dev/sdd1.

/DEV/SDD1 is the USB drive we are going to hook up with, mount it with the following command:


 The code is as follows:
#mkdir-P/MNT/USB



Note: Create a directory to use as a mount point


 The code is as follows:
#mount-T Vfat/dev/sdd1/mnt/usb

Description: You can now access the USB flash drive through/MNT/USB, if the Chinese character file name is displayed as garbled or not displayed, please use the following command to access:


 The code is as follows:
#mount-T vfat-o iocharset=cp936/dev/sdd1/mnt/usb

Here, the use of Mount command mount in Linux is introduced, it is recommended that friends do more hands-on, their own practice under the above example, to help understand the content.

If you want to access resources in other file systems under running Linux, you will use the Mount command.

2. What is the basic usage of mount?
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 Specifies the file system type of the device, the common ones are:
EXT2 Linux currently used file system
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 Specifies the option to mount the file system, and some can also be written to the/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

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:

[Copy to Clipboard]
CODE:
# 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:
[Copy to Clipboard]
CODE:
# 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.
[Copy to Clipboard]
CODE:
# MOUNT/DEV/HDA5/MNT/HDA5
This allows access to the/MNT/HDA5 directory for resources in the partition.
3. 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.
[Copy to Clipboard]
CODE:
# 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:
[Copy to Clipboard]
CODE:
# Mount–o Iocharset=utf8/dev/hda5/mnt/hda5
4. Why is the partition normal user not writable after mount up?
Mount with –o umask=000:
[Copy to Clipboard]
CODE:
# Mount–o umask=000, Iocharset=cp936/dev/hda5/mnt/hda5
5. 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.
[Copy to Clipboard]
CODE:
# mount–t Vat/dev/hda5/mnt/hda5
6. Why can't I mount an NTFS partition?
This is why the kernel does not support the NTFS file system, please recompile the kernel or install the NTFS file system support package for the kernel so that the kernel has NTFS file system support.
7. 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:
[Copy to Clipboard]
CODE:
# mkdir/mnt/u
# mount/dev/sda1/mnt/u
Mount it.
8. 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:
[Copy to Clipboard]
CODE:
# Mkdir/mnt/iso
# Mount–o Loop Linux.iso/mnt/iso
Of course, mounting the mount point/mnt/iso is also read-only.
9. How can I not mount an ISO file?
In general, the kernel used by most distributions has compiled support for the loop device, but there is no case, so make sure that the kernel used by the system supports the loop device.
The second case is that the ISO file is placed in NTFS or other read-only file systems. The Mount loop device must be mounted to a writable partition, and currently the Linux kernel has very limited write support for the NTFS file system, please copy the ISO file to another writable file system before mounting.
10. How to mount the optical driveand floppy
Generally CDROM device file is/DEV/HDC, the device name of the floppy drive is/dev/fd0
[Copy to Clipboard]
CODE:
# Mkdir/mnt/cdrom
# Mount/dev/hdc/mnt/cdrom//Mount Optical Drive//
# Mkdir/mnt/floppy
# Mount/dev/fd0/mnt/floppy//Mount Floppy//
11. Why does the attached CD-ROM not display Chinese files?
Using the –o iocharset=cp936 option will generally solve the problem, otherwise use utf-8 encoding.
[Copy to Clipboard]
CODE:
# Mount–o Iocharset=cp936/dev/hdc/mnt/cdrom
12. 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:
[Copy to Clipboard]
CODE:
/dev/hda5/mnt/hda5 vfat defaults,iocharset=cp936, rw 0 0
13. How can I mount a samba partition?
[Copy to Clipboard]
CODE:
# 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.
What does mount--bind mean?
Mount--bind is to mount the contents of one directory to another directory, using the
[Copy to Clipboard]
CODE:
# mount--bindOlddir 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:
[Copy to Clipboard]
CODE:
# mount--moveOlddir Newdir can be.
If Mount--bind also wants to write to Fstab, the format is as follows:
[Copy to Clipboard]
CODE:
Olddir newdir None bind 0 0
What is the basic usage of umount?
For example,/DEV/HDA5 has been mounted on the/MNT/HDA5, using three commands can be uninstalled mounted file system
[Copy to Clipboard]
CODE:
# UMOUNT/DEV/HDA5
# UMOUNT/MNT/HDA5
# UMOUNT/DEV/HDA5/MNT/HDA5
16. 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:
[Copy to Clipboard]
CODE:
# 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.

Linux mount (Mount) command detailed

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.