Linux mount mounting devices (USB flash drives, optical disks, iso, etc.)

Source: Internet
Author: User

For beginners to learn the mount command, there will be a lot of questions. In fact, I want to know more about the special nature of the linux system. Linux is based on a file system. All devices correspond to the following devices:/dev. For example:

[Chengmo @ centos5 dev] $ ls | grep-E "^ (sd | hd )"
Hdc
Sda
Sda1
Sda2
Sdb
Sdb1

Sd * represents the scic Hard Disk

Therefore, when you need to access devices, we need to mount these devices. Let's take a look.

I. mount:

Different operating systems use different file system formats. MS-DOS supports FAT16 file system, Windows98 supports FAT16, FAT32 file system, WindowsNT supports FAT16, NTFS file system, Windows2000 supports FAT16, FAT32, NTFS file system format, currently, xp supports FAT32 and NTFS. The latest version of windows 7 introduces a new WinFS file system. Linux supports almost all file system formats, but ext2 or ext3 is generally used. Many users use a windows operating system. to access resources in other file systems in a running Linux system, use the Linux mount command.

Ii. mount format:

Mount command [-parameter] [device name] [mount point]

Note:

The [mount point] must be an existing directory. This directory cannot be empty. However, after mounting, the previous contents in this directory will be unavailable and umount will resume normal operation.

[Device name] can be a partition, a usb device, an optical drive, a floppy disk, or a network share.

Common parameters:

Mount mounted file system help
Parameters Description
Common parameters:
-T vfstype

Mount the specified device types: adfs, affs, autofs, coda, coherent, cramfs, devpts, efs, ext, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, nfs4, ntfs, proc, qnx4, ramfs, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs, xiafs

Common file types, which can have the same Automatic Detection (adfs, bfs, cramfs, ext, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, ntfs, qnx4, reiserfs, romfs, udf, ufs, vxfs, xfs, xiafs, and other file systems). If the test fails,/etc/filesystems is accessed to specify the file system detection. Note: If you are clear about the file system, it is best to specify a specific type. Detection errors can be disastrous.

Multiple file systems can be separated by commas (,).
Mount-a-t nomsdos, ext
Mount the fstab file to specify all the file systems except those of the msdos and ext types.

Common File Types

  1. Ext2 common file systems in linux
  2. Msdos MS-DOS fat, is fat16 vfat
  3. Commonly used fat32 in windows98
  4. Nfs Network File System
  5. Smbfs windows Sharing System
  6. ISO CD-ROM CD standard file system
  7. Ntfs windows NT/2000/XP File System
  8. Auto automatically detects the File System
