Script for remastering Debian 9.1.0 under Knoppix
For the record, here is the script used to remaster Debian Live 9.1.0. Basically, it performs the aufs union mount, copies the whole thing to a directory with rsync, and then compresses the result. Squashfs-tools are needed. The whole operation takes only a few minutes on a contemporary i7 machine with SSD disk.
Code:
#!/bin/bash
#
[ -d sqfs ] || mkdir sqfs ;
[ -d persfs ] || mkdir persfs
[ -d aufs ] || mkdir aufs
[ -d copyfs ] || mkdir copyfs
#
# Running under Knoppix 7.7.1 w/Debian 9.1 image on same partition as Knoppix, persistent store at /dev/sda9
[ -d /media/sda9/deb91_1p ] || mount /media/sda9
fsck.ext3 -y /media/sda9/deb91_1p/persistence
mount -o ro,loop /mnt-system/deb910/live/filesystem.squashfs sqfs
mount -o loop /media/sda9/deb91_1p/persistence persfs
mount -t aufs -o "br=persfs/rw=rw:sqfs=ro,noplink" none aufs
#
#
# Clean up, in case
rm -rf copyfs/*
# Copy union file system
rsync -axu aufs/* copyfs
# Clean up mounts
umount aufs
umount sqfs
umount persfs
#
# Compress file system to new live file
mksquashfs copyfs filesystem_rem_1.squashfs
Afterwards, the new live file is copied to a new directory, a new persistence file is created in a new directory, and a new grub entry is created with the new locations. This way, it is possible to go back to an earlier version on the fly if somethings goes very wrong. At irregular intervals, depending on how much is changed, the new persistence file is backed up.
Procedure applied to Knoppix 8.1: It basically works
Have just repeated the procedure with Knoppix 8.1 under Debian 8.3 live. A bit more glitches than earlier, but it has worked.
Downloaded the ISO+md5sums and went to the directory. Kvm had no problems running the ISO, and after checking that things seemed to work, and that the flash was recognized as /dev/sdb, I used flash-knoppix to create a bootable flash install.
Used the old setup with persistence file, no encryption.
Code:
user@debian:/store/download/iso$ md5sum -c KNOPPIX_V8.1-2017-09-05-EN.iso.md5
KNOPPIX_V8.1-2017-09-05-EN.iso: OK
user@debian:/store/download/iso$ sudo kvm -cdrom KNOPPIX_V8.1-2017-09-05-EN.iso -hdb /dev/sdb -m 1024 -boot d &
I had some problems with the choices in the flash-knoppix setup. We must choose fixed disk, for that's what the flash drive looks like from kvm Knoppix. But I had to double click to choose that.
Also, it complained that it couldn't get the geometry for the persistent image right. The file was created, but file system creation somehow went wrong.
So, I had to do a mkfs.ext2 on the knoppix-data.img file afterwards. From there, things seem to work fine.
But, to get the stick to boot properly and consistently on a Windows PC, I had to use a USB2 port - the recognition in the USB3 ports seemed a bit random. Maybe it has to do with the drive, a 32 GB HyperX Fury.
There is an interesting new option for remastering in flash-knoppix. Will try it out from a Poor Man's Install. Will also try this whole procedure under Knoppix, and under Debian 9.1.
Workaround for problem with wrong resolution detection in 8.1
Posting this from 8.1 Poor Man's Install. For the first time, I have had to manually set screen resolution - wrong detection left me with an unusable Knoppix.
But, as so often, the knoppix-cheatcodes.txt file helped me out. What I needed, was a specification screen=1920x1200. One might think the norandr alternative would do, but it didn't.
Here are the Knoppix 8.1.0 boot stanzas from legacy grub's menu.lst file. I have added a 1280x1024 frame buffer alternative to have a fallback.
Code:
title Knoppix 8.1.0 64 bits sda1 cloop no persistence fixed screen
kernel (hd0,5)/boot/knx810/linux64 screen=1920x1200 fromhd=/dev/sda1 noimage knoppix_dir=KNOPPIX810_0 nosound keyboard=no ramdisk_size=100000 lang=no apm=power-off initrd=minirt.gz nomce hpsa.hpsa_allow_any=1 loglevel=1 tz=localtime
initrd (hd0,5)/boot/knx810/minirt.gz
title Knoppix 8.1.0 64 bits sda1 cloop fixed screen
kernel (hd0,5)/boot/knx810/linux64 screen=1920x1200 fromhd=/dev/sda1 knoppix_dir=KNOPPIX810_0 nosound keyboard=no ramdisk_size=100000 lang=no apm=power-off initrd=minirt.gz nomce hpsa.hpsa_allow_any=1 loglevel=1 tz=localtime
initrd (hd0,5)/boot/knx810/minirt.gz
title Knoppix 8.1.0 64 bits sda1 cloop fbdev
kernel (hd0,5)/boot/knx810/linux64 fromhd=/dev/sda1 knoppix_dir=KNOPPIX810_0 vga=794 video=1280x1024 xmodule=fbdev nosound keyboard=no ramdisk_size=100000 lang=no apm=power-off initrd=minirt.gz nomce hpsa.hpsa_allow_any=1 loglevel=1 tz=localtime
initrd (hd0,5)/boot/knx810/minirt.gz
By specifying knoppix_dir, and eventually fromhd, I can multi-boot as many Knoppixes I want. I place the kernel and initrd files in separate directories under boot on the partition where grub is installed.
One important reason for having noimage ie. no persistence, boot alternatives, is that I can then backup or copy the persistence file "from within".
Right now, I have 5 live OS alternatives for booting on this old PC: Knoppix 7.05, 7.4.2, 6.7.1 and 8.1.0, and Debian 8.3.0. The old stuff is for running program versions or hardware drivers that can no longer be installed under newer OS versions.