12
sudo mkdir -p /media/cdrom
cd ~
sudo mount -o loop ubuntu-* /
mount: ubuntu-*: failed to setup loop device: No such file or directory
Ron
  • 20,518
  • 6
  • 57
  • 72
user418576
  • 121
  • 1
  • 1
  • 3
  • What did you expect? You created (as `root`) a directory, then changed directory to the HOME directory of the logged-in user, then tried to mount the wildcard `ubuntu-*` over the root directory. The wildcard `ubuntu-*` did not match anything in the current directory, and `mount` told you. What were you trying to do? – waltinator Jun 10 '15 at 05:56

3 Answers3

14

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.

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Ron
  • 20,518
  • 6
  • 57
  • 72
  • 26
    `modprobe loop` produces no output, is that the expected behavior? Even after that, there is no output for `lsmod | grep loop`. – Mads Skjern Mar 02 '17 at 23:31
  • 1
    Check that you have the `/dev/loop0` device and that you have permissions to use it. Use `--privileged` if you try this in Docker. – Qsiris Oct 17 '19 at 14:07
  • 2
    I have the `/dev/loop0` and I am running this after `sudo -i` but still no output after doing `modprobe loop`. – bomben Dec 11 '21 at 14:10
4

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
kos
  • 35,535
  • 13
  • 101
  • 151
0

This mounted my file for me

sudo mount -o loop ubuntu-14.04.2-desktop-amd64.iso /media/cdrom

Thanks kos