7916
Comment: Initial version
|
12406
Fixed 404 link
|
Deletions are marked like this. | Additions are marked like this. |
Line 4: | Line 4: |
Mounting an ISO and extracting files from it. Command line techniques. | Mounting an ISO and extracting files from it. Command line techniques with a Debian ISO remaster example. |
Line 9: | Line 9: |
== Loopmount an ISO without administrative privileges == Users seeking to view the contents of an ISO file or copy a file from it are frequently advised to mount the ISO with {{{ mount -o loop example.iso /mnt |
----------------------------------------- == Copy an optical disk to a file == Copy a CD to a .iso file: {{{ dd if=/dev/cdrom of=image.iso }}} == Mount an ISO file == Mount the contents of a {{{.iso}}} file to a directory: {{{ mount -o loop -t iso9660 image.iso /the/directory }}} == Convert any disk image to ISO format == The [[DebPkg:iat]] package can be used to convert many disk image formats (BIN, MDF, PDI, CDI, NRG, and B5I) to ISO9660. == Loopmount an ISO Without Administrative Privileges == Users seeking to view the contents of an ISO file or copy a file from it are frequently advised to [[DebianMan:mount|mount]] the ISO with {{{ mount -o loop example.iso /mnt |
Line 19: | Line 45: |
{{{ * The command requires root privileges, which the user might not have. * Why invoke a root privilege (if available) when it is unnecessary? }}} |
* The command requires root privileges, which the user might not have. * Why invoke a root privilege (if available) when it is unnecessary? |
Line 30: | Line 54: |
Install [[https://packages.debian.org/jessie/udisks2|udisks2]]: {{{ apt-get install udisks2 }}} If a [[DesktopEnvironment|desktop environment]] has been installed from [[QuickInstall|the installer]] or after the installation udisks2 will already be on the system. The package contains the [[http://manpages.debian.org/cgi-bin/man.cgi?query=udisksctl|udisksctl]] program. The command {{{ udisksctl loop-setup -f example.iso |
Install [[DebPkg:udisks2|udisks2]]: {{{ apt install udisks2 }}} If a [[DesktopEnvironment|desktop environment]] has been installed from [[QuickInstall|the installer]] or after the installation, udisks2 will already be on the system. The package contains the [[DebianMan:udisksctl|udisksctl]] program. The command {{{ udisksctl loop-setup -r -f example.iso |
Line 50: | Line 74: |
ls -l /dev/loop* | ls -l /dev/loop* |
Line 56: | Line 80: |
brw-rw---- 1 root disk 7, 0 Nov 16 15:14 /dev/loop0 brw-rw---- 1 root disk 259, 2 Nov 16 15:14 /dev/loop0p1 brw-rw---- 1 root disk 259, 3 Nov 16 15:14 /dev/loop0p2 brw-rw---- 1 root disk 7, 1 Nov 16 15:19 /dev/loop1 brw-rw---- 1 root disk 7, 2 Nov 16 15:14 /dev/loop2 brw-rw---- 1 root disk 7, 3 Nov 16 15:14 /dev/loop3 brw-rw---- 1 root disk 7, 4 Nov 16 15:14 /dev/loop4 brw-rw---- 1 root disk 7, 5 Nov 16 15:14 /dev/loop5 brw-rw---- 1 root disk 7, 6 Nov 16 15:14 /dev/loop6 brw-rw---- 1 root disk 7, 7 Nov 16 15:14 /dev/loop7 crw-rw---- 1 root disk 10, 237 Nov 16 15:14 /dev/loop-control }}} The ISO can be mounted and unmounted with the commands {{{ udisksctl mount -b /dev/loop0p1 udisksctl unmount -b /dev/loop0p1 }}} The mount point is at /media/$USER. Unmounting still leaves example.iso associated with /dev/loop0. To |
brw-rw---- 1 root disk 7, 0 Nov 16 15:14 /dev/loop0 brw-rw---- 1 root disk 259, 2 Nov 16 15:14 /dev/loop0p1 brw-rw---- 1 root disk 259, 3 Nov 16 15:14 /dev/loop0p2 brw-rw---- 1 root disk 7, 1 Nov 16 15:19 /dev/loop1 brw-rw---- 1 root disk 7, 2 Nov 16 15:14 /dev/loop2 brw-rw---- 1 root disk 7, 3 Nov 16 15:14 /dev/loop3 brw-rw---- 1 root disk 7, 4 Nov 16 15:14 /dev/loop4 brw-rw---- 1 root disk 7, 5 Nov 16 15:14 /dev/loop5 brw-rw---- 1 root disk 7, 6 Nov 16 15:14 /dev/loop6 brw-rw---- 1 root disk 7, 7 Nov 16 15:14 /dev/loop7 crw-rw---- 1 root disk 10, 237 Nov 16 15:14 /dev/loop-control }}} The ISO's main partition can be mounted and unmounted with the commands {{{ udisksctl mount -b /dev/loop0p1 udisksctl unmount -b /dev/loop0p1 }}} The mount point is at ''/media/$USER''. Unmounting still leaves ''example.iso'' associated with ''/dev/loop0''. To |
Line 83: | Line 107: |
udisksctl loop-delete /dev/loop0 }}} udisks2 appeared in Debian 8 (Jessie). |
udisksctl loop-delete -b /dev/loop0 }}} udisks2 appeared in Debian 8 (jessie). |
Line 90: | Line 114: |
Intended as a udisks2 replacement but [[http://manpages.debian.org/cgi-bin/man.cgi?query=udevil|udevil]] can co-exist with it and will work to mount an ISO with or without its recommended packages. {{{ udevil mount example.iso |
Intended as a udisks2 replacement but [[DebianMan:udevil|udevil]] can co-exist with it and will work to mount an ISO with or without its recommended packages. {{{ udevil mount example.iso |
Line 99: | Line 123: |
udevil unmount example.iso }}} work out of the box. The mount point is in /media. udevil appeared in Debian 8 (Jessie) but has been [[Backports|backported]] to Debian 7 (Wheezy). |
udevil unmount example.iso }}} work out of the box. The mount point is in ''/media''. udevil appeared in Debian 8 (jessie) but has been [[Backports|backported]] to Debian 7 (wheezy). |
Line 109: | Line 133: |
Mounting an ISO with [[http://manpages.debian.org/cgi-bin/man.cgi?query=pmount|pmount]] requires (at present) the [[DebianExperimental|experimental version]]. Alter the ''loop_allow'' directive in /etc/pmount.conf to ''yes'' and uncomment ''loop_devices'' before mounting the ISO in /media with {{{ pmount example.iso |
Mounting an ISO with [[DebianMan:pmount|pmount]] requires (at present) the [[DebianExperimental|experimental version]]. Alter the ''loop_allow'' directive in ''/etc/pmount.conf'' to ''yes'' and uncomment ''loop_devices'' before mounting the ISO in ''/media'' with {{{ pmount example.iso |
Line 118: | Line 142: |
pumount example.iso | pumount example.iso |
Line 123: | Line 147: |
[[http://manpages.debian.org/cgi-bin/man.cgi?query=archivemount|archivemount]] is a [[https://www.kernel.org/doc/Documentation/filesystems/fuse.txt|FUSE]] based file system which supports reading from (but not writing to) ISO 9660 images. Create the directory iso in $HOME and mount with {{{ archivemount example.iso iso/ |
[[DebianMan:archivemount|archivemount]] is a [[https://www.kernel.org/doc/Documentation/filesystems/fuse.txt|FUSE]] based file system which supports reading from (but not writing to) ISO 9660 images. Create the directory ''isomount'' in $HOME and mount with {{{ archivemount example.iso isomount/ |
Line 132: | Line 156: |
fusermount -u iso/ | fusermount -u isomount/ |
Line 137: | Line 161: |
[[http://manpages.debian.org/cgi-bin/man.cgi?query=fuseiso9660|fuseiso9660]] is a module for the [[https://www.kernel.org/doc/Documentation/filesystems/fuse.txt|FUSE]] kernel service. Create the directory iso in the home directory ($HOME) and mount the iso with {{{ fuseiso9660 example.iso iso/ |
[[DebianMan:fuseiso9660|fuseiso9660]] is a module for the [[https://www.kernel.org/doc/Documentation/filesystems/fuse.txt|FUSE]] kernel service. Create the directory ''isomount'' in the home directory ($HOME) and mount the iso with {{{ fuseiso9660 example.iso isomount/ |
Line 148: | Line 172: |
fusermount -u iso/ }}} fuseiso9660 deals only with the basic ISO9660 format (see the manual) so filenames are limited to uppercase and eight characters. == Viewing the contents of an ISO == [[ManipulatingISOs#Loopmount an ISO without administrative privileges|Mounting]] the ISO and following up with {{{ ls -l <mount_point> }}} is one method of seeing what the structure of the ISO and what it contains. However, there is a number of programs which will allow examination of the contents of an ISO archive without having to mount it and without administration rights. A Jessie netinst ISO will be used as an example image in what follows. |
fusermount -u isomount/ }}} fuseiso9660 deals only with the basic ISO9660 format (see the manual) so filenames are limited to uppercase and 11 characters in an 8.3 format. <<Anchor(view)>> == Viewing the Contents of an ISO == [[#loopmount|Mounting]] the ISO and following up with {{{ ls -l <mount_point> }}} is one method of seeing what the structure of the ISO is and what it contains. However, there are a number of programs which will allow examination of the contents of an ISO archive without having to mount it and without administration rights. A Debian 9 (stretch) netinst ISO will be used as an example image in what follows. |
Line 167: | Line 192: |
[[http://manpages.debian.org/cgi-bin/man.cgi?query=bsdtar|bsdtar]] is a [[http://manpages.debian.org/cgi-bin/man.cgi?query=tar|tar]] implemenation which can view the contents of various archive files, including ISO 9660 images. It can also extract files from the image. For a basic view of the contents of an ISO image do {{{ bsdtar -tf debian-8.2.0-i386-netinst.iso |
[[DebianMan:bsdtar|bsdtar]] is a [[DebianMan:tar|tar]] implementation which can view the contents of various archive files, including ISO 9660 images. It can also extract files from the image. For a basic view of the contents of an ISO image do {{{ bsdtar -tf debian-9.3.0-i386-netinst.iso |
Line 176: | Line 201: |
bsdtar -tvf debian-8.2.0-i386-netinst.iso | bsdtar -tvf debian-9.3.0-i386-netinst.iso |
Line 182: | Line 207: |
bsdtar -tf debian-8.2.0-i386-netinst.iso pool/main/a | bsdtar -tf debian-9.3.0-i386-netinst.iso pool/main/a |
Line 187: | Line 212: |
[[http://manpages.debian.org/cgi-bin/man.cgi?query=xorriso|xorriso]] is a versatile program which manipulates ISO 9660 filesystem images. It can also extract files from the image. | [[DebianMan:xorriso|xorriso]] is a versatile program which manipulates ISO 9660 filesystem images. It can also extract files from the image. |
Line 192: | Line 217: |
xorriso -indev debian-8.2.0-i386-netinst.iso -ls xorriso -indev debian-8.2.0-i386-netinst.iso -lsl xorriso -indev debian-8.2.0-i386-netinst.iso -ls pool/main/b |
xorriso -indev debian-9.3.0-i386-netinst.iso -ls xorriso -indev debian-9.3.0-i386-netinst.iso -lsl xorriso -indev debian-9.3.0-i386-netinst.iso -ls pool/main/b |
Line 201: | Line 226: |
[[http://manpages.debian.org/cgi-bin/man.cgi?query=isoinfo|isoinfo]] is included in the [[https://packages.debian.org/jessie/genisoimage|genisoimage]] package and is able to list and extract files in an ISO 9660 image. The listing is of all files in the image. | [[DebianMan:isoinfo|isoinfo]] is included in the [[DebianPkg:genisoimage|genisoimage]] package and is able to list and extract files in an ISO 9660 image. The listing is of all files in the image. |
Line 206: | Line 231: |
isoinfo -J -l -i debian-8.2.0-i386-netinst.iso | isoinfo -J -l -i debian-9.3.0-i386-netinst.iso |
Line 212: | Line 237: |
isoinfo -J -f -i debian-8.2.0-i386-netinst.iso | isoinfo -J -f -i debian-9.3.0-i386-netinst.iso |
Line 217: | Line 242: |
The [[http://manpages.debian.org/cgi-bin/man.cgi?query=7z|7z]] utility comes in the [[https://packages.debian.org/jessie/p7zip-full|p7zip-full]] package. It packs and unpacks 7z archives and has ISO 9660 as a supported format for unpacking. {{{ 7z l debian-8.2.0-i386-netinst.iso |
The [[DebianMan:7z|7z]] utility comes in the [[DebianPkg:p7zip-full|p7zip-full]] package. It packs and unpacks 7z archives and has ISO 9660 as a supported format for unpacking. {{{ 7z l debian-9.3.0-i386-netinst.iso |
Line 226: | Line 250: |
== Extraction of files from an ISO == If debian-8.2.0-i386-netinst.iso [[ManipulatingISOs#Loopmount an ISO without administrative privileges|has been mounted]] and it is desired to have all the deb and udeb files copied to other media it should be sufficient to do {{{ cp -a /media/<mount_point>/pool/main DESTINATION }}} Without mounting, [[ManipulatingISOs#Viewing the contents of an ISO|all the programs mentioned above]] are capable of extracting the same files. The relevant commands are: {{{ bsdtar -C DESTINATION -xf debian-8.2.0-i386-netinst.iso pool/main xorriso -osirrox on -indev debian-8.2.0-i386-netinst.iso -extract pool/main DESTINATION isoinfo -J -x /pool/main/a/adduser/adduser_3.113+nmu3_all.deb -i debian-8.2.0-i386-netinst.iso > DESTINATION/adduser_3.113+nmu3_all.deb 7z x -oDESTINATION -i\!pool/main debian-8.2.0-i386-netinst.iso |
<<Anchor(extraction)>> == Extraction of Files from an ISO == If debian-9.3.0-i386-netinst.iso [[#loopmount|has been mounted]] and it is desired to have all the deb and udeb files copied to other media it should be sufficient to do {{{ cp -a /media/<mount_point>/pool/main DESTINATION }}} Without explicit mounting, [[#view|all the programs mentioned above]] are capable of extracting the same files. The relevant commands are: {{{ bsdtar -C DESTINATION -xf debian-9.3.0-i386-netinst.iso pool/main xorriso -osirrox on -indev debian-9.3.0-i386-netinst.iso -extract pool/main DESTINATION isoinfo -J -x /pool/main/a/adduser/adduser_3.113+nmu3_all.deb -i debian-9.3.0-i386-netinst.iso > DESTINATION/adduser_3.113+nmu3_all.deb 7z x -oDESTINATION -i\!pool/main debian-9.3.0-i386-netinst.iso |
Line 247: | Line 272: |
isoinfo only extracts single files and will display a file on stdin (possibly the screen) if it is not redirected somewhere. 7z doesn't like spaces between an option and its argument. Also, the bash shell sees ! as having a special meaning to it. This meaning can be removed by preceding ! with a backslash. }}} |
* isoinfo only extracts single files and will display a file on stdout (possibly the screen) if it is not redirected somewhere. * 7z doesn't like spaces between an option and its argument. Also, the bash shell sees ''!'' as having a special meaning to it. This meaning can be removed by preceding ''!'' with a backslash. }}} <<Anchor(remaster)>> == Remaster an Installation Image == [[https://www.debian.org/distrib/netinst|Netinst]] and [[https://www.debian.org/CD/http-ftp/|DVD-1]] images are popular choices when it comes to installing Debian. Much of the time it is sufficient simply to boot the image to have everything installed to a user's satisfaction. However, it is also possible to pass [[https://www.debian.org/releases/stable/amd64/ch05s03.en.html|boot parameters]] to the installer to achieve a particular end, either during the installation or on the installed system. Objectives could be to produce a [[Installation+Archive+USBStick|fully automatic installation]] or to configure part of the system using [[https://www.debian.org/releases/stable/amd64/apbs02.en.html|preseeding]]. Appending parameters to the kernel command line to setup, for example, a network connection, can be done relatively easily, but is a repetitive task when installing frequently. On the other hand, the installation image can be altered to contain the needed parameters before burning to CD or DVD or writing to a USB stick. Manipulating an ISO image in this way is known as ''remastering''. The basic idea will be illustrated using a Debian 9.3.0 i386 netinst image which is planned to be booted from the non-graphical `install` option with a preseed configuration file, ''preseed.cfg''. <<Anchor(extract)>> === Extracting All Files from an ISO === First make a place to put the extracted files: {{{ mktemp -d }}} The name of the directory is displayed. Something like this should be seen: {{{ /tmp/tmp.8t03ifDFAx }}} [[#extraction|Extract]] all files from the ISO with (for example) {{{ cat firmware-9.3.0-i386-netinst.iso | bsdtar -C "/tmp/tmp.8t03ifDFAx" -xf - }}} or {{{ xorriso -osirrox on -indev firmware-9.3.0-i386-netinst.iso -extract / /tmp/tmp.8t03ifDFAx }}} and make the files in ''/tmp/tmp.8t03ifDFAx'' writable: {{{ chmod -R +w /tmp/tmp.8t03ifDFAx }}} A preseed configuration file can now be put in ''/tmp/tmp.8t03ifDFAx'': {{{ cp preseed.cfg /tmp/tmp.8t03ifDFAx }}} <<Anchor(append)>> === Appending Boot Parameters to the ISO === Edit ''/tmp/tmp.8t03ifDFAx/isolinux/txt.cfg'' to add the required parameters to the end of the ''append'' line. What follows is a personal choice but {{{ priority=high locale=en_GB.UTF-8 keymap=gb file=/cdrom/preseed.cfg }}} shows the intent. The language and keymap questions will not be asked and the rest of the installation will proceed under the guidance of ''preseed.cfg''. ''preseed.cfg'' is found by the installer because the image is mounted on ''/cdrom''. <<Anchor(newiso)>> === Putting the ISO Back Together === For instructions how to re-use the full boot equipment of installation ISOs for "i386", "amd64", "arm64", and other architectures, see [[RepackBootableISO]]. The instructions in the following text suffice for "i386" and "amd64" in legacy BIOS mode. Install [[DebianMan:genisoimage|genisoimage]] and do {{{ genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat \ -no-emul-boot -boot-load-size 4 -boot-info-table \ -o preseed-firmware-9.3.0-i386-netinst.iso /tmp/tmp.8t03ifDFAx }}} (Leave out `\` when using the command. It is only here to indicate a line-break ). The original ISO was capable of being put on a USB stick at ''/dev/sdX'' (X depends on what [[DebianMan:lsblk|lsblk]] gives when the stick is plugged in) with {{{ cat firmware-9.3.0-i386-netinst.iso > /dev/sdX }}} and would have been bootable. The ISO can be restored to a bootable state with {{{ isohybrid preseed-firmware-9.3.0-i386-netinst.iso }}} [[DebianMan:isohybrid|isohybrid]] is found in the [[DebianPkg:syslinux-utils|syslinux-utils]] package. Alternatively, the `genisoimage` and `isohybrid` commands can be replaced by the single command: {{{ xorriso -as mkisofs -o preseed-firmware-9.3.0-i386-netinst.iso \ -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \ -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot \ -boot-load-size 4 -boot-info-table /tmp/tmp.8t03ifDFAx/ }}} after installing [[DebianPkg:isolinux|isolinux]]. Finally, remove ''/tmp/tmp.8t03ifDFAx'': {{{ rm -r /tmp/tmp.8t03ifDFAx }}} ------------------------- CategoryFileFormat | CategorySoftware |
Translation(s): none
Mounting an ISO and extracting files from it. Command line techniques with a Debian ISO remaster example.
Contents
Copy an optical disk to a file
Copy a CD to a .iso file:
dd if=/dev/cdrom of=image.iso
Mount an ISO file
Mount the contents of a .iso file to a directory:
mount -o loop -t iso9660 image.iso /the/directory
Convert any disk image to ISO format
The iat package can be used to convert many disk image formats (BIN, MDF, PDI, CDI, NRG, and B5I) to ISO9660.
Loopmount an ISO Without Administrative Privileges
Users seeking to view the contents of an ISO file or copy a file from it are frequently advised to mount the ISO with
mount -o loop example.iso /mnt
There are two aspects of this advice to consider:
- The command requires root privileges, which the user might not have.
- Why invoke a root privilege (if available) when it is unnecessary?
The following programs allow loopmounting without administrative privileges.
udisksctl
Install udisks2:
apt install udisks2
If a desktop environment has been installed from the installer or after the installation, udisks2 will already be on the system.
The package contains the udisksctl program. The command
udisksctl loop-setup -r -f example.iso
attaches the ISO to a loop device in /dev. Logging out and back in again might be necessary to have success with this command as a user.
Afterwards
ls -l /dev/loop*
might show
brw-rw---- 1 root disk 7, 0 Nov 16 15:14 /dev/loop0 brw-rw---- 1 root disk 259, 2 Nov 16 15:14 /dev/loop0p1 brw-rw---- 1 root disk 259, 3 Nov 16 15:14 /dev/loop0p2 brw-rw---- 1 root disk 7, 1 Nov 16 15:19 /dev/loop1 brw-rw---- 1 root disk 7, 2 Nov 16 15:14 /dev/loop2 brw-rw---- 1 root disk 7, 3 Nov 16 15:14 /dev/loop3 brw-rw---- 1 root disk 7, 4 Nov 16 15:14 /dev/loop4 brw-rw---- 1 root disk 7, 5 Nov 16 15:14 /dev/loop5 brw-rw---- 1 root disk 7, 6 Nov 16 15:14 /dev/loop6 brw-rw---- 1 root disk 7, 7 Nov 16 15:14 /dev/loop7 crw-rw---- 1 root disk 10, 237 Nov 16 15:14 /dev/loop-control
The ISO's main partition can be mounted and unmounted with the commands
udisksctl mount -b /dev/loop0p1 udisksctl unmount -b /dev/loop0p1
The mount point is at /media/$USER.
Unmounting still leaves example.iso associated with /dev/loop0. To unattach the device do
udisksctl loop-delete -b /dev/loop0
udisks2 appeared in Debian 8 (jessie).
udevil
Intended as a udisks2 replacement but udevil can co-exist with it and will work to mount an ISO with or without its recommended packages.
udevil mount example.iso
and
udevil unmount example.iso
work out of the box. The mount point is in /media.
udevil appeared in Debian 8 (jessie) but has been backported to Debian 7 (wheezy).
pmount
Mounting an ISO with pmount requires (at present) the experimental version. Alter the loop_allow directive in /etc/pmount.conf to yes and uncomment loop_devices before mounting the ISO in /media with
pmount example.iso
Unmount with
pumount example.iso
archivemount
archivemount is a FUSE based file system which supports reading from (but not writing to) ISO 9660 images. Create the directory isomount in $HOME and mount with
archivemount example.iso isomount/
Unmount with
fusermount -u isomount/
fuseiso9660
fuseiso9660 is a module for the FUSE kernel service.
Create the directory isomount in the home directory ($HOME) and mount the iso with
fuseiso9660 example.iso isomount/
Unmount with
fusermount -u isomount/
fuseiso9660 deals only with the basic ISO9660 format (see the manual) so filenames are limited to uppercase and 11 characters in an 8.3 format.
Viewing the Contents of an ISO
Mounting the ISO and following up with
ls -l <mount_point>
is one method of seeing what the structure of the ISO is and what it contains. However, there are a number of programs which will allow examination of the contents of an ISO archive without having to mount it and without administration rights.
A Debian 9 (stretch) netinst ISO will be used as an example image in what follows.
bsdtar
bsdtar is a tar implementation which can view the contents of various archive files, including ISO 9660 images. It can also extract files from the image. For a basic view of the contents of an ISO image do
bsdtar -tf debian-9.3.0-i386-netinst.iso
A detailed view would be obtained with
bsdtar -tvf debian-9.3.0-i386-netinst.iso
To look at a particular directory in the archive there is
bsdtar -tf debian-9.3.0-i386-netinst.iso pool/main/a
xorriso
xorriso is a versatile program which manipulates ISO 9660 filesystem images. It can also extract files from the image.
Commands which correspond to the ones for bsdtar are
xorriso -indev debian-9.3.0-i386-netinst.iso -ls xorriso -indev debian-9.3.0-i386-netinst.iso -lsl xorriso -indev debian-9.3.0-i386-netinst.iso -ls pool/main/b
isoinfo
isoinfo is included in the genisoimage package and is able to list and extract files in an ISO 9660 image. The listing is of all files in the image.
For basic listing:
isoinfo -J -l -i debian-9.3.0-i386-netinst.iso
For long listing:
isoinfo -J -f -i debian-9.3.0-i386-netinst.iso
7z
The 7z utility comes in the p7zip-full package. It packs and unpacks 7z archives and has ISO 9660 as a supported format for unpacking.
7z l debian-9.3.0-i386-netinst.iso
gives a file listing of the archive.
Extraction of Files from an ISO
If debian-9.3.0-i386-netinst.iso has been mounted and it is desired to have all the deb and udeb files copied to other media it should be sufficient to do
cp -a /media/<mount_point>/pool/main DESTINATION
Without explicit mounting, all the programs mentioned above are capable of extracting the same files. The relevant commands are:
bsdtar -C DESTINATION -xf debian-9.3.0-i386-netinst.iso pool/main xorriso -osirrox on -indev debian-9.3.0-i386-netinst.iso -extract pool/main DESTINATION isoinfo -J -x /pool/main/a/adduser/adduser_3.113+nmu3_all.deb -i debian-9.3.0-i386-netinst.iso > DESTINATION/adduser_3.113+nmu3_all.deb 7z x -oDESTINATION -i\!pool/main debian-9.3.0-i386-netinst.iso
- isoinfo only extracts single files and will display a file on stdout (possibly the screen) if it is not redirected somewhere.
7z doesn't like spaces between an option and its argument. Also, the bash shell sees ! as having a special meaning to it. This meaning can be removed by preceding ! with a backslash.
Remaster an Installation Image
Netinst and DVD-1 images are popular choices when it comes to installing Debian. Much of the time it is sufficient simply to boot the image to have everything installed to a user's satisfaction. However, it is also possible to pass boot parameters to the installer to achieve a particular end, either during the installation or on the installed system. Objectives could be to produce a fully automatic installation or to configure part of the system using preseeding.
Appending parameters to the kernel command line to setup, for example, a network connection, can be done relatively easily, but is a repetitive task when installing frequently. On the other hand, the installation image can be altered to contain the needed parameters before burning to CD or DVD or writing to a USB stick.
Manipulating an ISO image in this way is known as remastering. The basic idea will be illustrated using a Debian 9.3.0 i386 netinst image which is planned to be booted from the non-graphical install option with a preseed configuration file, preseed.cfg.
Extracting All Files from an ISO
First make a place to put the extracted files:
mktemp -d
The name of the directory is displayed. Something like this should be seen:
/tmp/tmp.8t03ifDFAx
Extract all files from the ISO with (for example)
cat firmware-9.3.0-i386-netinst.iso | bsdtar -C "/tmp/tmp.8t03ifDFAx" -xf -
or
xorriso -osirrox on -indev firmware-9.3.0-i386-netinst.iso -extract / /tmp/tmp.8t03ifDFAx
and make the files in /tmp/tmp.8t03ifDFAx writable:
chmod -R +w /tmp/tmp.8t03ifDFAx
A preseed configuration file can now be put in /tmp/tmp.8t03ifDFAx:
cp preseed.cfg /tmp/tmp.8t03ifDFAx
Appending Boot Parameters to the ISO
Edit /tmp/tmp.8t03ifDFAx/isolinux/txt.cfg to add the required parameters to the end of the append line. What follows is a personal choice but
priority=high locale=en_GB.UTF-8 keymap=gb file=/cdrom/preseed.cfg
shows the intent. The language and keymap questions will not be asked and the rest of the installation will proceed under the guidance of preseed.cfg. preseed.cfg is found by the installer because the image is mounted on /cdrom.
Putting the ISO Back Together
For instructions how to re-use the full boot equipment of installation ISOs for "i386", "amd64", "arm64", and other architectures, see RepackBootableISO. The instructions in the following text suffice for "i386" and "amd64" in legacy BIOS mode.
Install genisoimage and do
genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat \ -no-emul-boot -boot-load-size 4 -boot-info-table \ -o preseed-firmware-9.3.0-i386-netinst.iso /tmp/tmp.8t03ifDFAx
(Leave out \ when using the command. It is only here to indicate a line-break ).
The original ISO was capable of being put on a USB stick at /dev/sdX (X depends on what lsblk gives when the stick is plugged in) with
cat firmware-9.3.0-i386-netinst.iso > /dev/sdX
and would have been bootable. The ISO can be restored to a bootable state with
isohybrid preseed-firmware-9.3.0-i386-netinst.iso
isohybrid is found in the syslinux-utils package.
Alternatively, the genisoimage and isohybrid commands can be replaced by the single command:
xorriso -as mkisofs -o preseed-firmware-9.3.0-i386-netinst.iso \ -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \ -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot \ -boot-load-size 4 -boot-info-table /tmp/tmp.8t03ifDFAx/
after installing isolinux.
Finally, remove /tmp/tmp.8t03ifDFAx:
rm -r /tmp/tmp.8t03ifDFAx