Differences between revisions 20 and 22 (spanning 2 versions)
Revision 20 as of 2020-04-14 11:10:07
Size: 5676
Editor: ?FelixStupp
Comment: While regenerating the md5sum, the md5sum.txt file needs to be excluded, otherwise the checksum for this file is invalid because it is written using this command
Revision 22 as of 2021-08-08 21:02:17
Size: 5991
Comment:
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:
The `file` method to get a [[ManipulatingISOs#remaster|remastered image]] to use a preseed file within an image puts ''preseed.cfg'' on the image's file system. Putting ''preseed.cfg'' into the `initrd` is the method described on this page. The installer will look for a file of this name when it boots. The `file` method to get a [[ManipulatingISOs#remaster|remastered image]] to use a preseed file within an image puts ''preseed.cfg'' on the image's file system. Putting ''preseed.cfg'' into the `initrd` is the method described on this page. The installer will look for a file of this name when it boots. Note: This page describes remastering the initrd file named initrd.gz. This means, you need to boot the text-based installer, to have the installer detect the preseed.cfg file (thus: use the 'Install' or 'Expert install' option from the GRUB menu)! When you use the graphical installer options ('Graphical install' or 'Graphical expert install'), the preseed.cfg will not be found!
Line 37: Line 37:
 * Command line utilities for mounting an ISO image include [[DebianMan:udevil|udevil]]:  * Command line utilities for mounting an ISO image include DebianMan:udevil:
Line 62: Line 62:
Line 65: Line 66:
md5sum `find -follow -type f \! -name md5sum.txt` > md5sum.txt find -follow -type f ! -name md5sum.txt -print0 | xargs -0 md5sum > md5sum.txt
Line 70: Line 71:
A warning will be issued because ''./debian'' is a [[DebianMan:ln|symlink]] to ''.'' : A warning will be issued because ''./debian'' is a [[SymLink|symlink]] to ''.'' :
Line 82: Line 83:
Install [[DebianMan:genisoimage|genisoimage]] and do Install DebianMan:genisoimage and do
Line 92: Line 93:
A quick test of the ISO using the [[DebianPkg:qemu|qemu]] command A quick test of the ISO using the DebianPkg:qemu command
Line 95: Line 96:
qemu -net user -cdrom test.iso qemu-system-i386 -net user -cdrom test.iso
Line 100: Line 101:
As root, the original ISO was capable of being written to a USB stick at ''/dev/sdX'' (X depends on what [[DebianMan:lsblk|lsblk]] gives when the stick is plugged in) with As root, the original ISO was capable of being written to a USB stick at ''/dev/sdX'' (X depends on what DebianMan:lsblk gives when the stick is plugged in) with
Line 112: Line 113:
[[DebianMan:isohybrid|isohybrid]] is found in the [[DebianPkg:syslinux-utils|syslinux-utils]] package. DebianMan:isohybrid is found in the DebianPkg:syslinux-utils package.
Line 123: Line 124:
after installing [[DebianPkg:isolinux|isolinux]]. after installing DebianPkg:isolinux.

It is intended that all the commands necessary to remaster an ISO image can be run by a regular user. Root privilege is only required when it comes to writing the modified image to a bootable device.

Modifying an installation ISO image to preseed the installer from its initrd.

Introduction

If you want to incorporate preseeding directly into the Debian Installer (as opposed to using boot parameters) it is necessary to modify (remaster) the ISO image to use one of the methods advised by the Installation Guide. As the Guide says:

There are three methods that can be used for preseeding: initrd, file and network.

The file method to get a remastered image to use a preseed file within an image puts preseed.cfg on the image's file system. Putting preseed.cfg into the initrd is the method described on this page. The installer will look for a file of this name when it boots. Note: This page describes remastering the initrd file named initrd.gz. This means, you need to boot the text-based installer, to have the installer detect the preseed.cfg file (thus: use the 'Install' or 'Expert install' option from the GRUB menu)! When you use the graphical installer options ('Graphical install' or 'Graphical expert install'), the preseed.cfg will not be found!

Extracting the Initrd from an ISO Image

One of the already built ISO images is required; either a Netinst image or DVD-1 would be suitable. A buster i386 netinst image is used as an example in what follows. Because an ISO 9660 image is a read-only image, the initrd will have to be extracted from it (together with all the other files), modified and a new image built with the new initrd.

There are at least three commands that a user can employ to extract all files from an ISO Image:

bsdtar -C DESTINATION -xf debian-10.2.0-i386-netinst.iso
xorriso -osirrox on -indev debian-10.2.0-i386-netinst.iso -extract / DESTINATION
7z x -oDESTINATION debian-10.2.0-i386-netinst.iso

Another user technique (which is the one used on this page) would be to mount the ISO image and copy all the files from it to a chosen directory, isofiles.

  • A desktop environment likely has a file manager which will do the mounting and copying for you.

  • A terminal application which will display the files in the image and allow copying to isofiles is Midnight Commander.

  • Command line utilities for mounting an ISO image include udevil:

udevil mount debian-10.2.0-i386-netinst.iso

Copy the files to isofiles with, for example,

cp -rT /media/debian-10.2.0-i386-netinst.iso/ isofiles/

Adding a Preseed File to the Initrd

You now have the directory isofiles with all the ISO's files in it. Make initrd.gz writable by the user, uncompress it and append a preseed file to the initrd. Recompress the initrd and return initrd.gz to its original read-only state:

chmod +w -R isofiles/install.386/
gunzip isofiles/install.386/initrd.gz
echo preseed.cfg | cpio -H newc -o -A -F isofiles/install.386/initrd
gzip isofiles/install.386/initrd
chmod -w -R isofiles/install.386/

Regenerating md5sum.txt

cd isofiles
chmod +w md5sum.txt
find -follow -type f ! -name md5sum.txt -print0 | xargs -0 md5sum > md5sum.txt
chmod -w md5sum.txt
cd ..

A warning will be issued because ./debian is a symlink to . :

find: File system loop detected; ‘./debian’ is part of the same file system loop as ‘.’ :

The production of md5sum.txt is unaffected.

Creating a New Bootable ISO Image

The following instructions suffice for i386 and amd64 in legacy BIOS mode. Information on how to create bootable ISOs for EFI or for architectures like arm64 is given at RepackBootableISO.

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-debian-10.2.0-i386-netinst.iso isofiles

(Omit \ when using the command. It is only there for presentational purposes to indicate a line-break).

A quick test of the ISO using the qemu command

qemu-system-i386 -net user -cdrom test.iso

could be done before burning it to a CD or DVD or writing it to a USB device.

As root, the original ISO was capable of being written to a USB stick at /dev/sdX (X depends on what lsblk gives when the stick is plugged in) with

cp debian-10.2.0-i386-netinst.iso /dev/sdX

and would have been bootable. The new ISO can be restored to a bootable state for using on a USB device with

isohybrid preseed-debian-10.2.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-debian-10.2.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 isofiles

after installing isolinux.

Finally, remove isofiles and unmount the original ISO:

chmod +w -R isofiles
rm -r isofiles
udevil unmount /media/debian-10.2.0-i386-netinst.iso