Saturday, 19 March 2016

Create a custom distro: Create your first ISO image

Create a custom distro: Create your first ISO image


Now it's time to create the first image, it's just a matter of minutes.

Preparation

When the login screen comes around you may enter in your system with the root user, “toor” is the default password with SLAX unless you change it, /etc/issue is reporting a lot of useful information for newbies as well (root/toor, xconf, startx, …)

Now in less than 5 minutes you'll be able to create your new virtual machine, let's create a simple environment:
root@slax:~# mkdir target target/image target/iso
root@slax:~# cd target/image/
Now it's time to copy the contents of your build machine into your target host space:
root@slax:~/target/image# cp /mnt/sda1/boot . -R
root@slax:~/target/image# cp /mnt/sda1/slax . -R
root@slax:~/target/image# ls -la
total 16
drwxr-xr-x 4 root root 4096 May 30 17:35 ./
drwxr-xr-x 3 root root 4096 May 30 17:33 ../
dr-xr-xr-x 6 root root 4096 May 30 17:35 boot/
dr-xr-xr-x 7 root root 4096 May 30 17:35 slax/
Where /mnt/sda1/ is my root partition, if you've followed my previous article you may have the same device name, expecially if you've installed it in a virtual host (I'm using VMWare), if you're not under /mnt/sda1 you may discover your root partition name, it ain't that difficult:
root@slax:~/target/image# df
Filesystem           1K-blocks      Used Available Use% Mounted on
aufs                   7115576    631668   6122448  10% /
tmpfs                   255440         0    255440   0% /dev/shm
/dev/sda1              7115576    631668   6122448  10% /mnt/sda1

Now in your target directory you've the essential structure of your new target device

root@slax:~/target/image# ls -la
total 16
drwxr-xr-x 4 root root 4096 May 30 17:35 ./
drwxr-xr-x 3 root root 4096 May 30 17:33 ../
dr-xr-xr-x 6 root root 4096 May 30 17:35 boot/
dr-xr-xr-x 7 root root 4096 May 30 17:35 slax/
This is just what you need to create your new target system



Creating a target ISO

to create a target ISO with an exact copy of your system you only need to use a ready made script file located under target/image/slax directory, invocation is straightforward:
root@slax:~/target# ./image/slax/make_iso.sh iso/mycoolimage.iso
2.01.01a53 (i686-pc-linux-gnu)
Scanning ../.
Scanning .././boot
Scanning .././boot/dos
Scanning .././boot/isolinux
Excluded by match: .././boot/isolinux/isolinux.boot
Scanning .././boot/pxelinux.cfg
Scanning .././boot/pxelinux.cfg/web
Scanning .././boot/pxelinux.cfg/web/conf
Scanning .././boot/syslinux
Scanning .././slax
Scanning .././slax/base
Scanning .././slax/modules
Scanning .././slax/optional
Scanning .././slax/rootcopy
Scanning .././slax/tools
Scanning .././slax/tools/WIN
Writing:   Initial Padblock                        Start Block 0
Done with: Initial Padblock                        Block(s)    16
Writing:   Primary Volume Descriptor               Start Block 16
Done with: Primary Volume Descriptor               Block(s)    1
Writing:   Eltorito Volume Descriptor              Start Block 17
Size of boot image is 4 sectors -> No emulation
Done with: Eltorito Volume Descriptor              Block(s)    1
Writing:   Joliet Volume Descriptor                Start Block 18
Done with: Joliet Volume Descriptor                Block(s)    1
Writing:   End Volume Descriptor                   Start Block 19
Done with: End Volume Descriptor                   Block(s)    1
Writing:   Version block                           Start Block 20
Done with: Version block                           Block(s)    1
Writing:   Path table                              Start Block 21
Done with: Path table                              Block(s)    4
Writing:   Joliet path table                       Start Block 25
Done with: Joliet path table                       Block(s)    4
Writing:   Directory tree                          Start Block 29
Done with: Directory tree                          Block(s)    17
Writing:   Joliet directory tree                   Start Block 46
Done with: Joliet directory tree                   Block(s)    15
Writing:   Directory tree cleanup                  Start Block 61
Done with: Directory tree cleanup                  Block(s)    0
Writing:   Extension record                        Start Block 61
Done with: Extension record                        Block(s)    1
Writing:   The File(s)                             Start Block 62
  4.89% done, estimate finish Mon May 30 17:44:43 2011
  9.77% done, estimate finish Mon May 30 17:44:43 2011
 14.65% done, estimate finish Mon May 30 17:44:43 2011
 19.53% done, estimate finish Mon May 30 17:44:43 2011
 24.42% done, estimate finish Mon May 30 17:44:43 2011
 29.29% done, estimate finish Mon May 30 17:44:43 2011
 34.18% done, estimate finish Mon May 30 17:44:45 2011
 39.05% done, estimate finish Mon May 30 17:44:45 2011
 43.94% done, estimate finish Mon May 30 17:44:45 2011
 48.82% done, estimate finish Mon May 30 17:44:45 2011
 53.71% done, estimate finish Mon May 30 17:44:44 2011
 58.58% done, estimate finish Mon May 30 17:44:44 2011
 63.47% done, estimate finish Mon May 30 17:44:44 2011
 68.34% done, estimate finish Mon May 30 17:44:44 2011
 73.22% done, estimate finish Mon May 30 17:44:44 2011
 78.11% done, estimate finish Mon May 30 17:44:44 2011
 82.99% done, estimate finish Mon May 30 17:44:44 2011
 87.86% done, estimate finish Mon May 30 17:44:44 2011
 92.75% done, estimate finish Mon May 30 17:44:44 2011
 97.64% done, estimate finish Mon May 30 17:44:45 2011
Total translation table size: 2048
Total rockridge attributes bytes: 9444
Total directory bytes: 32768
Path table size(bytes): 208
Done with: The File(s)                             Block(s)    102222
Writing:   Ending Padblock                         Start Block 102284
Done with: Ending Padblock                         Block(s)    150
Max brk space used 21000
102434 extents written (200 MB)
And that's it, you now have a file called mycoolimage.iso under the iso directory

root@slax:~/target# ls -la iso/
total 205084
drwxr-xr-x 2 root root      4096 May 30 17:44 ./
drwxr-xr-x 4 root root      4096 May 30 17:36 ../
-rw-r--r-- 1 root root 209784832 May 30 17:44 mycoolimage.iso
you may create a little script if you want to automate the whole process:
#!/bin/bash
# This script builds an ISO file from the image created
BASEPATH=/mnt/sda1/target
REMOTEHOST=192.168.84.1

mkdir -p $BASEPATH/iso
$BASEPATH/image/slax/make_iso.sh $BASEPATH/iso/image.iso
scp $BASEPATH/iso/image.iso ben@$REMOTEHOST:/iso/image.iso
p { margin-bottom: 0.08in; }
To make my own tests I've two virtual machines, one it's called “Slax Build Machine”, one it's called “Slax Test Machine”. “Slax Build Machine” is the machine we're now using and the same machine we've built in the previous chapter. “Slax Test Machine” it's an empty VMWare virtual machine, no hard drives, just a virtual cdrom device pointing to an ISO file located on the real host (in the directory /tmp/image.iso). When I'd like to make some tests I just need to create an ISO file (in the build machine with the previous script). The script copies the .ISO image in the physical host after the creation, then I start the Test Machine when needed, I don't need to waste CDs or reinstall/configure the virtual machine each time, it's really easy

In this chapter we've just created an identical copy of our build machine, in the next chapter we'll customize the test machine, we'll start with a bare bone system and we'll add modules/functionalities later on
I guess this phase is really easy but it's important to understand it well, from the next phase you'll understand why customizing and building a slax machine is really easy and powerful

No comments: