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--
This article mainly introduces "detailed introduction of mount commands of linux". In daily operation, I believe many people have doubts about the detailed introduction of linux mount commands. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "detailed introduction of linux mount commands". Next, please follow the editor to study!
Linux is an excellent open source operating system, which can run on all kinds of computer systems from large to small to palmtop. With the increasing maturity and stability of linux system and its unique advantages of open source, linux has been more and more widely used all over the world. At present, the computer systems of many enterprises are mixed systems composed of UNIX system, Linux system and Windows system, and data exchange is often needed between different systems. Based on my own practical work experience, I will introduce how to mount (mount) CD image files, removable hard disk, U disk, Windows network share and UNIX NFS network share under linux system.
Hook command (mount)
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, usually not necessarily. 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
Due to the great progress of disk technology in recent years, new computer systems are equipped with large-capacity disk systems. Under Windows, many people are used to making software and materials into CD-ROM image files to use virtual optical drives. This has many advantages: first, reduce the wear of the optical drive; second, now the huge capacity of the hard disk to store dozens of CD image files is not a problem, with the use and adjustment is very convenient; third, the reading speed of the hard disk is much higher than the reading speed of the CD, and the CPU occupancy rate is greatly reduced. In fact, making and using CD-ROM image under linux system is more convenient than Windows system, and there is no need to borrow any third-party software packages.
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
Disk / dev/sda: 73 dot 4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 1 432098 + de Dell Utility
/ dev/sda2 * 5 2554 20482875 7 HPFS/NTFS
/ dev/sda3 2555 7904 42973875 83 Linux
/ dev/sda4 7905 8924 8193150 f Win95 Ext'd (LBA)
/ dev/sda5 7905 8924 8193118 + 82 Linux swap
Here you can clearly see that the system has a SCSI hard drive / dev/sda and its four disk partitions / dev/sda1-/ dev/sda4, / dev/sda5 is the logical partition of the partition / dev/sda4. After connecting the removable hard drive, use fdisk-l or more / proc/partitions to check the hard disk and hard disk partition of the system.
[root at pldyrouter /] # fdisk-l
Disk / dev/sda: 73 dot 4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 1 432098 + de Dell Utility
/ dev/sda2 * 5 2554 20482875 7 HPFS/NTFS
/ dev/sda3 2555 7904 42973875 83 Linux
/ dev/sda4 7905 8924 8193150 f Win95 Ext'd (LBA)
/ dev/sda5 7905 8924 8193118 + 82 Linux swap
Disk / dev/sdc: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 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 3497347343 + b Win95 FAT32
You should be able to find an extra 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 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
Disk / dev/sda: 73 dot 4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 1 432098 + de Dell Utility
/ dev/sda2 * 5 2554 20482875 7 HPFS/NTFS
/ dev/sda3 2555 7904 42973875 83 Linux
/ dev/sda4 7905 8924 8193150 f Win95 Ext'd (LBA)
/ dev/sda5 7905 8924 8193118 + 82 Linux swap
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
Disk / dev/sda: 73 dot 4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 1 432098 + de Dell Utility
/ dev/sda2 * 5 2554 20482875 7 HPFS/NTFS
/ dev/sda3 2555 7904 42973875 83 Linux
/ dev/sda4 7905 8924 8193150 f Win95 Ext'd (LBA)
/ dev/sda5 7905 8924 8193118 + 82 Linux swap
Disk / dev/sdd: 131 MB, 131072000 bytes
9 heads, 32 sectors/track, 888 cylinders
Units = cylinders of 288 * 512 = 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= (1000, 8, 32) logical= (888,7,31)
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.
At this point, the study on "detailed introduction of mount commands of linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.