Mount the CD image file, mobile hard disk, USB flash disk, windows network share and NFS network share under Linux

Time:2022-5-23

Mount command

First, let’s introduce the use of the mount commandmethod, the mount command has a lot of parameters. Here we mainly talk about what we will use today.

Command format:

     mount [-t vfstype] [-o options] device dir

Of which:

     1.- T vfstype specifies the filesystemYou usually do not have to specify the type of. Mount will automatically select the correct type. Common types are:

CD or CD image: iso9660

DOS FAT16 filesystem:msdos

Windows 9x FAT32 filessystem:vfat

Windows NT NTFS filesystem:ntfs

Mount Windows filesnetworkShare: smbfs

UNIX (Linux) filesnetworkShare: NFS

2. – O options is mainly used to describe the attachment mode of equipment or files. Common parameters are:

Loop: used to attach a file as a hard disk partitionsystem

Ro: hook up the equipment in read-only mode

RW: connect the equipment by reading and writing

Iocharset: Specifies the access filesystemCharacter set used

3. Device the device to be mounted.

     4. Dir device insystemMount point on the.

Attach CD image file

Because in recent yearstechnologyGreat progress, new computerssystemAre equipped with large capacity diskssystem, under windows, many people are used to making software and materials into CD-ROM image files and using them through virtual CD-ROM drive. This has many advantages: first, it reduces the wear of the optical drive; 2、 Now the hard disk has a huge capacity, and it is not a problem to store dozens of optical disk image files. It is very convenient to use and adjust at any time; 3、 The reading speed of hard disk is much higher than that of optical disk, and the CPU occupation rate is greatly reduced. In fact, it is more convenient to make and use CD-ROM image under Linux system than windows system, and there is no need to borrow any third-party software package.

1. Create a disc image file from the disc. Put the disc into 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: execute any of the above commands to make the disc in the current drive into a disc image file / home / Sunky / mydisk iso

2. Make the file and directory into a disc image file and execute the following command.

      #mkisofs -r -J -V mydisk -o /home/sunky/mydisk.iso /home/sunky/ mydir

Note: this command makes all directories and files in / home / Sunky / mydir directory into CD image file / home / Sunky / mydisk ISO, disc volume label: mydisk

3. Mount of CD image file

      #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 / vcrom to access the disk image file mydisk All the documents in ISO.

     

Attach mobile hard disk

For Linux system, the mobile hard disk with USB interface is treated as SCSI device. Before inserting the mobile hard disk, you should use fdisk – L or more / proc / partitions to checksystemHard disk and hard disk partition.

     [[email protected] /]# fdisk -l

     Disk /dev/sda: 73.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

It can be clearly seen heresystemThere is a SCSI hard disk / dev / SDA and its four disk partitions / dev / sda1 — / dev / sda4, / dev / sda5 is the logical partition of partition / dev / sda4. After connecting the mobile hard disk, use fdisk – L or more / proc / partitions to checksystemHard disk and hard disk partition

     [[email protected] /]# fdisk -l

     Disk /dev/sda: 73.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

You should find 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 hook up / dev / SDC1 and / dev / sdc5 using the following command.

     #mkdir -p /mnt/usbhd1

     #mkdir -p /mnt/usbhd2

Note: create a directory to use as 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 NTFS format disk partitions, and the – t VFAT parameter should be used for FAT32 format disk partitions. 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 under Linux systemsystemThe create command can make the partition of mobile hard disk into ext2 and ext3 formats unique to Linux system. In this way, it is more convenient to use under Linux. Use the following command to connect directly.

     #mount /dev/sdc1 /mnt/usbhd1

Attach USB flash disk

Like the mobile hard disk with USB interface, for Linux system, the U disk is also treated as a SCSI device. usemethodIt’s exactly the same as a mobile hard disk. Before inserting the USB flash disk, you should check it with fdisk – L or more / proc / partitionssystemHard disk and hard disk partition.

     [[email protected] root]# fdisk -l

     Disk /dev/sda: 73.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

After inserting the USB flash disk, use fdisk – L or more / proc / partitions to view itsystemHard disk and hard disk partition.

     [[email protected] root]# fdisk -l

     Disk /dev/sda: 73.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/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)

     systemThere is an additional SCSI hard disk / dev / SDD and a disk partition / dev / SDD1, / dev / SDD1 is the U 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: now you can access the USB flash disk through / MNT / USB. If the Chinese character file name is displayed as garbled or not, you can use the following command.

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

Attach windows file share

The core of windows network sharing is SMB / CIFS. To mount Windows disk sharing under Linux, you mustinstallAnd using Samba package. Most of the popular Linux distributions now include Samba packages. IfinstallLinux system is not runninginstallSamba, please firstinstallsamba。 Of course, you can also go to www.samba.com Www.samba.org, the latest version is version 3.0.10.

Windows sharing systemset upAfter that, you can mount on the Linux clientoperationAs follows:

     # mkdir –p /mnt/samba

Note: create a directory to use as mount point

     # mount -t smbfs -o username=administrator,password=pldy123 //10.140.133.23/c$ /mnt/samba

Note: administrator and pldy123 are the user name and password of Windows computer with IP address of 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. aboveoperationIt passed the test in the environment of RedHat as server 3, Redflag Server 4.1, SUSE server 9, Windows NT 4.0, Windows 2000, Windows XP and windows 2003.

Attaching a UNIX System NFS file share

Similar to windowsnetworkShare, UNIX (Linux)systemHave their ownnetworkShare, that is NFS(networkfilesystem), let’s take sun Solaris 2 8 and RedHat as server 3 as examples to briefly introduce how to mount NFS network sharing under Linux.

The NFS server must be configured before the Linux client mounts the NFS disk share.

1. NFS server configuration of Solaris SystemmethodAs follows:

(1) Modify / etc / DFs / dfstab and add shared directory

     share -F nfs -o rw /export/home/sunky

(2) Start 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 the directories to be shared

2. NFS server configuration of Linux systemmethodAs 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 directory: / export / home / are the directories to be shared, and 10.140.133.23, *, and Linux client are the IP address or host name of the Linux client that is allowed to be attached to this shared Linux. If you want to use the host name, the Linux client must be inserviceAdd the Linux client host IP definition in the / etc / hosts file of the end host. The format is as follows:

     10.140.133.23 linux-client

(2) Start and stop services for NFS

/etc/rc. d/init. D / portmap start (portmap is started 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 first stop NFS and then start NFS to make the newly added share work. 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 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 NFS server. Of course, the host name can also be used here, but it must be added in the local / etc / hosts fileserviceEnd IP definition/ Export / home / Sunky isserviceThe directory shared by the client.

In this way, you can access files shared by other Linux systems or UNIX systems through / MNT / NFS on the Linux client. aboveoperationServer 3, server 4, red flag 1. SUSE server 9 and Solaris 7, Solaris 8 and Solaris 9 for x86 SPARC environment passed the test.

Recommended Today

Detailed explanation of new features of springboot2 and custom endpoints

New features of springboot2 custom endpoint package com.yan.otlan.springboot; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.boot.actuate.endpoint.annotation.Selector; import org.springframework.stereotype.Component; @Endpoint(id = “customPoint”) @Component public class StatusEndPoint { @ReadOperation public String getCustom(@Selector String name) { return “MyName is .” + name; } } Only three annotations are [email protected]、@ReadOperation、@Selector Start the springboot project If you see the red mapped, it […]