CentOS for Linux (5)-how to mount a linux mount device (USB flash drive, CD, iso, etc.)

Source: Internet
Author: User

After learning about the Linux system, it was still quite smooth in general. For example, all the commands that can be typed in will get corresponding results .... But today, when I learned how to mount the Linux mount command, I was really depressed for a long time. It took about two hours. I found that no solution was found for various google and baidu instances... In the end, it was an unintentional trick that made the problem suddenly open, so I wrote an article for the mount command here.

I,Mount command

First, let's briefly introduce the mount command:

In Linux, if you want to use storage devices such as hard disks, CDs, floppy disks, or modisks, you must Mount them first ). After the storage device is mounted, it can be accessed as a directory. To mount a device, run the mount command. To execute this command, you must determine at least three types of information:

1. File System Type of the Mount object to be mounted;
2. Name of the device to Mount (Mount) object (/dev /...);
3. The directory to which the device is mounted. Because I installed CentOS6.4 64-bit system on the vmvm, if I want to upload files on windows to Linux on the VM, I can use the following methods: 1. install VMware-Tools. If it is easy to install it on windows, click Install. The installation process on Linux will be recorded later.
2. mount the ISO file, find the file we need on windows, and then use UltraISO (a powerful and convenient and practical tool for creating, editing, and converting CD image files ), use this to create an IOS image file and mount it to the Linux system on the virtual machine.
3. Enable the file sharing function on the virtual machine. In this way, files are transmitted to Linux on the Virtual Machine by sharing folders on windows. (This is only available after VMware-Tools is installed ).
Here, I use the second method to mount an ISO file to a Linux system ( The partition and mount concepts of Linux systems will be detailed in the future.) Ii. Mount the ISO file to the Linux SystemFirst, make the required files (jdk1.7, tomcat, eclipse, and other Linux software) into an ISO file through UltraISO. For example, I named it linuxSoft. iso.
First, choose VM> Settings at the top of the VM To Go To The Settings page: select the newly created ISO file in the Use ISO image file on the right ,( Note: The two check boxes in the upper-right corner must be marked with √.) Click OK. We can see that there is a virtual optical drive attached to our desktop... That is, the iso file we just mounted is the software we just needed after it is opened: How to install these software will be detailed in the next article !!! 3. Small complaints about the mount command
You may find that the second step above makes it easy to mount the file to Linux, and it is useful to the mount command ..... So next I will talk about my mount command for a few hours yesterday.
After mounting the ISO file to Linux, run the mount command to mount the ISO file. The command is as follows:
Mount/mnt/cdrom // This command is to mount ISO to the/mnt/cdrom directory, so that I can access the content (Root permission is required for mounting)
When I typed this command as the root user, the following mount was reported: can't find/mnt/cdrom in/etc/fstable or/etc/mtab. So I went to google and found an article on google to handle this error:
Mount: can't find/mnt/cdrom in/etc/fstable or/etc/mtab 1. First, check # cat/etc/fstab to view a line similar to the following; /dev/hdc/media/cdrecorder auto users, exec, noauto, managed 0 0(The key to the problem is that after I checked the fstable, I had a similar sentence)Through this, we can know that hdc is a cdrom (dvdrom) device and a cdrecorder device. to verify our statement, use ls-l to list files; # ls-lh/dev/dvd * lrwxrwxrwx 1 root 3/dev/dvd-> hdc # ls-lh/dev/cdrom lrwxrwxrwx 1 root 3/dev/cdrom -> hdc # ls-lh/dev/cdwriter lrwxrwxrwx 1 root 3/dev/cdwriter-> hdc: the file names of DVDs, cdrom, and cdwriter are all linked to the hdc device, so the root cause of the optical drive device is/dev/hdc. It is known that the files are displayed in/etc/fstab, we can be sure that the disc is mounted /Media/cdrecorder directory; 2. Customize the cdrom Mount location; for example,/mnt/cdrom, so we can also mount the optical drive; Modify:/etc/fstab, change/dev/hdc/media/cdrecorder auto users, exec, noauto, and managed 0 to:/dev/hdc/mnt/cdrom auto users, exec, noauto, manage 0 0 and archive again. 3. Create an optical drive mount directory # mkdir/mnt/cdrom 4. mount commands # mount/dev/hdc/mnt/cdrom or # mount/dev/cdrom/mnt/cdrom

Because the code similar to/dev/hdc/media/cdrecorder auto users, exec, noauto, and managed 0 is not found, this setting will fail in the future .....

Continue to google, followed by more than N posts, summed up, nothing more than the following:

mount  -t auto /mnt/cdrom /dev/cdrom /media

This error also occurs after you press enter, saying that the cdrom folder cannot be found under mnt... However, when I use the mkdir/mnt/cdrom command, I keep reminding me that the optical drive is read-only and will not be created... I am a root user !!!! Once again, it ended in failure.

At this time, I accidentally found such a post and got some inspiration: mount: can't find/dev/cdrom in/etc/fstab or/etc/mtab solution, some points can be drawn from the above:The Linux system estimates that the default Mount location varies depending on the version, and may be mounted to the/mnt,/dev,/media directory.

If you can no longer mount the optical drive under/mnt, first check whether there is a cdrom file in the/dev/directory, and find that there is actually a file, and then I enter the/media Directory again, after I typed the ls-l command, I was shocked !!!

[root@xiaoluo media]$ ls -l

Result:

Dr-x ------. 1 xiaoluo 2048 March 31 13:26

I found that the ISO file we just attached was found under/media, and then I was excited. I continued to enter this directory, and then ls-l, I found all the files I needed !!!!

It seems that the CentOS6.4 system I installed has mounted the ISO image to the/media directory by default. Therefore, the mount command has not been used to mount the image to/mnt.

So I run the unmount command umount again to check whether the ISO image file can be detached from Linux:

[Root @ xiaoluo 20130331_132633] $ cd // when uninstalling the agent, first return it to the root directory [root @ xiaoluo 20130331_132633] $ umount/media/20130331_132633]

Then ls-l/media

I found that the ISO has been detached, so I was excited. I was wondering if I could re-mount it through mount/media. The result was disappointing !!!! The preceding errors are prompted during mounting... So I was so angry that I restarted the CentOS system and found that the selected ISO file was automatically mounted under the/media directory !!!!!!

Iv. My Solutions

At this time, I suddenly realized that the solution to my problem was summed up !!!!

On the 64-bit CentOS6.4 system that I installed, if I need to mount an ISO file, I will select the ISO file when I start the system.

Select here. After entering the system, CentOS will automatically mount the ISO file to us, which is stored in the/media/folder by default !, If we need to use the software installation package, we will directly copy it to another directory (Because this only mounts the ISO file to CentOS and is a virtual optical drive, all the files in it are read-only. If you need to install the file, you must first copy the file to another path, this is recorded in subsequent documents)

In this solution, I also referred to the posts of many friends and posted a good post for in-depth analysis of the mount command. Here I will release the link, hope to help other friends who have not solved this problem !!!

Linux mount mounting devices (USB flash drives, optical disks, iso, etc.)

Mount: can't find/dev/cdrom in/etc/fstab or/etc/mtab Solution

Introduction to the mount command in Linux

This article explains how to mount the ISO file in Linux. We will continue to record how to learn about Linux !!!!!!

 

Related Article

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.