Thursday, December 13, 2018

Prepare a Lightweight Linux Distro - Slax - to Play with!

I felt like one Linux install is not enough! That's why I got myself another to play with inside my existing one!


I loved Slax since the day I saw it. It had a 200mb ISO and surprizingly it had KDE packed within that ISO. It's quite impressive to fit KDE into that small filesize. Also, it was great to look at and so entertaining to use. The KDE 4 effects were better than what KDE 5 has now. It was short, appropriate and smooth.

The old Slax had applications packed into .sb files that you could put inside a folder to automatically "mount" them. It was cool in its way and had a smaller footprint than other distros I used. Although a downside being, it used Slackware and some packages that I used were missing.

It doesn't have KDE anymore. Since version 9 it now uses xlunch (not "xlaunch"). xlunch shows its panels, and fullscreen application menu. Plus fluxbox for window manager and debian for packages. Having debian is good, because I can get the packages that was missing before. But now the image size has crossed its 200mb limit. But still, its a ~275mb download which is a respectable size to have, since it has some preloaded drivers.

xlunch - the default panel system on Slax - now has a scrollbar
xlunch - the default panel system on Slax - now has a scrollbar
Slax 9.6.4 adds a scrollbar in xlunch. Another reason to try it!


Slax is not as good looking as it used to be, but it's slowly being developed to be better. xlunch is new after all.

I was using Arch Linux inside a pendrive of mine. So I thought it would be cool to run another Linux inside it. But I had less space to spare. This gave me the idea to use Slax for this project. It is smaller in size and was a perfect fit for handy linux install that I can destroy and play with.


I have used QEMU with KVM, since its smaller in size and equally performant similar to its competition. Plus, it is completely Free Software opposed to Virtualbox - which has a non-free BIOS now.

If you don't have QEMU+kvm installed, I believe you can:

sudo pacman -S qemu libvirt

I was on Arch, so I used pacman. If you are on Ubuntu/Debian, you may need to run:

sudo apt install qemu qemu-kvm

Now create a new folder named slax on your home folder and cd into it:
mkdir ~/slax
cd ~/slax

Now create a disk image file for the machine. This will act like a virtual hard disk for you virtual machine. All the files you save/copy inside the machine will be kept in this file:
qemu-img create slax.img 2G
* 2G means 2GB. You can choose any filesize you want instead of 2G.

Now download Slax ISO from https://www.slax.org/ and put it inside the slax folder.

Let me just point out the install instructions for Slax. It is a bit unique and in a sense easier than other distros. It just says 2 steps, (1) extract "slax" folder from the ISO, (2) run the bootinst.sh. It's that simple! But in here we'd have to take care of the virtual machine stuff, that's all.

Install p7zip and extract the "slax" folder from inside the iso with a zip manager, such as engrampa [lightweight], file-roller [Gnome], Ark [KDE/qt]. So you now should have another slax folder inside the ~/slax folder.

qemu-system-x86_64 -m 1024 -soundhw ac97 -net nic -net user -fsdev fsdriver=local,path=/home/$USER/slax,id=shared0,security_model=passthrough -device virtio-9p-pci,fsdev=shared0,mount_tag=shared0 -machine accel=kvm -hda slax.img -cdrom slax-64bit-9.6.4.iso

I am using a 64 bit system. Run uname -m and find out your architecture and change the qemu-system-x86_64 appropriately if needed. If you need to resize the window, check View - Zoom To Fit and resize.

The command will launch a QEMU window running Slax inside it.

From inside the QEMU window, start terminal and create a new partition with these instructions. Basically, run cfdisk, create a msdos partition table, create a new partition, Write and exit, then run mkfs.ext2 -L "slax-drive" /dev/sda1

Warning: Please double check that you are running these commands from inside the QEMU window. If not, you may loose your data on your hard disk. Make sure by running fdisk -l first that you selected the right drive. The partitions done inside the QEMU Window will stay in the slax.img file, so it will not affect your linux install outside QEMU.

Now mount the drive on "/mnt":
mount /dev/sda1 /mnt

Now we will access the slax folder from outside the QEMU VM to copy the contents of the iso:
mkdir /tmp/shared0; mount -t 9p -o trans=virtio shared0 /tmp/shared0 # -o version=9p2000.L,posixacl,cache=mmap

Then copy the contents:
cp -r /tmp/shared0/slax /mnt

Now run the bootinst.sh from the slax drive:
cd /mnt/slax/boot
chmod +x {bootinst.sh,extlinux.*}
./bootinst.sh

After it is successful, you should see a "Boot install finished" message.

Now reboot:
reboot

Wait for the boot screen to pass. It will boot into your new installation automatically.
It may ask for your username and password. Don't bother, it will boot automatically.

Next time you have to run it, you can shorten the command and run:

qemu-system-x86_64 -m 1024 -soundhw ac97 -net nic -net user -machine accel=kvm -hda slax.img

-m 1024 denotes the RAM you allow the machine to use. You can increase if you have more RAM available.

Better yet, you can create a file named run.sh to run the VM:
touch run.sh && chmod +x run.sh && nano run.sh
Then put this content:
```
#!/bin/bash
qemu-system-x86_64 -m 1024 -soundhw ac97 -net nic -net user -machine accel=kvm -hda slax.img
```

You can now double click the run.sh file and it will run Slax for you every time! Sweet!

You can also delete the slax.iso and the extracted slax folder from outside QEMU.

You can now try out many cool things Slax can do for you while staying in a smaller size at the same time.


ref:
https://wiki.qemu.org/Documentation/9psetup
https://www.slax.org/starting.php

No comments:

Post a Comment