-O options Specify mounting system options: multiple options can be separated by commas (,). Some options make sense only when they appear in the file/etc/fstab. The following options can be used for any file system to be mounted (but not all file systems care about them. For example, option sync is only valid for ext2, ext3, and ufs)
Option Description
Async All I/O operations on the file system must be completed asynchronously.
Atime Update the inode access time for each access. This is the default option.
Auto It can be mounted when the-a option is used.
Ults Contains the following options: rw, suid, dev, exec, auto, nouser, async.
Dev Parses character devices or block devices in a file system.
Exec Binary File Execution allowed
_ Netdev File Systems reside on devices that require network connection, avoiding network disconnection and constantly attaching resource consumption.
Noatime Do not update inode access time of the file system (improving the speed of the news server)
Noauto It can only be explicitly mounted.-a cannot mount it.
Nodev Do not parse character devices or block devices in the file system
Noexec It is not allowed to execute any binary files in the loaded file system.
Nosuid The set-user-identifier or set-group-identifier bit is not allowed.
Nouser Disable normal file system mounting (default)
Remount Try to remount a mounted file system. It is usually used to change the Mount tag, for example, from read-only mounting to read-write.
Ro Mounting in read-only mode
Rw Mounting in read/write mode
Suid Allow set-user-identifier or set-group-identifier bits to work
Sync When I/O operations are performed in synchronous mode, data will not be lost due to sudden power failure, but the disk burden is increased.
Dirsync All updates to directories in the file system should be synchronized, affecting the following system calls: creat, link, unlink, symlink, mkdir, rmdir, mknod, and rename
User A common user is allowed to mount the file system. The user name of the user is written to the mtab so that the user can unmount the file system again. This option implies the options noexec, nosuid, and nodev.
Users Allows each user to mount and detach a File System
Codepage Codepage = XXX code page
Iocharset Iocharset = XXX Character Set
Loop Mounting an iso file is often used by a maneuver device.
Username Username = username used by the user to access the device
Password Password = pass password for accessing the device
The following parameters are only useful for special file systems:
Uid/gid Uid = value and gid = value mount the system with special users and groups
Ownmask Ownmask = value owner permission mask
Othmask Othmask = value othmask permission mask
Different file systems support different attributes. You can find relevant information
- Search for the file system that meets the conditions in the/etc/fstab file and mount the file.
Format: mount-a-t type-o options. You do not need to specify the device/directory.
-F Test the mount system. Only check the devices and directories and do not mount the file system.
-N Do not record the mounting records in the/etc/mtab File
-R Install the file system as read-only, the same as (-o ro)
-W Install the file system as read/write, the same as (-o rw)
-L label Mount a partition with the specified volume label
-W Install the file system as read/write, the same as (-o rw)
-V Displays detailed Mount progress
-L List all mounted file systems
Other parameters:
-- Bind Remount part of the file hierarchy to other places. Only mount a single file system. If the directory has another file system, it cannot be mounted. You can use the -- rbind parameter if you need to mount all of them.
Mount -- bind olddir newdir 2 directories can access system content
-- Move Move a directory to another location, mount -- move olddir newdir
-H Show Help
-V Show version

Iii. Common partition loading methods:

  • Mount mounting an iso file:

# Mkdir/mnt/iso1

# Mount-o loop linuxsetup. iso/mnt/iso1

In linux, you can directly read the iso file without a virtual Optical Drive.

  • Mount the Optical Drive System

Generally, the CDROM device file is/dev/hdc. Usage:

# Mkdir/mnt/cdrom

# Mount/dev/hdc/mnt/cdrom-o iocharset = cp936

By default, the optical drive system is not specified and can be searched automatically. The encoding is specified as Chinese.

  • Mount a soft drive

# Mkdir/mnt/floppy

# Mount/dev/fd0/mnt/floppy

By default, the file system is not specified and can be searched automatically.

 

  • Mount and mount windows Shared Files (samba)

# Mkdir/mnt/winshare

# Mount-t smbfs-o username = w, password = w, codepage = 936, iocharset = gb2312 // 192.168.0.101/share/mnt/winshare

Specify the user name, password, and codepage used to access Shared data. codepage specifies the same Encoding As iocharset. The windows system is simplified Chinese.

Codepage specifies the code page of the file system. The Chinese code for simplified Chinese is 936. iocharset specifies the character set. For Simplified Chinese, cp936 or gb2312 is generally used.

  • Mount a USB flash drive

If the computer does not have other SCSI devices and usb peripherals, the path of the inserted usb flash drive device is/dev/sda1. Run the following command:

# Mkdir/mnt/upan

# Mount/dev/sda1/mnt/upan

Mount.

  • Mount the nfs System

Similar to windows shared connections. You must correctly configure the nfs service on the server. Then, you can view the connection through showmount-e 192.168.0.30 on the client.

Mount-t nfs 192.168.0.30:/tmp/mnt/nfs

  • Umount unmount the File System

Umount dir

As shown above: umout/mnt/upan or umount/dev/sda1

 

The preceding describes how to use the mount command. The-o parameter is the most complex. The parameters supported by different file systems may be different. If you encounter a special file system. We recommend that you check the relevant information. The following section describes the mount-Related Files: fstab format.

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.