Linux mount command usage detailed parsing _unix Linux

Source: Internet
Author: User
Tags mkdir

Hook Command (Mount)
First, introduce the use of the Hook (Mount) command, the Mount command parameters are very many, here is the main point we want to use today.
Command format: Mount [-t vfstype] [-O options] Device dir
which

1.-t vfstype Specifies the type of file system, which is not usually specified. Mount automatically selects the correct type. Common types are:
Optical or optical 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

2.-o options are mainly used to describe how devices or files are hooked up. The commonly used parameters are:
Loop: Used to mount a file as a hard disk partition to connect the system
RO: Use read-only way to hook up equipment
RW: Hook up device with read-write mode
Iocharset: Specifies the character set used to access the file system

3.device the device to hook up (Mount).

4.dir device mount point on the system.

To hook up a disc image file

1. Make CD-ROM image files from CD-ROM. Put the CD into the CD drive and execute the following command.
#cp/dev/cdrom/home/sunky/mydisk.iso or
#dd If=/dev/cdrom Of=/home/sunky/mydisk.iso
Note: Perform any of the above commands to make the CD-ROM image file in the current CD-ROM/home/sunky/mydisk.iso

2, the files and directories made into a CD-ROM image files, to execute the following command.
#mkisofs-R-j-v Mydisk-o/home/sunky/mydisk.iso/home/sunky/mydir
Note: This command makes a CD-ROM image file of all directories and files in the/home/sunky/mydir directory/home/sunky/mydisk.iso, and the disc volume is labeled: Mydisk

3, CD-ROM image file Hook (mount)
#mkdir/mnt/vcdrom
Note: Create a directory for hanging contacts (mount point)
#mount-O loop-t iso9660/home/sunky/mydisk.iso/mnt/vcdrom
Note: Use/mnt/vcdrom to access all files in the disk image file Mydisk.iso.

Hook up a removable hard drive
For Linux systems, the USB interface's removable hard disk is treated as a SCSI device. Before you insert a mobile hard disk, you should use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partitions.
[Root at Pldyrouter/]# fdisk-l

After you have moved the hard disk, then use Fdisk–l or more/proc/partitions to view the system's hard disk and hard drive partitions. You should be able to find one more SCSI hard drive/DEV/SDC and its two disk partitions/dev/sdc1?,/DEV/SDC2, where/ DEV/SDC5 is a 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 for hanging contacts (mount point)
#mount-T NTFS/DEV/SDC1/MNT/USBHD1
#mount-T VFAT/DEV/SDC5/MNT/USBHD2
Note: Disk partitions in NTFS format should use the-T NTFS parameter, and the-T VFAT parameter should be used for disk partitions in FAT32 format. If the Chinese character file name appears garbled or does not display, 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 on Linux systems, you can make partitions of a removable hard disk into a ext2, ext3 format that is unique to the Linux system. In this way, it is more convenient to use Linux. Use the following command to hook up directly.
#mount/DEV/SDC1/MNT/USBHD1

hook u disk
with the USB interface of the mobile hard disk on the Linux system as a USB disk is treated as a SCSI device. Using the method is exactly the same as moving the hard disk. Before inserting a U disk, you should use Fdisk–l or more/proc/partitions to view the system's hard disk and hard disk partitions.
[Root at Pldyrouter root]# fdisk-l
Inserts a U disk, then uses fdisk–l or more/proc/partitions to view the system's hard disk and hard drive partitions. The
[root at Pldyrouter root]# fdisk-l
System has one more SCSI hard drive/DEV/SDD and one disk partition/DEV/SDD1,/DEV/SDD1 is the USB disk we want to hook up.
#mkdir-P/MNT/USB
Note: Create a directory to use for hanging Point (mount point)
#mount-T VFAT/DEV/SDD1/MNT/USB
Note: You can now access the USB drive via/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

To hook up a Windows file share
The core of Windows network sharing is smb/cifs, where you must install and use the Samba package to connect (mount) Windows disk sharing under Linux. Most popular Linux distributions now contain samba packages, and if you install the Linux system without samba, install Samba first. Of course, can also be downloaded to the www.samba.org website ... The new version is the 3.0.10 version.
When Windows system sharing is set up, you can hook up the Linux client (mount), as follows:
# Mkdir–p/mnt/samba
Note: Create a directory for hanging contacts (mount point)
# mount-t Smbfs-o username=administrator,password=pldy123//10.140.133.23/c$/mnt/samba
Note: The Administrator and pldy123 are a user name and password for the IP address 10.140.133.23 Windows computer, and C $ is a disk share for this computer
This allows access to the files on the Windows system disk via/mnt/samba on the Linux system. The above actions were tested in Redhat as server 3, Redflag Server 4.1, SuSE Server 9 and Windows NT 4.0, Windows 2000, Windows XP, and Windows 2003.

Hook up UNIX System NFS file sharing
Similar to Windows network sharing, UNIX (Linux) systems also have their own network share, that is, NFS (Network File system), below we take the Sun Solaris2.8 and Redhat as server 3 For example, let's take a look at how to mount an NFS network share under Linux.
Before Linux client Hook (Mount) NFS disk sharing, you must first configure the NFS server.

1, the Solaris System NFS Service-side configuration method is as follows:
(1) Modify/etc/dfs/dfstab, add the shared directory
Share-f Nfs-o Rw/export/home/sunky
(2) Start NFS Service
#/etc/init.d/nfs.server Start
(3) After the NFS service is started, you can also use the following command to add new shares
# Share/export/home/sunky1
# Share/export/home/sunky2
Note:/export/home/sunky and/export/home/sunky1 are the directories to be shared

2, the Linux system NFS server configuration methods are as follows:
(1) Modify/etc/exports, add the shared directory
/export/home/sunky 10.140.133.23 (rw)
/export/home/sunky1 * (rw)
/export/home/sunky2 linux-client (rw)
Note: The Sunky, Sunky1, sunky2 in the/export/home/directory are ready to share, 10.140.133.23, *, linux-client are the IP addresses or host names that are allowed to hook up this shared Linux client. If you want to use host name linux-client you must add the Linux-client host IP definition to the server-side 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 Server for NFS
/etc/rc.d/init.d/nfs Stop stopping NFS services
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 by using command EXPORTFS-RV.

3, Linux client Hook (mount) other Linux systems or UNIX system NFS sharing
# Mkdir–p/mnt/nfs
Note: Create a directory for hanging contacts (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, and of course the hostname can be used here, but the server-side IP definition must be added to the native/etc/hosts file. /export/home/sunky is a directory shared by the service side.

This makes it possible for Linux clients to access files that are shared by NFS in other Linux systems or UNIX systems via/MNT/NFS. The above tests are done in Redhat as Server 3, Redflag server4.1, SuSE Server 9, and Solaris 7, Solaris 8, Solaris 9 for X86&SPARC Environment

Add:
Linux Load Optical Drive
(1) Before using the optical drive, the first mount: #mount/dev/cdrom/mnt/cdrom, then you can enter the/mnt/cdrom directory to read the contents of the CD;

(2) When you want to exit the disc, you must use the Umout command, otherwise the optical drive will always be in a deadlock state: #umount/mnt/cdrom.

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.