Difference between revisions of "Custom Slax Bootable OS"
(→Procedure) |
(→Procedure) |
||
| Line 70: | Line 70: | ||
systemctl start ssh | systemctl start ssh | ||
</source> | </source> | ||
| + | |||
| + | Now find out your IP address (assuming the guest OS was able to obtain an address from DHCP): | ||
| + | <source> | ||
| + | ifconfig | ||
| + | </source> | ||
| + | |||
| + | <pre class="result"> | ||
| + | enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 | ||
| + | inet 172.16.1.109 netmask 255.255.0.0 broadcast 172.16.255.255 | ||
| + | inet6 fe80::a00:27ff:fe2c:39ac prefixlen 64 scopeid 0x20<link> | ||
| + | ether 08:00:27:2c:39:ac txqueuelen 1000 (Ethernet) | ||
| + | RX packets 421 bytes 39318 (38.3 KiB) | ||
| + | RX errors 0 dropped 0 overruns 0 frame 0 | ||
| + | TX packets 15 bytes 1714 (1.6 KiB) | ||
| + | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | ||
| + | |||
| + | lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 | ||
| + | inet 127.0.0.1 netmask 255.0.0.0 | ||
| + | inet6 ::1 prefixlen 128 scopeid 0x10<host> | ||
| + | loop txqueuelen 1 (Local Loopback) | ||
| + | RX packets 4 bytes 240 (240.0 B) | ||
| + | RX errors 0 dropped 0 overruns 0 frame 0 | ||
| + | TX packets 4 bytes 240 (240.0 B) | ||
| + | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | ||
| + | |||
| + | </pre> | ||
== Customization Script == | == Customization Script == | ||
Revision as of 16:58, 30 September 2019
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
File Downloads
| Filename | Description | Size | Modified | Link |
|---|---|---|---|---|
|
gen-slax-custom.sh |
My own script for generating a custom Slax image. | 4K | 9/30/2019 |
Procedure
First, download Slax from their website: https://slax.org
In this tutorial, I am using version 9.11.0 (64 bit).
I used VirtualBox to set up a VM for generating the custom Slax image: https://www.virtualbox.org/
Be sure to have hardware virtualization enabled in your BIOS (Intel VT-x or AMD-V). Even when I tried to build a 32 bit version of Slax, the build process froze without hardware virtualization.
I created a new VM with these properties:
- 2G of RAM
- 8G virtual disk (dynamic expanding)
- Network connection "Bridged"
Boot it up and select the "slax-64bit-9.11.0.iso" image. It will now boot into a graphical desktop.
You can right-click anywhere on the desktop and select "Terminal".
Start the SSH server:
systemctl start sshNow find out your IP address (assuming the guest OS was able to obtain an address from DHCP):
ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.1.109 netmask 255.255.0.0 broadcast 172.16.255.255
inet6 fe80::a00:27ff:fe2c:39ac prefixlen 64 scopeid 0x20<link>
ether 08:00:27:2c:39:ac txqueuelen 1000 (Ethernet)
RX packets 421 bytes 39318 (38.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15 bytes 1714 (1.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 4 bytes 240 (240.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 240 (240.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Customization Script
Custom script gen-slax-custom.sh (download here):
# ================================================================
#
# 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 .