Linux mount (Mount) command detailed

Source: Internet
Author: User

Linux is an excellent open-source operating system, can run in large-to-small to the palm of a variety of computer systems, with the growing maturity and stability of Linux systems and its unique advantages of open source code, Linux in the world has been more and more widely used. Nowadays, many enterprises ' computer systems are mixed systems composed of UNIX system, Linux system and Windows system, and data exchange between different systems is often needed. I'll show you how to mount a CD image file, a removable hard disk, a USB flash drive, and a Windows network share and UNIX NFS network share on a Linux system, based on my actual work experience.

  Hook up Command (Mount)

First of all, describe the use of the Mount command, the Mount command parameters are very many, here is the main talk about what we are going to use today.

Command format:

  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.

 Mount Disc image File

Due to the huge advances in disk technology in recent years, new computer systems are equipped with large-capacity disk systems, and many people in windows are accustomed to using the software and materials as disc image files through a virtual optical drive. This has many advantages: first, to reduce the wear of the optical drive; second, the hard disk capacity to store dozens of CD image files is not a problem, with the use of Tiaogan is very convenient; third, the hard disk reading speed is much higher than the optical disk reading speed, the CPU occupancy rate is greatly reduced. In fact, it is more convenient to make and use optical disk images in Linux than for Windows, without borrowing any third-party packages.

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

#cp/dev/cdrom/home/sunky/mydisk.iso or

#dd If=/dev/cdrom Of=/home/sunky/mydisk.iso

Note: Any of the above commands can be used to make discs in the current optical drive into a disc image file/home/sunky/mydisk.iso

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

#mkisofs-R-j-v Mydisk-o/home/sunky/mydisk.iso/home/sunky/mydir

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

3. Mounting of the disc image file (Mount)

#mkdir/mnt/vcdrom

Note: Create a directory to use as a mount point

#mount-O loop-t iso9660/home/sunky/mydisk.iso/mnt/vcdrom

Note: You can access all the files in the disk image file Mydisk.iso using/mnt/vcdrom.

  Hooking up a removable hard disk

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.

