Crazy mounting: how to connect to common external devices in Linux

Source: Internet
Author: User
Article Title: Crazy mounting: How Linux connects to common external devices. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems, open source, and other basic classification Linux is an excellent open source operating system, linux can run on various computer systems from the largest to the smallest. With the increasingly mature and stable linux system and its unique advantages of open source code, linux has been widely used in the world. Nowadays, many enterprise computer systems are a hybrid system consisting of UNIX, Linux, and Windows systems. Data Exchange is often required between different systems. Next, based on my actual work experience, I will introduce how to mount a CD image file, a mobile hard disk, a USB flash disk, Windows network sharing, and UNIX NFS network sharing in linux.
 
  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
 
Where:
 
1.-t vfstype specifies the type of the file system, which is usually not required. Mount automatically selects the correct type. Common types include:
 
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
 
Network Sharing for UNIX (LINUX) files: nfs
 
2.-o options is used to describe the mounting method of a device or file. Common parameters include:
 
Loop: used to connect a file to the system as a hard disk partition.
 
Ro: mounting a device in read-only mode
 
Rw: mounting a device in read/write mode
 
Iocharset: Specifies 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 file
 
Thanks to the huge advances in disk technology in recent years, new computer systems are equipped with large-capacity disk systems. In Windows, many people are used to making software and materials into disc image files and using virtual optical drives. This has many advantages: 1. It reduces the wear and tear of the optical drive; 2. It is not a problem that the hard disk capacity is huge to store dozens of disc image files, and it is very convenient to use as needed; iii. Hard Disk reading speed is much higher than the disk reading speed, and the CPU usage is greatly reduced. In fact, it is more convenient to create and use a CD image in a linux system than in a Windows system. You do not have to borrow any third-party software package.
 
1. 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. Should I use fdisk before inserting a mobile hard disk? L or more/proc/partitions to view 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 4 32098+ 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 we can clearly see that the system has a SCSI hard disk/dev/sda and its four Disk Partitions/dev/sda1 --/dev/sda4, /dev/sda5 is the logical partition of/dev/sda4. After the mobile hard disk is connected, use fdisk again? L or more/proc/partitions to view 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 4 32098+ 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 34973473+ b Win95 FAT32


 
We should be able to find that there is an additional 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
 

[1] [2] Next page

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.