Difference between revisions of "Browse and Netboot ISO images"
(One intermediate revision by the same user not shown) | |||
Line 9: | Line 9: | ||
First, we're going to use the automounter together with /dev/loop to mount the ISO files on demand. Before we can go any further, ensure that you have the automounter installed: | First, we're going to use the automounter together with /dev/loop to mount the ISO files on demand. Before we can go any further, ensure that you have the automounter installed: | ||
− | + | yum -y install autofs | |
− | |||
− | |||
Next, create a suitable mount point. In this example, we're using /media/iso-fs | Next, create a suitable mount point. In this example, we're using /media/iso-fs | ||
− | + | ||
− | + | mkdir -p /media/iso-fs | |
− | |||
Now create a file called /media/.iso-fs.map using your favourite editor with the following contents: | Now create a file called /media/.iso-fs.map using your favourite editor with the following contents: | ||
− | + | <pre> | |
− | + | #!/bin/bash | |
DIR_LIST=(/var/hda/files/torrents /home/*/Downloads) | DIR_LIST=(/var/hda/files/torrents /home/*/Downloads) | ||
iso=`find ${DIR_LIST[@]} -name $1.iso -type f` | iso=`find ${DIR_LIST[@]} -name $1.iso -type f` | ||
echo "-fstype=iso9660 :$iso" | echo "-fstype=iso9660 :$iso" | ||
− | + | </pre> | |
+ | |||
This script will act as an executable mount map for the automounter, returning suitable mount point parameters if it finds an ISO file that matches the key passed to it. | This script will act as an executable mount map for the automounter, returning suitable mount point parameters if it finds an ISO file that matches the key passed to it. | ||
...and ensure that this file is executable: | ...and ensure that this file is executable: | ||
− | + | ||
− | + | chmod u+x /media/.iso-fs.map | |
− | |||
The final step is to create an entry in the master automount map. Edit /etc/auto.master and add the following line somewhere after the default /net entry: | The final step is to create an entry in the master automount map. Edit /etc/auto.master and add the following line somewhere after the default /net entry: | ||
− | + | /media/iso-fs /media/.iso-fs.map ro,loop --timeout=5 | |
− | |||
− | |||
The last parameter is the time in seconds after which a mount point will be automatically unmounted. Now restart the automounter with: | The last parameter is the time in seconds after which a mount point will be automatically unmounted. Now restart the automounter with: | ||
− | + | service autofs restart | |
− | |||
− | |||
If all has gone well, then you should be able to browse any ISO image that you have in your torrents or downloads directories. In my case, I have ubuntu-10.10-desktop-i386.iso in my torrents directory, so I get: | If all has gone well, then you should be able to browse any ISO image that you have in your torrents or downloads directories. In my case, I have ubuntu-10.10-desktop-i386.iso in my torrents directory, so I get: | ||
− | + | ||
− | + | bash$ ls /media/iso-fs/ubuntu-10.10-desktop-i386/ | |
− | autorun.inf dists md5sum.txt preseed usb-creator.exe | + | autorun.inf dists md5sum.txt preseed usb-creator.exe |
− | boot install pics README.diskdefines wubi.exe | + | boot install pics README.diskdefines wubi.exe |
− | casper isolinux pool ubuntu | + | casper isolinux pool ubuntu |
− | + | ||
You can browse around the directories, copy files etc at leisure, and when you're done the automounter will release the loop device for reuse. | You can browse around the directories, copy files etc at leisure, and when you're done the automounter will release the loop device for reuse. | ||
Line 56: | Line 49: | ||
== Part 2 - Making ISO images bootable == | == Part 2 - Making ISO images bootable == | ||
First, we need to create some directories to hold the PXE menu structure and the script to generate it: | First, we need to create some directories to hold the PXE menu structure and the script to generate it: | ||
− | + | ||
− | + | cd /usr/share/amahi-netboot/tftp | |
− | mkdir iso-boot | + | mkdir iso-boot |
− | mkdir iso-boot/conf | + | mkdir iso-boot/conf |
− | mkdir iso-boot/mnt | + | mkdir iso-boot/mnt |
− | |||
Next you will need to download [[File:menu-gen.sh]] to generate the PXE boot menus. Save this script as iso-boot/menu-gen.sh and make it executable: | Next you will need to download [[File:menu-gen.sh]] to generate the PXE boot menus. Save this script as iso-boot/menu-gen.sh and make it executable: | ||
− | + | chmod u+x iso-boot/menu-gen.sh | |
− | |||
− | |||
menu-gen.sh contains a number of configuration variables at the top; you will need to edit HDA_IP to match the IP address of your HDA at the very least. The TIMEOUT variable also needs to match the automount timeout set in part one so that your machine doesn't run out of loop devices. | menu-gen.sh contains a number of configuration variables at the top; you will need to edit HDA_IP to match the IP address of your HDA at the very least. The TIMEOUT variable also needs to match the automount timeout set in part one so that your machine doesn't run out of loop devices. | ||
Now run the script to generate the menus based on the ISOs on your system and the distributions the script knows about: | Now run the script to generate the menus based on the ISOs on your system and the distributions the script knows about: | ||
− | + | ||
− | + | iso-boot/menu-gen.sh | |
− | + | ||
Note that the script will appear to run slowly as it waits for each ISO to time out before moving on to the next one. | Note that the script will appear to run slowly as it waits for each ISO to time out before moving on to the next one. | ||
The last stage in setting up the menus, we need to add an entry in pxelinux.cfg/default to link to the generated menus. Open pxelinux.cfg/default in your favourite editor and add: | The last stage in setting up the menus, we need to add an entry in pxelinux.cfg/default to link to the generated menus. Open pxelinux.cfg/default in your favourite editor and add: | ||
− | + | <pre> | |
LABEL linux-boot | LABEL linux-boot | ||
MENU LABEL Boot from ISO images | MENU LABEL Boot from ISO images | ||
kernel menu.c32 | kernel menu.c32 | ||
append iso-boot/conf/boot.conf | append iso-boot/conf/boot.conf | ||
− | + | </pre> | |
With the menus created, we just have two final steps to take. First, the kernel and initrd need to be available under the tftp directory structure. Fortunately, the automounter can take care of this for us; simply add the following additional to /etc/auto.master: | With the menus created, we just have two final steps to take. First, the kernel and initrd need to be available under the tftp directory structure. Fortunately, the automounter can take care of this for us; simply add the following additional to /etc/auto.master: | ||
− | |||
Text=/usr/share/amahi-netboot/tftp/iso-boot/mnt /media/.iso-fs.map ro,loop --timeout=5 | Text=/usr/share/amahi-netboot/tftp/iso-boot/mnt /media/.iso-fs.map ro,loop --timeout=5 | ||
− | + | ||
...and then restart the automounter: | ...and then restart the automounter: | ||
− | + | ||
− | + | service autofs restart | |
− | |||
Secondly, we need to enable NFS and export the relevant directories. Assuming you have NFS installed and running, edit /etc/exports to add: | Secondly, we need to enable NFS and export the relevant directories. Assuming you have NFS installed and running, edit /etc/exports to add: | ||
− | + | ||
− | + | /media 192.168.147.0/24(ro,crossmnt) | |
− | + | ||
And then issue service nfs restart to load the new export table. | And then issue service nfs restart to load the new export table. | ||
Latest revision as of 03:53, 23 June 2020
Contents
Overview
If you use Amahi to regularly download ISO images of operating systems and such like, this page is for you. It describes some tweaks that can be made to an Amahi setup to enable easy browsing and netbooting of ISO images, *without* having to mount each one and copy files. This is particularly handy, if you just want to try out the latest and greatest version of something.
Almost every command in this article needs to be executed with root privileges. Therefore, use "su" to become root before you begin, or prefix each command with sudo if you prefer.
Part 1 - Making ISO images browsable
First, we're going to use the automounter together with /dev/loop to mount the ISO files on demand. Before we can go any further, ensure that you have the automounter installed:
yum -y install autofs
Next, create a suitable mount point. In this example, we're using /media/iso-fs
mkdir -p /media/iso-fs
Now create a file called /media/.iso-fs.map using your favourite editor with the following contents:
#!/bin/bash DIR_LIST=(/var/hda/files/torrents /home/*/Downloads) iso=`find ${DIR_LIST[@]} -name $1.iso -type f` echo "-fstype=iso9660 :$iso"
This script will act as an executable mount map for the automounter, returning suitable mount point parameters if it finds an ISO file that matches the key passed to it.
...and ensure that this file is executable:
chmod u+x /media/.iso-fs.map
The final step is to create an entry in the master automount map. Edit /etc/auto.master and add the following line somewhere after the default /net entry:
/media/iso-fs /media/.iso-fs.map ro,loop --timeout=5
The last parameter is the time in seconds after which a mount point will be automatically unmounted. Now restart the automounter with:
service autofs restart
If all has gone well, then you should be able to browse any ISO image that you have in your torrents or downloads directories. In my case, I have ubuntu-10.10-desktop-i386.iso in my torrents directory, so I get:
bash$ ls /media/iso-fs/ubuntu-10.10-desktop-i386/ autorun.inf dists md5sum.txt preseed usb-creator.exe boot install pics README.diskdefines wubi.exe casper isolinux pool ubuntu
You can browse around the directories, copy files etc at leisure, and when you're done the automounter will release the loop device for reuse.
Part 2 - Making ISO images bootable
First, we need to create some directories to hold the PXE menu structure and the script to generate it:
cd /usr/share/amahi-netboot/tftp mkdir iso-boot mkdir iso-boot/conf mkdir iso-boot/mnt
Next you will need to download File:Menu-gen.sh to generate the PXE boot menus. Save this script as iso-boot/menu-gen.sh and make it executable:
chmod u+x iso-boot/menu-gen.sh
menu-gen.sh contains a number of configuration variables at the top; you will need to edit HDA_IP to match the IP address of your HDA at the very least. The TIMEOUT variable also needs to match the automount timeout set in part one so that your machine doesn't run out of loop devices.
Now run the script to generate the menus based on the ISOs on your system and the distributions the script knows about:
iso-boot/menu-gen.sh
Note that the script will appear to run slowly as it waits for each ISO to time out before moving on to the next one.
The last stage in setting up the menus, we need to add an entry in pxelinux.cfg/default to link to the generated menus. Open pxelinux.cfg/default in your favourite editor and add:
LABEL linux-boot MENU LABEL Boot from ISO images kernel menu.c32 append iso-boot/conf/boot.conf
With the menus created, we just have two final steps to take. First, the kernel and initrd need to be available under the tftp directory structure. Fortunately, the automounter can take care of this for us; simply add the following additional to /etc/auto.master:
Text=/usr/share/amahi-netboot/tftp/iso-boot/mnt /media/.iso-fs.map ro,loop --timeout=5
...and then restart the automounter:
service autofs restart
Secondly, we need to enable NFS and export the relevant directories. Assuming you have NFS installed and running, edit /etc/exports to add:
/media 192.168.147.0/24(ro,crossmnt)
And then issue service nfs restart to load the new export table.
Known Issues
- The menu-gen.sh script doesn't currently work for some images, notably those based on the dracut system
- menu-gen.sh is a first attempt; it currently needs to be taught about new distributions and where to find the kernel and initrd image on each type of ISO. Suggestions and improvements to make it smarter greatly appreciated.
- Occasionally, if you don't shutdown the PXE booted system cleanly, the automounter is unable to release the mount point