Linux mount command mount usage and Parameter Details

Source: Internet
Author: User

Linux mount command mount usage and Parameter Details
GuideMount is a command in Linux. It can mount a partition to a folder in Linux to associate the partition with the directory. Therefore, we only need to access this folder, this is equivalent to accessing the partition.Mount command)

First, we will introduce how to use the mount command. The mount command has many parameters. Here we will focus on what we will use today.

Command Format: mount [-t vfstype] [-o options] device dir

1.-t vfstype specifies the type of the file system, which is usually not required. mount automatically selects the correct type.

Disk or CD image: iso9660 DOS fat16 File System: msdos Windows 9x fat32 File System: vfat Windows NT ntfs file system: ntfs Mount Windows File network sharing: smbfs UNIX (LINUX) file network sharing: nfs

2.-o options is used to describe the mounting method of a device or file.

Loop: used to mount a file as a hard disk partition to the system ro: Use read-only mode to mount the device rw: Use read/write mode to mount the device iocharset: Specify the character set used to access the file system

3. the device to be mounted.
4. mount point of the dir device on the system ).

Attach a CD image file1. Create a CD image file from the CD. Put the CD in the optical drive and execute the following command.
# Cp/dev/cdrom/home/sunky/mydisk. iso or # dd if =/dev/cdrom of =/home/sunky/mydisk. iso

Note: You can execute any of the above commands to make the current CD in the optical drive into a CD image file/home/sunky/mydisk. iso

2. Make the files and directories into a CD image file and execute the following command.
#mkisofs -r -J -V mydisk -o /home/sunky/mydisk.iso /home/sunky/ mydir

Note: This command will make all the directories and files under the/home/sunky/mydir Directory into a CD image file/home/sunky/mydisk. iso, and the disc volume is marked as mydisk.

3. mount the disk image file)
#mkdir /mnt/vcdrom

Note: create a directory for mount point)

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

Note: You can use/mnt/vcdrom to access all files in the disk image file mydisk. iso.

Mount a mobile hard drive

For linux systems, mobile hard disks with USB interfaces are treated as SCSI devices. Before inserting a mobile hard disk, use fdisk-l or more/proc/partitions to view the system's hard disk and hard disk partition.

[root at pldyrouter /]# fdisk -l

After the mobile hard disk is connected, use fdisk-l or more.
/Proc/partitions to view the system's hard disk and hard disk partition, you should be able to find one more 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 mount/dev/sdc1 and
/Dev/sdc5.

#mkdir -p /mnt/usbhd1 #mkdir -p /mnt/usbhd2

Note: creating a directory is used as a mount point)

#mount -t ntfs /dev/sdc1 /mnt/usbhd1 #mount -t vfat /dev/sdc5 /mnt/usbhd2

Note: The-t ntfs parameter should be used for Disk Partitions In ntfs format, and the-t vfat parameter should be used for disk partitions in fat32 format. If the Chinese character file name is 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

In linux, The fdisk partition command and The mkfs file system creation command can be used to make the partition of the mobile hard disk into the ext2 and ext3 formats specific to the linux system. In this way, it is more convenient to use in linux. Use the following command to directly mount the file.

#mount /dev/sdc1 /mnt/usbhd1
Mount a USB flash drive

Like a USB-based mobile hard drive, USB flash drives are also treated as SCSI devices for linux systems. The usage is exactly the same as that of a mobile hard disk. Before inserting a USB flash drive, use fdisk-l or more/proc/partitions to view the hard disk and hard disk partition of the system.

[root at pldyrouter root]# fdisk -l

After the USB flash drive is inserted, use fdisk-l or more/proc/partitions to view the hard disk and hard disk partition of the system.

[root at pldyrouter root]# fdisk -l

The system has a SCSI hard disk/dev/sdd and a disk partition/dev/sdd1./dev/sdd1 is the USB flash drive to be attached.

#mkdir -p /mnt/usb

Note: create a directory for 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 garbled or not displayed, use the following command.

#mount -t vfat -o iocharset=cp936 /dev/sdd1 /mnt/usb
Mount Windows File Sharing

The core of Windows Network Sharing is SMB/CIFS. To mount windows disk sharing in linux, samba must be installed and used.
Software Package. Currently, most popular linux distributions already contain samba packages. If samba is not installed on linux, install samba first. Of course, you can download the new version 3.0.10 from www.samba.org.
After windows sharing is configured, you can mount the file on the linux client as follows:

# mkdir –p /mnt/samba

Note: create a directory for 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 windows computer with the IP address 10.140.133.23, and c $ is a disk share for this computer.
In this way, files on windows disks can be accessed through/mnt/samba on linux. The preceding operations are successfully performed in redhat as server3, redflag server 4.1, suse server 9, windows NT 4.0, windows 2000, windows XP, and windows 2003 environments.

Mount NFS file sharing in UNIX systems

Similar to windows Network Sharing, UNIX (Linux) systems also have their own network sharing, that is, NFS (Network File System ), next we will take SUN Solaris2.8 and REDHAT as server 3 as an example to briefly introduce how to mount nfs network sharing in linux.
Before mounting an NFS disk to a linux client, you must configure the NFS server.

1. Configure the NFS server of the Solaris system as follows:

(1) Modify/etc/dfs/dfstab to add a 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 shared directories.

2. Configure the NFS server in linux as follows:

(1) Modify/etc/exports to add a shared directory.

/export/home/sunky 10.140.133.23(rw) /export/home/sunky1 *(rw) /export/home/sunky2 linux-client(rw)

Note: sunky, sunky1, and sunky2 under the/export/home/directory are shared directories, 10.140.133.23 ,*,
Linux-client is the IP address or Host Name of the shared linux client. If you want to use the host name linux-client must be on the server host
Add the linux-client host ip definition in the/etc/hosts file. The format is as follows:

10.140.133.23 linux-client

(2) start and stop the NFS service

/Etc/rc. d/init. d/portmap start (PORTMAP is started by default in REDHAT)/etc/rc. d/init. d/nfs start the NFS service/etc/rc. d/init. d/nfs stop the NFS service

Note: If a new share is added to the/etc/export file, stop the NFS service and then start the NFS service to make the new share take effect.
The command exportfs-rv can also achieve the same effect.

3. mount the NFS share of other linux or UNIX systems on the linux Client
# mkdir –p /mnt/nfs

Note: create a directory for mount point)

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

Note: here we assume 10.140.133.9 is the ip address of the NFS server host. Of course, the host name can also be used here, but the Server ip address definition must be added to the local/etc/hosts file. /Export/home/sunky is the directory shared by the server.
In this way, you can use/mnt/nfs on the linux client to access files shared by NFS on other linux or UNIX systems.
The preceding operations are successfully performed in redhat as server 3, redflag server4.1, suse server 9, Solaris 7, Solaris 8, and Solaris 9 for x86 & iSCSI.

Supplement:

Linux drive loading:
(1) Before using the optical drive, you need to mount it first:

#mount /dev/cdrom /mnt/cdrom

Then you can access the/mnt/cdrom directory to read the content of the disc.
(2) When you want to exit the disc, you must use the umout command, otherwise the optical drive will remain in the deadlock status:

#umount /mnt/cdrom

From: http://www.linuxdo.com/archives/182

Address: http://www.linuxprobe.com/mount-detail-parameters/


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.