Table of Contents
GRML
GRML 2022.11 customize USB boot
It is possibile to automatically customize the GRML environment at boot, so it become possibile to:
- Load a localized keyboard mapping.
- Define some aliases.
- Install some additional packages from the net or from the USB stick.
- Keep some SSH RSA keys to access remote hosts.
- Keep some scripts to be run.
The process is composed of the following steps:
- Create the USB boot stick from the GRML ISO image.
- Create a new GRMLCFG partition into the USB stick.
- Customize the GRML environment at your will and create a config.tbz. Copy the file into the new partition.
- Create a scripts/ directory into the partition containing the scripts to be run at boot.
Create the USB stick from the ISO image
Download the ISO image from the GRML Download Page. As the root user copy the file into an empty USB stick (in the following example the kernel assigned the name /dev/sdc
to it):
dd bs=4M status=progress conv=fdatasync if=grml64-full_2022.11.iso of=/dev/sdc
Create a new partition into the USB stick
Boot your PC using the newly crate GRML USB stick. The image supports the UEFI boot.
I had to use the fdisk tool to create a new partition into the GRML USB stick, because the parted
program was unable to properly detect the partitions schema:
fdisk --wipe never /dev/sdc
The option --wipe never is required because the device contains an iso9660 signature that otherwise will be removed by the write command.
Using the n key to add a new partition it is possible to create the /dev/sdc3
partition, which I decided to size at 5 Gb. Select p (print the partition table) and w (write table to disk and exit) to finalize the partitioning, using the following schema as a reference:
Device Boot Start End Sectors Size Id Type /dev/sdc1 * 0 1751039 1751040 855M 0 Empty /dev/sdc2 596 8787 8192 4M ef EFI (FAT-12/16/32) /dev/sdc3 1751040 12236799 10485760 5G 83 Linux
Now format the new partition using an ext4 filesytem:
mkfs.ext4 -F -F -L GRMLCFG /dev/sdc3
The double option -F is required because the system thinks that the whole device is in use and cannot be formatted. The special label GRMLCFG is required because GRML at boot searches for a device with that label and load the configuration from it.
Customize the environment and save the config.tbz
Now it is time to customize your environment; check the grml-autoconfig man page about the options to automatically install Debs, Configuration and Scripts into a freshly booted GRML environment.
You can for example:
- Generate an SSH RSA key running the ssh-keygen utility. The key will be saved into
$HOME/.ssh/
. - Customize the shell by editing the $HOME/.zsrc file, e.g. by adding alias commands, customizing the PATH or other environment variables. etc.
- Run and configure some programs that will save preferences into the $HOME/, e.g. the Midnight Commander mc will save its files into
$HOME/.config/mc/
. - Create an
$HOME/config/
directory and place what you want in it. You will find that directory again at the next boot.
At the end of the customization, run the GRML command:
save-config -all
A file named config.tbz will be saved into the current directory. The file is a grml configuration archive, which may contains several components: hidden files from the $HOME
directory, modified files from the /etc/
directory, etc.
Mount the custom partition and copy the file into its root directory:
mkdir /mnt/grmlcfg mount /dev/sdc3 /mnt/grmlcfg cp -p config.tbz /mnt/grmlcfg
If you want to modify the config.tbz archive without re-creating it via the save-config
command, you can extract the archive and then re-create it:
mkdir config cd config tar jxvf ../config.tbz # Do whatever you need to the extracted files... mv ../config.tbz ../config.bak.tbz tar jcvf ../config.tbz *
Add scripts and other files to the USB
If you want to have some scripts run at bootstrap by GRML, create a script/ directory into the root of the custom USB partition, and place the scripts into it. During the execution of the script the partition will be mounted under /mnt/grmlcfg/.
You can place also files into the partition, so e.g. you can install additional deb packages on-the-fly.
Obsolete
WARNING: The following notes were taken in 2018 and may be out of date.
Boot via PXE
Vedere Boot via PXE.
Installazione da Live-CD
Personalizzazione
La partizione VFAT quando il sistema live è avviato, risulta accessibile sotto /lib/live/mount/medium/
.
La via più comoda di avere una GRML personalizzata è passare il parametro netconfig=server/archivio.tar.bz2
al boot prompt. L'archivio viene scompattato subito dopo l'avvio a partire dalla directory radice, ovviamente è necessario che la macchina abbia accesso alla rete.
In alternativa è possibile creare una partizione opportuna sulla chiavetta USB oppure sul disco fisso, impostare su di essa la label GRMLCFG
e metterci dentro l'archivio config.tbz
.
Altri parametri di boot utili:
lang=it
netconfig=10.0.1.253/grml/gca-$ARCH.tar.bz2
ssh=maidiremai
debs=*.deb
Per impostare dei parametri boot prompt permanenti sulla chiavetta USB è sufficiente seguire le istruzioni Permanently adjust boot parameters. In pratica è sufficiente creare una directory bootparams nella directory radice della chiavetta e creare un file con nome a piacere che contenga i boot parameters desiderati, su una sola riga separati da spazi.
grml2usb
Con il tool grml2usb
(omonimo pacchetto Debian) è possibile copiare una .ISO GRML su chiavetta USB. A differenza di unetbootin
in questo caso è possibile specificare una serie di parametri per personalizzare il boot. Ecco un esempio:
grml2usb --bootoptions="lang=it ssh=mysecret" /home/niccolo/Downloads/grml_2011.05.iso /dev/sdb1
La partizione VFAT (sdb1 nell'esempio) deve essere montata.
I parametri sono documentati in http://grml.org/cheatcodes/. Durante la creazione della chiavetta USB vengono scritti in numerosi file di configurazione nella directory /boot/
.
Pacchetti aggiuntivi
Gran parte dei pacchetti aggiuntivi possono essere installati direttamente dal repository Debian. Quello usato dalla versione 2013.02 ad esempio è:
http://snapshot.debian.org/archive/debian/20130226/testing/main
Per installare automaticamente un pacchetto al bootstrap, basta creare una directory debs/
nella radice della partizione VFAT e copiarci i file .deb. Quindi si aggiunge il parametro di boot (eventualmente anche sulla riga di comando di grlm2usb
, vedi sopra):
debs=*.deb