[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

Here you can see clearly that the system has a SCSI hard disk/DEV/SDA and its four disk partitions/dev/sda1-/DEV/SDA4,/DEV/SDA5 is the logical partition/DEV/SDA4 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

[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

You should be able to find a SCSI hard disk/DEV/SDC and its two disk partitions/dev/sdc1?,/DEV/SDC2, where/DEV/SDC5 is the logical partition of the/DEV/SDC2 partition. We can use the following command to hook up/DEV/SDC1 and/DEV/SDC5.

#mkdir-P/MNT/USBHD1

#mkdir-P/MNT/USBHD2

Note: Create a directory to use as a mount point

#mount-T NTFS/DEV/SDC1/MNT/USBHD1

#mount-T VFAT/DEV/SDC5/MNT/USBHD2

Note: 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.

#mount-T Ntfs-o iocharset=cp936/dev/sdc1/mnt/usbhd1

#mount-T Vfat-o iocharset=cp936/dev/sdc5/mnt/usbhd2

Using the Fdisk partitioning 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 easier to use under Linux. Use the following command to hook up directly.

#mount/DEV/SDC1/MNT/USBHD1

  Mount 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.

[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.

[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, 31)

The system has a SCSI hard disk/DEV/SDD and a disk partition/DEV/SDD1,/DEV/SDD1 is the USB stick we want to hook up.

#mkdir-P/MNT/USB

Note: Create a directory to use as a mount point

#mount-T Vfat/dev/sdd1/mnt/usb

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

#mount-T Vfat-o iocharset=cp936/dev/sdd1/mnt/usb

 Hooking up Windows file shares

The core of Windows network sharing is smb/cifs, where you have to install and use the Samba package if you want to mount a disk share for Windows on Linux. The majority of popular Linux distributions now contain samba packages, and if you install a Linux system without samba, install Samba first. Of course, you can also download the www.samba.org website ... The new version is 3.0.10 version.

When the Windows system share is set up, you can hook up (mount) on the Linux client, with the following details:

# Mkdir–p/mnt/samba

Note: Create a directory to use as a mount point

# mount-t Smbfs-o username=administrator,password=pldy123//10.140.133.23/c$/mnt/samba

Note: Administrator and pldy123 are a user name and password for the IP address of the 10.140.133.23 Windows computer, and C $ is a disk share on this computer

This allows you to access the files on the Windows system disk via/mnt/samba on your Linux system. These actions are tested in Redhat as server 3, Redflag Server 4.1, SuSE Server 9, and Windows NT 4.0, Windows 2000, Windows XP, Windows 2003 environments.

 Hooking up UNIX System NFS file shares

Similar to the Windows-based network share, UNIX (Linux) systems also have their own network shares, that is, NFS (Network File system), below we are in the Sun Solaris2.8 and Redhat as server 3 For example, briefly describe how to mount an NFS network share under Linux.

Before the Linux client mounts (Mount) NFS disk share, the NFS server must be configured first.

1. The Solaris system NFS Server configuration method is as follows:

(1) Modify/etc/dfs/dfstab, add shared directory

Share-f Nfs-o Rw/export/home/sunky

(2) Start the NFS service

#/etc/init.d/nfs.server Start

(3) After the NFS service is started, you can also use the following command to add a new share

# Share/export/home/sunky1

# Share/export/home/sunky2

Note:/export/home/sunky and/export/home/sunky1 are directories that are ready to be shared

2, the Linux system NFS server configuration method is as follows:

(1) Modify/etc/exports, add shared directory

/export/home/sunky 10.140.133.23 (rw)

/export/home/sunky1 * (rw)

/export/home/sunky2 linux-client (rw)

Note: Sunky, Sunky1, sunky2 in the/export/home/directory are the directories that are ready to be shared, 10.140.133.23, *, and linux-client are the IP addresses or host names that are allowed to hook up this shared Linux client. If you want to use hostname linux-client You must add the Linux-client host IP definition in the server host/etc/hosts file. The format is as follows:

10.140.133.23 linux-client

(2) Start and stop NFS services

/etc/rc.d/init.d/portmap Start (Portmap is started by default in Redhat)

/etc/rc.d/init.d/nfs Start NFS Service

/etc/rc.d/init.d/nfs Stop Stop NFS Service

Note: If you modify the/etc/export file to add new shares, you should stop the NFS service before starting the NFS service to make the newly added share work. The same effect can be achieved using the command EXPORTFS-RV.

3, Linux client mount (Mount) NFS sharing for other Linux systems or UNIX systems

# Mkdir–p/mnt/nfs

Note: Create a directory to use as a mount point

#mount-t Nfs-o RW 10.140.133.9:/export/home/sunky/mnt/nfs

Note: Here we assume that 10.140.133.9 is the host IP address of the NFS server, of course, the host name can be used here, but the server-side IP definition must be added to the native/etc/hosts file. /export/home/sunky the directory that is shared with the server.

This allows the Linux client to access files that are shared on NFS by other Linux systems or UNIX systems via/MNT/NFS. These actions are tested in Redhat as Server 3, Redflag server4.1, SuSE Server 9, and Solaris 7, Solaris 8, and Solaris 9 for X86&SPARC environments.

Permissions issues:

Server-side user jack, user ID 1818, GID for 1818, client side also has a user jack, but UID and GID is 1818. The client-side Jack wants to fully read the server-side/home/jack. The server-side/etc/exports is

Write this:

/home/jack * (rw,all_squash,anonuid=1818,anongid=1818)

This setup means that all client-side users access the server-side/home/jack this

When it is recorded, it will map to the server-side Jack (uid,gid=1818). My mount's results are

1. Client-side root can be fully accessed, including reading, writing, killing ... such as

2. The client side of Jack (uid,gid=1818) I can do:

RM-RF server_jack/*
CP Something server_jack/
mkdir server_jack/a

Let's tidy up the good layout below.

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:

Linux mount (Mount) command detailed

Related Article

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.