$ sudo mount -o loop <iso-file>
Of course, the blog adds some code around it to create a new directory and such.
I decided to use the mount call and create a script, for my -and maybe your- convenience. First, I'll give the script, then I'll explain, in case you're interested.
#!/bin/bash
FILENAME=$1
if ! [ -f $FILENAME ]; then
echo "ISO file does not exist, exiting."
exit
fi
if [ $# != 1 ]; then
echo "No ISO file given, exiting."
exit
fi
if ! [ -d /mnt/iso/ ]; then
sudo mkdir -p /mnt/iso/
echo "/mnt/iso/ did not exist, created."
fi
if [[ $(mount | grep -c /mnt/iso/) -ge 1 ]]
then
sudo umount /mnt/iso/
echo "/mnt/iso/ was already mounted, unmounted."
fi
sudo mount -o loop $FILENAME /mnt/iso/
echo "$FILENAME is now mounted on /mnt/iso/"
A script always starts with #!, this script uses /bin/bash.
The location and name of the iso file the user is required to give is begin remembered in a variable, FILENAME.
The script starts with two tests. Is a file given and does the given file exist. If the tests (or one of the tests) fail, the program exits.
Then the mountpount is being checked. The script mounts the iso by default at /mnt/iso/. If the directory doesn't exist, it's created.
Next we have the block which checks if there's already a mount active on /mnt/iso/. If so, it is being unmounted.
Now we're finally ready to mount the iso file. A message is printed the mount was successful.
You can place the script in your homedir, for example. Don't forget to make it executable by (I called the file 'mountiso')
$ chmod 755 mountiso
I placed an iso on a usb stick, which mounted as /media/UDISK/ (the name of the usb stick was UDISK, don't ask me why), and mounted it with the command
$ ./mountiso /media/UDISK/iso/CM0102.iso
Geen opmerkingen:
Een reactie posten