带有示例Linux安装命令教程

As we know Linux operating system mainly uses files and folders as operational units. Files folders are stored in file systems and disks. There are different tools to manage file systems and disks. But mount is de facto command used to mount and list disks and file systems? In this tutorial, we will look at different types of usages of the mount.

众所周知,Linux操作系统主要使用文件和文件夹作为操作单元。 文件文件夹存储在文件系统和磁盘中。 有多种工具可以管理文件系统和磁盘。 但是mount实际上是用来挂载和列出磁盘和文件系统的命令吗? 在本教程中,我们将研究安装的不同类型的用法。

列出安装路径 (List Mounted Paths)

Normally most of the Linux operating systems are started by mounting some file systems for system partition and user partition. The mounted partitions can be changed according to configuration. These partitions and file systems can be listed just issuing mount command like below. In this example we can see that are are some pseudo partitions those used by operations system-related functionalities.

通常,大多数Linux操作系统是通过挂载一些用于系统分区和用户分区的文件系统来启动的。 可以根据配置更改已安装的分区。 这些分区和文件系统可以像下面那样通过发出mount命令列出。 在此示例中,我们可以看到一些与操作系统相关的功能所使用的伪分区。

$ mount
List Mounts
List Mounts
列表挂载

将给定分区或磁盘挂载到指定路径(Mount Given Partition or Disk To The Specified Path)

Mount file systems and partitions are not so hard or complex in the command line. To mount just provide the partitions that will be mounted and the destination where the mounted partition will be accessed.

在命令行中,挂载文件系统和分区并不那么困难或复杂。 要进行安装,只需提供将要安装的分区以及将访问已安装分区的目的地。

$ mount /dev/vdb1 /mnt

挂载Ext4文件系统 (Mount Ext4 File System)

In the previous example, we have mounted a partition without specifying a file system. Because the mount is decided the partitions file system automatically and set required parameters internally without needing any additional information. But sometimes this can not work. We can specify the file system type with -t parameter like below. In this example, we will mount the ext4 file system.

在前面的示例中,我们安装了一个分区,但未指定文件系统。 由于挂载已决定,因此分区文件系统会自动进行,并在内部设置所需的参数,而无需任何其他信息。 但是有时候这是行不通的。 我们可以使用-t参数指定文件系统类型,如下所示。 在此示例中,我们将挂载ext4文件系统。

$ mount -t ext4 /dev/vdb1 /mnt

挂载NTFS文件系统 (Mount NTFS File System)

As we know NTFS is a Windows native file system. The mounting NTFS file system is very similar. NTFS provides a reach feature set like the BTRFS file system which is used by some of the distributions. We can see from mount output that NTFS is named fuseblk .

众所周知,NTFS是Windows本机文件系统。 挂载的NTFS文件系统非常相似。 NTFS提供了一些BTRFS文件系统之类的覆盖范围功能集,某些发行版使用了该功能集。 从mount输出中可以看到NTFS名为fuseblk。

$ mount -t ntfs /dev/vdb1 /mnt

挂载FAT文件系统 (Mount FAT File System)

FAT is the predecessor of the NTFS file system and used wide in different systems like cameras, TV, etc. FAT file systems can be specifically mounted like below.

FAT是NTFS文件系统的前身,并广泛用于各种系统中,例如相机,电视等。FAT文件系统可以像下面这样专门安装。

$ mount | grep vdb1

挂载ISO文件系统 (Mount ISO File System)

CD-ROM is old technology nowadays. But the CD-ROM de facto file system ISO is used regularly for distribution of Linux distributions, Setup tools, etc. These ISO file systems can be mounted with the following command.

光盘是当今的旧技术。 但是CD-ROM实际上是文件系统ISO,通常用于Linux发行版,安装工具等的分发。可以使用以下命令挂载这些ISO文件系统。

$ mount -t iso9660 virtio-win.iso /mnt

挂载Fstab的所有文件系统 (Mount All File Systems Of Fstab)

Up to now we have mounted file systems by giving details. There is a configuration file used by mount which resides /etc/fstab . This file is used to mount file systems during boot time. But this configuration file can be used after boot.

到目前为止,我们已经通过提供详细信息来挂载文件系统。 挂载使用的配置文件位于/etc/fstab 。 该文件用于在引导期间挂载文件系统。 但是此配置文件可以在启动后使用。

$ sudo mount -a
$ mount -a

卸载Fstab的所有文件系统 (Unmount All File Systems Of Fstab)

In the previous example, we have used fstab file as mount configuration but this can be also used as unmount configuration to unmount all file systems specified in fstab.

