Custom Slax Bootable OS
From TheBeard Science Project Wiki
Revision as of 15:46, 30 September 2019 by Beard (talk | contribs) (Beard moved page Custom Slax Rescue OS to Custom Slax Bootable OS without leaving a redirect)
This page is unfinished.
Slax is an amazing Linux distro! This is the first time I've found a tolerable workflow for generating custom bootable Linux images, on the fly, for different purposes. Slax has all the features that I want as a base system for custom images, and it comes with scripts that make it easy to roll your changes into modules, which you can then incorporate into a new disk image. It's super fast and super easy.
Everything that I wanted:
- Debian based
- Minimal lightweight base OS
- Simple bootloader
- Fast and easy build process
Purpose of this example build:
- Lightweight utility OS for general IT work (including Windows systems)
Customizations I've made:
- Added Memtest86+ to the boot menu
- Made the OS boot to text mode by default
- Installed several recovery, diagnostic, and security packages
- Replaced the desktop wallpaper with a flat color
- Removed the startup/shutdown sound
Procedure
Customization Script
Custom script gen-slax-custom.sh:
# ================================================================
#
# GENERATE CUSTOM SLAX BOOTABLE ISO
#
# This was created with Slax 9.11.0 (64 bit)
# Source: http://ftp.sh.cvut.cz/slax/Slax-9.x/slax-64bit-9.11.0.iso
#
# Boot up the live Slax image in a virtual environment, create a
# virtual disk that is at least 3G attached to the VM, copy this
# script onto that VM, then run this script (needs network
# connection).
#
# The /mnt directory is used for temporary build files.
#
# The final image will be located in:
# /mnt/slax-custom64-build<DATE>.iso
#
# When you boot the custom image, you can hit Tab at the
# bootloader, and there is several boot options. There is now an
# Entry for Memtest86+.
#
# When you boot into the OS, you will get a text terminal. Login
# as Username: root, Password: toor
#
# If you want a graphical desktop, run the command "startx".
#
# ================================================================
#
#
# Set the time zone
# ================================================================
dpkg-reconfigure tzdata
#
# Enable SSH Server
# ================================================================
systemctl enable ssh
#
# Install packages
# ================================================================
apt-get update
apt-get -y install binutils chntpw cifs-utils clamav curl dnsutils etherwake ffmpeg gddrescue gparted iftop john macchanger memtest86+ nmap ntfs-3g parted rar recordmydesktop rsync smbclient ssh sshfs steghide stress sudo tcpdump telnet testdisk tmux traceroute unrar vim wireshark
#
# Replace the desktop wallpaper with flat color
# ================================================================
apt-get -y install imagemagick
convert -size 1x1 xc:gray /usr/share/wallpapers/slax_wallpaper.jpg
apt-get -y purge imagemagick
apt-get autoremove
apt-get autoclean
#
# Remove startup/shutdown sound files
# ================================================================
rm /usr/share/sounds/*.wav
#
# Partition the disk and create a file system
# ================================================================
echo -e "n\np\n1\n\n\n\nw\n" | fdisk /dev/sda
mkfs -t ext4 /dev/sda1
tune2fs -m 0 /dev/sda1
#
# Mount the disk
# ================================================================
umount /dev/sda1
mount /dev/sda1 /mnt
#
# Delete the shell history
# ================================================================
echo > ~/.bash_history
history -c
#
# Save the custom module
# ================================================================
savechanges /mnt/custom.sb
#
# Generate the temp ISO
# ================================================================
genslaxiso /mnt/slax-temp.iso /mnt/custom.sb
#
# Create the temp folders for working with the ISO file
# ================================================================
mkdir /mnt/isomount
mkdir /mnt/isotemp
#
# Mount the ISO file and copy into the temp folder
# ================================================================
mount -t iso9660 -o loop /mnt/slax-temp.iso /mnt/isomount
cp -R /mnt/isomount/* /mnt/isotemp/
umount /mnt/slax-temp.iso
rm /mnt/slax-temp.iso
#
# Move memtest86+ to the boot folder and rename it (required)
# ================================================================
mv /boot/memtest86+.bin /mnt/isotemp/slax/boot/memtest86
rm /boot/memtest86+_multiboot.bin
#
# Set the text mode as the default boot option
# ================================================================
sed -i 's/perch,automount/&\ text/g' /mnt/isotemp/slax/boot/syslinux.cfg
#
# Add Memtest86+ to the boot menu
# ================================================================
echo -e "\nLABEL memtest86\nMENU LABEL Memtest86+ (Test RAM)\nKERNEL /slax/boot/memtest86" >>/mnt/isotemp/slax/boot/syslinux.cfg
#
# Generate the final ISO file
# ================================================================
cd /mnt/isotemp/
dt=$(date +%y%m%d%H%M%S)
genisoimage -o /mnt/slax-custom64-build$dt.iso -b slax/boot/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V Slax .