How to Install and Run Slax OS from SSD

This article documents how to install Slax OS onto a solid state drive (SSD), and run it from there with persistent changes to the system.

Environment

The process was researched and tested in the following environment:

Kingston 120 GB SSD front
Kingston 120 GB SSD front
Kingston 120 GB SSD back sticker
Kingston 120 GB SSD back sticker

File System Options

We experimented with the following 2 options because Slax OS behavior is different depending on filesystem type on disk. Also, Slax does not recommend using GPT (GUID partition table), so we'll exclude them. Our options to research were:

Slax OS Install Procedure on SSD

We used the following simple procedure to install Slax OS on SSD.

That's it. Below is a bit more detailed description for each step.

Formatting

WARNING: this procedure is destructive as it destroys disk data. To minimize accidental damage to a wrong disk, it's probably best to prepare a system with only a target SSD inserted into it, and boot the system from Slax ISO. But there are other ways. For example, on Ubuntu 16.04, you can use the Disks utility to format SSD, or gdisk tool to convert its partition schema from GPT to MBR. The following procedure assumes we run Slax.

Converting from GPT to MBR

First, we need to make sure our disk uses MBR. We can do it using fdisk tool:

# fdisk /dev/sda

Then type p and press Enter to print partition table and look at Disklabel type value. If it says dos then we already have an MBR disk.

Disklabel type: dos

If disklabel type is gpt we need to convert the disk to MBR. We can do it with gdisk tool. It is not installed in Slax, but we can install it using:

# apt install gdisk

Note that gdisk can also display partition types. To remove GPT from /dev/sda:

# gdisk /dev/sda

Then use x for experts only mode. In expert mode, use z to zap (destroy) GPT data structures and exit.

Creating a Primary Partition

Now that we have an MBR disk, we can use fdisk utility to create a primary partition. First, we delete all existing partitions. Again, WARNING: DATA WILL BE LOST. We can print the existing partitions as so:

# fdisk /dev/sda
Command (m for help): p

And then use the d option (delete) to delete partitions one by one, if there are any. After all partitions are erased, we can add a new primary partition using the n option.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-234441647, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-234441647, default 234441647): 

Created a new partition 1 of type 'Linux' and of size 111.8 GiB.

Command (m for help): p
Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6f4bc64f

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 234441647 234439600 111.8G 83 Linux

Write changes to the disk with the w option.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Changing File System Type to FAT32

To change file system type on a new partition to fat32, we can use the t option in fdisk and then b option for fat32:

# fdisk /dev/sda
Command (m for help): t
Selected partition 1
Partition type (type L to list all types): b
Changed type of partition 'Linux' to 'W95 FAT32'.

Write changes to the disk:

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

The above completes our task of creating a fat32 partition for Slax OS install. We can print out the current disk layout with fdisk p option:

# fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3e3e2c09

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 234441647 234439600 111.8G  b W95 FAT32

Using the Entire Disk without Partitions

For experimentation, it could be much simpler to just use the entire disk without partitions. We can do it like so:

To create a fat32 disk:

mkfs.vfat /dev/sda -I

Note: Executing this command in Slax prints out an attribute "partition" not found message on screen, but it does change the file system type. There is no such message if we do it Ubuntu.

To create an ext4 disk:

mkfs.ext4 /dev/sda

After doing so, we can check filesystem type by mounting the disk and then invoking df -HT command. In the example below, vfat means we use fat32 file system.

# df -HT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/sda       vfat      121G   33k  121G   1% /media/sda

Copying Slax Files

We need to copy the files from Slax ISO to to SSD. One way of doing this is this:

cp -rf /media/sr0/* /media/sda/

Adjusting Boot Record

To make SSD bootable, execute bootinst.sh in slax/boot/. Note that just setting the bootable flag on the primary partition is not enough. You can look at bootinst.sh in text editor to see what it does.

cd /media/sda/slax/boot
./bootinst.sh

Now we can boot Slax from SSD.

Differences between fat32 and ext4 Installs

If you run Slax in both ext4 and fat32 install modes, you can notice a difference how it stores persistent changes.

Exploring Boot Options

During Slax boot, a boot logo is displayed for a brief period of 2 seconds, when you can press any key to see the following boot options.

Slax boot options
Slax boot options

Persistent Changes

This option persists changed files. See the section above on where the changes are kept. It is the default choice.

Fresh Start

This option means starting the OS without loading persistent changes accumulated earlier. Also, changes created in Fresh Start mode don't persist. For example, if you create a file it will be lost if you reboot in Persistent Changes mode.

Copy to RAM

This option means that an entire OS as in Fresh Start mode (without accumulated persistent changes) is copied to RAM and then you run everything from RAM only. You can actually remove the disk at this point and continue to use the OS.