Linux mount hard disk mount command usage and parameter details

Detailed explanation of mount command usage and parameters. Mount is a command under Linux. It can mount a partition to a folder in Linux, thereby linking the partition to the directory. Therefore, as long as we access this folder, it is equivalent to accessing the partition.

Mount command usage and parameter details

Mount is a command under Linux. It can mount a partition to a folder in Linux, thereby linking the partition with the directory. Therefore, as long as we access this folder, it is equivalent to accessing the partition.

Mount Command ( mount command )

First, let me introduce how to use the mount command.There are many parameters, here we mainly talk about the ones we are going to use today.

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

1. -t vfstype specifies the type of file system. Usually it is not necessary to specify it, mount will automatically select the correct type.

CD 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 are mainly used to describe the way devices or files are mounted.

loop: used to mount a file as a hard disk partition on the system ro: mount the device in read-only mode rw: mount the device in read-write mode iocharset: specifies the character set used to access the file system

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

Mount command to mount the CD image file

1. Create a CD image file from a CD. Insert the CD into the CD-ROM drive and execute the following command.
#cp /dev/cdrom /home/sunky/mydisk.iso or #dd if=/dev/cdrom of=/home/sunky/mydisk.iso

Note: Executing any of the above commands will create the CD in the current CD-ROM drive into a CD-ROM image file /home/sunky/mydisk.iso

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

Note: This command will create a CD image file /home/sunky/mydisk.iso from all the directories and files in the /home/sunky/mydir directory. The CD volume label is: mydisk

3. Mounting the CD image file
#mkdir /mnt/vcdrom

Note: Create a directory to be used as a mount point

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

Note: Use /mnt/vcdrom to access all files in the CD image file mydisk.iso.

Mounting a mobile hard disk

For Linux systems, USB-interfaced mobile hard disks are treated as SCSI devices. Before inserting a mobile hard disk, you should use fdisk –l or more /proc/partitions to check the system's hard disk and hard disk partitions.

[root at pldyrouter /]# fdisk -l

After connecting the mobile hard disk, use fdisk –l or more.
/proc/partitions Check the system's hard disk and hard disk partitions. You should be able to find an additional SCSI hard disk /dev/sdc and its two disk partitions /dev
/dev/sdc1, /dev/sdc2, where /dev/sdc5 is the logical partition of /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: 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 disk partitions, use the -t ntfs parameter, and for FAT32 disk partitions, use the -t vfat parameter. If the Chinese file name is displayed as garbled characters 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, you can use the fdisk partition command and the mkfs file system creation command to create the partition of the mobile hard disk into the ext2 and ext3 formats unique to the Linux system. This makes it more convenient to use in Linux. Use the following command to mount it directly.

#mount /dev/sdc1 /mnt/usbhd1

Mount USB flash drive

Like a mobile hard disk with a USB interface, a U disk is also treated as a SCSI device by the Linux system. The usage is exactly the same as a mobile hard disk. Before inserting a U disk, you should use fdisk –l or more /proc/partitions to check the system's hard disk and hard disk partition status.

[root at pldyrouter root]# fdisk -l

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

[root at pldyrouter root]# fdisk -l

The system has an additional SCSI hard disk /dev/sdd and a disk partition /dev/sdd1. /dev/sdd1 is the USB disk we want to mount.

#mkdir -p /mnt/usb

Note: Create a directory to be used 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 file name is displayed as garbled characters or not displayed at all, you can use the following command.

#mount -t vfat -o iocharset=cp936 /dev/sdd1 /mnt/usb

Mounting Windows file shares

The core of Windows network sharing is SMB/CIFS. To mount Windows disk sharing under Linux, you must install and use Samba
Software package. Most of the popular Linux distributions now include the Samba software package. If Samba is not installed when installing the Linux system, please install Samba first. Of course, you can also go tohttp://www.samba.orgThe new version available for download from the website is version 3.0.10.
After the Windows system share is set up, you can mount it on the Linux client. The specific operations are as follows:

# mkdir –p /mnt/samba

Note: Create a directory to be used 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 of a Windows computer with the IP address 10.140.133.23, and c$ is a disk share of this computer.
In this way, you can access the files on the Windows system disk through /mnt/samba on the Linux system. The above operations have been tested in redhat as server3, redflag server 4.1, suse server 9, and windows NT 4.0, windows 2000, windowsxp, and windows 2003.

Mounting UNIX system NFS file sharing

Similar to the network sharing of Windows, UNIX (Linux) system also has its own network sharing, that is NFS (Network File System). Below we will take SUN Solaris 2.8 and REDHAT as server 3 as examples to briefly introduce how to mount nfs network sharing under Linux.
Before mounting the NFS disk share on the Linux client, you must first configure the NFS server.

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

(1) Modify /etc/dfs/dfstab and 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 directories to be shared

2. The configuration method of the Linux system NFS server is as follows:

(1) Modify /etc/exports and 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 in the /export/home/directory are directories to be shared. 10.140.133.23, *,
linux-client is the IP address or host name of the Linux client that is allowed to mount this share. If you want to use the host name linux-client, you must
Add the linux-client host IP definition in the /etc/hosts file. The format is as follows:

10.140.133.23 linux-client

(2) Starting and stopping NFS services

/etc/rc.d/init.d/portmap start (PORTMAP is enabled by default in REDHAT) /etc/rc.d/init.d/nfs start Start NFS service /etc/rc.d/init.d/nfs stop Stop NFS service

Note: If you modify the /etc/export file to add a new share, you should stop the NFS service first and then start the NFS service for the newly added share to take effect.
The same effect can be achieved by using the command exportfs -rv.

3. Linux client mounts NFS shares of other Linux systems or UNIX systems
# mkdir –p /mnt/nfs

Note: Create a directory to be used 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, you can also use the host name here, but you must add the server IP definition in the local /etc/hosts file. /export/home/sunky is the directory shared by the server.
In this way, you can access files shared by other Linux systems or UNIX systems in NFS mode through /mnt/nfs on the Linux client.
The above operations have been tested in redhat as server 3, redflag server4.1, suse server 9, and Solaris 7, Solaris 8, and Solaris 9 for x86 environments.

Replenish:

Linux loads the CD-ROM drive:
(1) Before using the CD-ROM drive, you must mount it first:

#mount /dev/cdrom /mnt/cdrom

Then you can go to the /mnt/cdrom directory to read the contents of the CD.
(2) When you want to eject the CD, you must use the umout command, otherwise the CD-ROM drive will remain in a deadlock state:

# umount /mnt/cdrom
score

Leave a Reply

Your email address will not be published. Required fields are marked *