sudo mkdir -p /media/cdrom
cd ~
sudo mount -o loop ubuntu-* /
mount: ubuntu-*: failed to setup loop device: No such file or directory
- 20,946
- 6
- 61
- 73
- 161
4 Answers
First make sure you have mounted loop device kernel module. So run:
lsmod | grep loop
If you get no output, that means you have to mount the loop device kernel module . So:
modprobe loop
Re-run the following to make sure the module is loaded. You should get some outputs:
lsmod | grep loop
Now, to mount an ISO file as loop device do the following:
mount -o loop -t iso9660 <path/to/iso/file> /media/cdrom
However I guess it should also work without the -t iso9660 part.
- 17,552
- 20,946
- 6
- 61
- 73
-
33
modprobe loopproduces no output, is that the expected behavior? Even after that, there is no output forlsmod | grep loop. – Mads Skjern Mar 02 '17 at 23:31 -
2Check that you have the
/dev/loop0device and that you have permissions to use it. Use--privilegedif you try this in Docker. – Qsiris Oct 17 '19 at 14:07 -
4I have the
/dev/loop0and I am running this aftersudo -ibut still no output after doingmodprobe loop. – bomben Dec 11 '21 at 14:10
I'm aware that the this is not a direct answer to the OP's question. however I decided to drop an answer because this post was a high ranked result when I googled about my own situation.
In my case running as a non-root user caused the following error:
failed to setup loop device for /home/user/ubuntu-22.04.3-live-server-amd64.iso
Don't forget to run mount command with root privileges.
You can run it with sudo for example.
- 143
-
This does not answer the question. In the question, they clearly have the
sudopart correct – Daniel T Feb 12 '24 at 15:05 -
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. – Daniel T Feb 12 '24 at 15:05
-
2thank you @DanielT for your advice. I googled my error message (the one that is included in my answer) and this question was a high rank result. I noticed that the OP has already used sudo to run with high privileges but I decided to put an answer to help those who might be redirected here (just like me) – mahyard Feb 13 '24 at 07:42
-
2Doh! This was my exact issue - permissions. I should have checked permissions first but I'm so used to doing everything as root that I didn't even realize my terminal wasn't root. The generic error message is not helpful to determine it's just a permissions issue either. – reukiodo Nov 14 '24 at 22:37
I suspect you're blindly following some instructions on how to mount an Ubuntu ISO image using the loop device.
sudo mkdir -p /media/cdrom
This creates a directory cdrom owned by root in /media if not existing, and it's meant to be used as the to be mounted filesystem's mount point;
cd ~
This changes the current working directory of your terminal instance to ~, which is a shorthand which expands to your home directory's path;
sudo mount -o loop ubuntu-* /
This attempts to mount all the files matching ubuntu-* (all the files having a filename starting with ubuntu-) in your home directory using the loop device and / as the mount point. Just don't do that. It's not useful at all to match against a wildcard if you're trying to mount a single ISO image, leaving aside that fact that you want your / mount point to keep holding the root partition. Mount the ISO image specifying its exact filename and mount it on the mount point you just created (/media/cdrom). In order to do that, make sure that the ISO image you want to mount is present in your home directory and change ubuntu-* with the full name of the ISO image. For example, to mount the official image of Ubuntu Desktop 14.04.2 64-bit the command would be:
sudo mount -o loop ubuntu-14.04.2-desktop-amd64.iso /media/cdrom
- 41,378
This mounted my file for me
sudo mount -o loop ubuntu-14.04.2-desktop-amd64.iso /media/cdrom
Thanks kos
- 1
root) a directory, then changed directory to the HOME directory of the logged-in user, then tried to mount the wildcardubuntu-*over the root directory. The wildcardubuntu-*did not match anything in the current directory, andmounttold you. What were you trying to do? – waltinator Jun 10 '15 at 05:56