I have a iso file named ubuntu.iso
.
我有一个名为ubuntu.iso的iso文件。
I can mount
it with the command: mount ubuntu.iso /mnt
. After mounting it, I can see it from the outout of the command df -h
: /dev/loop0 825M 825M 0 100% /mnt
.
我可以使用以下命令挂载它:mount ubuntu.iso / mnt。安装后,我可以从命令df -h:/ dev / loop0 825M 825M 0 100%/ mnt的输出中看到它。
However, if I execute the command mount -o loop ubuntu.iso /mnt
, I'll get the same result.
但是,如果我执行命令mount -o loop ubuntu.iso / mnt,我将得到相同的结果。
As I know, loop device allows us to visit the iso file as a device, I think this is why we add the option -o loop
. But I can visit my iso file even if I only execute mount ubuntu.iso /mnt
.
据我所知,循环设备允许我们作为设备访问iso文件,我想这就是为什么我们添加选项-o循环。但即使我只执行mount ubuntu.iso / mnt,我也可以访问我的iso文件。
So I can't see the difference between mount
and mount -o loop
.
所以我看不出mount和mount -o循环之间的区别。
3 个解决方案
#1
16
Both versions use loop devices, and produce the same result; the short version relies on “cleverness” added to mount
in recent years. mount -o loop
tells mount
explicitly to use a loop device; it leaves the loop device itself up to mount
, which will look for an available device, set it up, and use that. (You can specify the device too with e.g. mount -o loop=/dev/loop1
.)
两个版本都使用循环设备,并产生相同的结果;短版本依赖于近年来增加的“聪明”。 mount -o loop告诉mount显式使用循环设备;它使循环设备本身可以安装,这将寻找可用的设备,设置并使用它。 (您也可以使用例如mount -o loop = / dev / loop1来指定设备。)
The cleverness is that, when given a device to mount, mount
will use libblkid
to determine its type; if it’s an image, it will automatically use a loop device to mount it.
聪明的是,当给定一个要挂载的设备时,mount将使用libblkid来确定它的类型;如果它是图像,它将自动使用循环设备来安装它。
The loop device section of the mount
man page has more details.
mount手册页的循环设备部分包含更多详细信息。
#2
4
The loop
device is primarily controlled with the losteup
command. So losetup -a
gives you overview about the used loop devices and attached files. The mount
command can mount the block device only. The loop device can create the virtual block device from a file (character device).
循环设备主要由losteup命令控制。因此,losetup -a为您提供有关已使用的循环设备和附加文件的概述。 mount命令只能挂载块设备。循环设备可以从文件(字符设备)创建虚拟块设备。
In fact there is a great difference between those commands because on older Linux systems the mount
could not recognise the file as the correct device to be mounted, but during the time the mount command was completed with lot of feature, hence it can now self decide to try to call the losetup command and mount the result. But if you got a whole disk image not iso format but e.g. with MBR at the beginning, the mount command could not recognise it and you have to find the usable partition (e.g. with the parted disk_image.raw unit B print
command) yoursef and than mount it with full option mount comman as :
实际上这些命令之间存在很大差异,因为在较旧的Linux系统上,mount无法将文件识别为要安装的正确设备,但在mount命令完成时具有很多功能,因此它现在可以自行决定尝试调用losetup命令并挂载结果。但是如果你得到的整个磁盘映像不是iso格式,而是在开头的MBR中,mount命令无法识别它,你必须找到可用的分区(例如,使用parted disk_image.raw unit B print命令)yoursef,然后使用完整选项mount comman将其挂载为:
mount disk_image.raw /mntpoint/ -o loop,offset=${OFFSET_of_PARTITION}
In this syntax the loop device was not specified and it is assumed the system choose the first free (/dev/loop0
, /dev/loop1
etc) Among the other new features of mount command is that you need not specify the filesystem type of the mounted block device (in your case -t iso9660
) if the filesystem support was installed.
在这个语法中没有指定循环设备,并假设系统选择第一个空闲(/ dev / loop0,/ dev / loop1等)。在mount命令的其他新功能中,您不需要指定文件系统的类型。如果安装了文件系统支持,则安装块设备(在您的情况下为-t iso9660)。
Thanks to all developers!
感谢所有开发人员!
#3
2
There is no difference between mount ubuntu.iso /mnt
and mount -o loop ubuntu.iso /mnt
.
mount ubuntu.iso / mnt和mount -o loop ubuntu.iso / mnt之间没有区别。
The first is transparently handled as if you had used the second.
第一个是透明处理,就像你使用了第二个。
#1
16
Both versions use loop devices, and produce the same result; the short version relies on “cleverness” added to mount
in recent years. mount -o loop
tells mount
explicitly to use a loop device; it leaves the loop device itself up to mount
, which will look for an available device, set it up, and use that. (You can specify the device too with e.g. mount -o loop=/dev/loop1
.)
两个版本都使用循环设备,并产生相同的结果;短版本依赖于近年来增加的“聪明”。 mount -o loop告诉mount显式使用循环设备;它使循环设备本身可以安装,这将寻找可用的设备,设置并使用它。 (您也可以使用例如mount -o loop = / dev / loop1来指定设备。)
The cleverness is that, when given a device to mount, mount
will use libblkid
to determine its type; if it’s an image, it will automatically use a loop device to mount it.
聪明的是,当给定一个要挂载的设备时,mount将使用libblkid来确定它的类型;如果它是图像,它将自动使用循环设备来安装它。
The loop device section of the mount
man page has more details.
mount手册页的循环设备部分包含更多详细信息。
#2
4
The loop
device is primarily controlled with the losteup
command. So losetup -a
gives you overview about the used loop devices and attached files. The mount
command can mount the block device only. The loop device can create the virtual block device from a file (character device).
循环设备主要由losteup命令控制。因此,losetup -a为您提供有关已使用的循环设备和附加文件的概述。 mount命令只能挂载块设备。循环设备可以从文件(字符设备)创建虚拟块设备。
In fact there is a great difference between those commands because on older Linux systems the mount
could not recognise the file as the correct device to be mounted, but during the time the mount command was completed with lot of feature, hence it can now self decide to try to call the losetup command and mount the result. But if you got a whole disk image not iso format but e.g. with MBR at the beginning, the mount command could not recognise it and you have to find the usable partition (e.g. with the parted disk_image.raw unit B print
command) yoursef and than mount it with full option mount comman as :
实际上这些命令之间存在很大差异,因为在较旧的Linux系统上,mount无法将文件识别为要安装的正确设备,但在mount命令完成时具有很多功能,因此它现在可以自行决定尝试调用losetup命令并挂载结果。但是如果你得到的整个磁盘映像不是iso格式,而是在开头的MBR中,mount命令无法识别它,你必须找到可用的分区(例如,使用parted disk_image.raw unit B print命令)yoursef,然后使用完整选项mount comman将其挂载为:
mount disk_image.raw /mntpoint/ -o loop,offset=${OFFSET_of_PARTITION}
In this syntax the loop device was not specified and it is assumed the system choose the first free (/dev/loop0
, /dev/loop1
etc) Among the other new features of mount command is that you need not specify the filesystem type of the mounted block device (in your case -t iso9660
) if the filesystem support was installed.
在这个语法中没有指定循环设备,并假设系统选择第一个空闲(/ dev / loop0,/ dev / loop1等)。在mount命令的其他新功能中,您不需要指定文件系统的类型。如果安装了文件系统支持,则安装块设备(在您的情况下为-t iso9660)。
Thanks to all developers!
感谢所有开发人员!
#3
2
There is no difference between mount ubuntu.iso /mnt
and mount -o loop ubuntu.iso /mnt
.
mount ubuntu.iso / mnt和mount -o loop ubuntu.iso / mnt之间没有区别。
The first is transparently handled as if you had used the second.
第一个是透明处理,就像你使用了第二个。