在前面的示例中,我们已将fstab文件用作安装配置,但也可以用作卸载配置来卸载fstab中指定的所有文件系统。

$ sudo unmount -a

挂载Fstab的特定文件系统 (Mount Specific File Systems Of Fstab)

Fstab can be used to get mount configuration of the specific mount points. Below is an example fstab file that provides mount configuration for /mnt . We will mount this line by specifying the mount path.

Fstab可用于获取特定安装点的安装配置。 下面是一个示例fstab文件,该文件提供了/mnt安装配置。 我们将通过指定安装路径来安装此行。

UUID=01f0e46f-9e44-4e25-8712-886427a3798b /               ext4    errors=remount-ro 0       1 
UUID=764C4C593741045B                     /mnt            ntfs    errors=remount-ro 0       1

And we mount /mnt

然后我们挂载/mnt

$ mount /mnt

列出挂载的文件系统 (List Mounted File Systems)

Mounted file systems can be listed with -l parameter.

可以使用-l参数列出已挂载的文件系统。

$ mount -l
List Mounted File Systems
List Mounted File Systems
列出挂载的文件系统

列出已安装的Ext3文件系统(List Mounted Ext3 File Systems)

While listing specific file systems can be specified to be listed. This can be used

在列出时,可以指定要列出的特定文件系统。 可以用

$ mount -l -t ext3

列出已安装的Ext4文件系统 (List Mounted Ext4 File Systems)

Ext4 file systems can be listed with the -t ext4 parameter like below.

可以使用-t ext4参数列出Ext4文件系统,如下所示。

$ mount -l -t ext4

列出已安装的Btrfs文件系统 (List Mounted Btrfs File Systems)

Btrfs file systems can be a list with the -t btrfs like below.

Btrfs文件系统可以是带有-t btrfs的列表,如下所示。

$ mount -l -t btrfs

将安装的路径绑定到新路径 (Bind Mounted Path To New Path)

After mounting to a directory the mount point can be changed. We will provide the current mounted point and new mount point in a row with -B parameter. This actually does not removes old mount only adds the new directory as the mount.

挂载到目录后,可以更改挂载点。 我们将使用-B参数连续提供当前安装点和新安装点。 这实际上并不会删除旧的安装,而只是将新目录添加为安装。

$ mount -B /mnt /mnt2
Bind Mount To New Directory
Bind Mount To New Directory
绑定挂载到新目录

挂载文件系统只读(Mount File System Read Only)

While mounting file systems there are a lot of options that affect the mount operation. One of the most used options is to read/write option. By default file systems are mounted read/writeable. But there are some situations we need to mount read-only. Mount can mount read-only with -r.

挂载文件系统时,有很多选项会影响挂载操作。 最常用的选项之一是读/写选项。 默认情况下,文件系统以可读/可写方式安装。 但是在某些情况下,我们需要以只读方式挂载。 挂载可以使用-r挂载只读。

$ mount -r /mnt

重新挂载挂载的文件系统 (Remount Mounted File System)

All ready mounted file systems can be remounted easily with -o mount parameter. This is needed some times some configurations about the file system is changed and make new configuration effective.

可以使用-o mount参数轻松地重新安装所有现成的文件系统。 有时需要更改有关文件系统的某些配置并使新配置生效。

$ mount -o remount /mnt

卸载多个支架 (Unmount Multiple Mounts)

Previously we have mounted multiple mount points. Now we may want to unmount the multiple mount points with the following commands.

以前,我们已经安装了多个安装点。 现在,我们可能要使用以下命令卸载多个安装点。

$ umount /mnt /mnt2

懒惰卸载 (Lazy Unmount)

Unmounting have some restrictions. While there are operations on the mounted partitions these partitions can not be unmounted. This can be an unwanted situation. There is a workaround which will unmount the system after the operation on the mount point.

卸载有一些限制。 尽管已安装的分区上有操作,但无法卸载这些分区。 这可能是不想要的情况。 有一种解决方法,可以在安装点上执行操作后卸载系统。

$ umount -l /mnt

强制卸载 (Force Unmount)

In the previous example, we have looked lazy unmount which will wait for the operation to end in order to unmount the mount point. There is a hard way which will forcibly unmount the mount point. But keep in mind that this can create problems with file systems.

在前面的示例中,我们看过了懒惰卸载,它会等待操作结束才能卸载安装点。 有一种硬性方法会强制卸载挂载点。 但是请记住,这会在文件系统中造成问题。

$ umount -f /mnt
LEARN MORE  What Is Windows Sysinternal?
了解更多什么是Windows Sysinternal?

翻译自: https://www.poftut.com/linux-mount-command-tutorial-examples/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值