In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to use the mount command in linux. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
First of all, let's introduce the use of the mount command. There are a lot of parameters for the mount command. Here we will mainly talk about what we are going to use today.
Command format: mount [- t vfstype] [- o options] device dir
Where: 1. Murt vfstype specifies the type of file system, which is usually not required. Mount automatically selects the correct type. The common types are:
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.Muro options is mainly used to describe how devices or files are connected. The commonly used parameters are:
Loop: used to attach a file to the system as if it were a hard disk partition
Ro: attach devices in read-only mode
Rw: use read-write mode to connect devices
Iocharset: specifies the character set used to access the file system
3.device the device to be attached (mount).
The mounting point (mount point) of a 4.dir device on the system.
Hang the CD image file
1. Make a CD image file from the CD. Put the CD in 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: execute any of the above commands to make the CD in the current CD drive into a CD image file / home/sunky/mydisk.iso
2. Make the files and directories into CD-ROM image files and execute the following command.
# mkisofs-r-J-V mydisk-o / home/sunky/mydisk.iso / home/sunky/ mydir
Note: this command makes all the directories and files in the / home/sunky/mydir directory into a CD image file / home/sunky/mydisk.iso, and the CD volume is labeled: mydisk.
3. Mount of CD image files.
# mkdir / mnt/vcdrom
Note: create a directory to use as mount point.
# mount-o loop-t iso9660 / home/sunky/mydisk.iso / mnt/vcdrom
Note: use / mnt/vcdrom to access all the files in the disk image file mydisk.iso.
Attach a removable hard disk
For linux systems, the removable hard disk with USB interface is treated as a SCSI device. Before inserting a removable hard drive, use fdisk-l or more / proc/partitions to check the hard drive and hard disk partitions of the system.
[root at pldyrouter /] # fdisk-l
After connecting the removable hard disk, use fdisk-l or more / proc/partitions to check the hard disk and hard disk partition of the system. You should find an extra SCSI hard disk / dev/sdc and its two disk partitions / dev/sdc1? and / dev/sdc2, where / dev/sdc5 is the logical partition of the / dev/sdc2 partition. We can hook up / dev/sdc1 and / dev/sdc5 using the following command.
# mkdir-p / mnt/usbhd1
# mkdir-p / mnt/usbhd2
Note: create a directory to be 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-t vfat parameter should be used for disk partitions in fat32 format. If the Chinese character 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 fdisk partition command and mkfs file system creation command under linux system, the partition of mobile hard disk can be made into ext2 and ext3 format peculiar to linux system. In this way, it is more convenient to use under linux. Just hang up directly using the following command.
# mount / dev/sdc1 / mnt/usbhd1
Hang up the flash drive
Like the removable hard disk with USB interface, U disk is also treated as SCSI device for linux system. Use it in exactly the same way as a mobile hard drive. Before inserting a USB drive, use fdisk-l or more / proc/partitions to check the hard drive and hard disk partition of the system.
[root at pldyrouter root] # fdisk-l
After inserting the USB drive, use fdisk-l or more / proc/partitions to check the hard drive and hard disk partition of the system.
[root at pldyrouter root] # fdisk-l
A SCSI hard drive / dev/sdd and a disk partition / dev/sdd1,/dev/sdd1 are added to the system, which is the USB disk we want to attach.
# mkdir-p / mnt/usb
Note: create a directory to use as mount point.
# mount-t vfat / dev/sdd1 / mnt/usb
Note: you can now access the U disk through / mnt/usb. If the Chinese character file name is garbled or not, you can use the following command.
# mount-t vfat-o iocharset=cp936 / dev/sdd1 / mnt/usb
Hook up Windows file sharing
The core of Windows network sharing is SMB/CIFS. If you want to mount windows disk sharing under linux, you must install and use samba software package. The vast majority of popular linux distributions already contain samba packages, so install samba first if you don't have samba installed when you install linux. Of course, you can also download it from the www.samba.org website. The new version is version 3.0.10.
When the windows system share is set up, you can mount (mount) on the linux client, as shown below:
# mkdir-p / mnt/samba
Note: create a directory to use as mount point.
# mount-t smbfs-o username=administrator,password=pldy123 / / 10.140.133.23Univer c$ / mnt/samba
Note: administrator and pldy123 are a user name and password of a windows computer with ip address 10.140.133.23, and c $is a disk share of this computer
This makes it possible to access the files on the windows system disk through / mnt/samba on the linux system. The above operations have passed the test in the environment of redhat as server 3, redflag server 4.1, suse server 9 and windows NT 4.0, windows 2000, windows xp, windows 2003.
Hook up UNIX system NFS file sharing
Similar to windows network sharing, UNIX (Linux) system also has its own network sharing, that is, NFS (network file system). Let's take SUN Solaris2.8 and REDHAT as server 3 as examples to briefly introduce how to mount nfs network sharing under linux.
Before the linux client mounts (mount) the NFS disk share, the NFS server must be configured.
1. The configuration method for NFS server of Solaris system is 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 new shares
# 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 for NFS server of linux system is 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, sunky2 under the / export/home/ directory are the directories to be shared, and 10.140.133.23, *, linux-client are the IP addresses or hostnames that are allowed to attach to this shared linux client. If you want to use the hostname linux-client, you must add the linux-client host ip definition to the server host / etc/hosts file. The format is as follows:
10.140.133.23 linux-client
(2) start and stop NFS service
/ etc/rc.d/init.d/portmap start (PORTMAP is started by default in REDHAT)
/ etc/rc.d/init.d/nfs start starts the 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 first stop the NFS service, and then start the NFS service for the newly added share to work. The same effect can be achieved with the command exportfs-rv.
3. Linux client hook-up (mount) NFS sharing of other linux systems or UNIX systems
# mkdir-p / mnt/nfs
Note: create a directory to use as 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 hostname can also be used here, but the server ip definition must be added in the native / etc/hosts file. / export/home/sunky is the directory shared by the server.
In this way, files shared by other linux systems or UNIX systems can be accessed 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, Solaris 9 for x86&sparc environments.
Add:
Linux load CD-ROM drive
(1) before using the optical drive, mount: # mount / dev/cdrom / mnt/cdrom, and then you can go to the / mnt/cdrom directory to read the contents of the disc; (2) when you want to exit the disc, you must use the umout command, otherwise the optical drive will always be in a deadlock: # umount / mnt/cdrom.
After reading the above, do you have any further understanding of how to use the mount command in linux? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.