May 20, 2011

Create a custom distro: building the build machine (p.2)

This page follows from: Create a custom distro: building the build machine (p.1)


Installation Process

The first thing to do is to partition the virtual hard drive, fdisk is my favorite tool and you'll be able to create a boot disk quickly:

root@slax:~# fdisk /dev/sda[ENTER]

The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs

Command (m for help): n[ENTER]
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 1[ENTER]
First cylinder (1-1044, default 1): [ENTER]
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): 900[ENTER]

Command (m for help): n[ENTER]
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 2[ENTER]
First cylinder (901-1044, default 901): [ENTER]
Using default value 901
Last cylinder, +cylinders or +size{K,M,G} (901-1044, default 1044): [ENTER]
Using default value 1044

Command (m for help): t[ENTER]
Partition number (1-4): 2[ENTER]
Hex code (type L to list codes): 82[ENTER]
Changed system type of partition 2 to 82 (Linux swap)

Command (m for help): a[ENTER]
Partition number (1-4): 1[ENTER]

Command (m for help): p[ENTER]

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x17159cab

Device Boot Start End Blocks Id System
/dev/sda1 * 1 900 7229218+ 83 Linux
/dev/sda2 901 1044 1156680 82 Linux swap

Command (m for help): w[ENTER]
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.



Now you've a drive with two partitions (resize them according to your needs), let's format them:


root@slax:~# mkfs.ext2 /dev/sda1[ENTER]
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
452480 inodes, 1807304 blocks
90365 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1853882368
56 block groups
32768 blocks per group, 32768 fragments per group
8080 inodes per group
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
root@slax:~# mkswap /dev/sda2[ENTER]
Setting up swapspace version 1, size = 1156676 KiB
no label, UUID=1bbc1448-eef5-4faf-874b-f6d9f873459d
root@slax:~# swapon /dev/sda2[ENTER]
root@slax:~# free[ENTER]
total used free shared buffers cached
Mem: 510880 272320 238560 0 38944 183456
-/+ buffers/cache: 49920 460960
Swap: 1156672 0 1156672

Now it's time mount the target drive into your system:

root@slax:~# mkdir /mnt/sda1[ENTER]
root@slax:~# mount /dev/sda1 /mnt/sda1[ENTER]
root@slax:~# df[ENTER]
Filesystem 1K-blocks Used Available Use% Mounted on
aufs 306528 916 305612 1% /
tmpfs 255440 0 255440 0% /dev/shm
/dev/hdc 204850 204850 0 100% /mnt/hdc
/dev/sda1 7115576 15900 6738216 1% /mnt/sda1


As you can see my virtual appliance mapped my virtual CD-ROM unit as /dev/hdc, please change your settings according to your virtualization software if needed because it's time to enter into the CD-ROM root and copy everything in the virtual hard disk, here's:


root@slax:~# cd /mnt/hdc/[ENTER]
root@slax:/mnt/hdc# ls -la[ENTER]
total 10
drwxr-xr-x 4 root root 2048 Aug 4 2009 ./
drwxr-xr-x 5 root root 100 May 20 12:59 ../
dr-xr-xr-x 6 apache apache 4096 May 20 10:31 boot/
dr-xr-xr-x 7 apache apache 4096 May 20 10:31 slax/
root@slax:/mnt/hdc# cp -R * ../sda1/[ENTER]

I've just copied the entire content of the Slax CD-ROM drive in the hard disk, now we only need to install LILO to have a bootable hard disk.

Enter into your hard drive location and issue the command, it's fairly simple to understand what it does, by the way this script will explain you what it's for and asks you to read few messages to continue the installation


root@slax:/mnt/hdc# cd ../sda1/[ENTER]
root@slax:/mnt/sda1# ./boot/[ENTER]

Welcome to Slax boot installer -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

This installer will setup disk /dev/sda to boot only Slax from /dev/sda1.
Warning! Master boot record (MBR) of /dev/sda will be overwritten.
If you use /dev/sda to boot any existing operating system, it will not work
anymore. Only Slax will boot from this device. Be careful!

Press any key to continue, or Ctrl+C to abort...[ENTER]

Flushing filesystem buffers, this may take a while...
Updating MBR to setup boot record...
Warning: The initial RAM disk is too big to fit between the kernel and
the 15M-16M memory hole. It will be loaded in the highest memory as
though the configuration file specified "large-memory" and it will
be assumed that the BIOS supports memory moves above 16M.
Added Slax ? *
Disk /dev/sda should be bootable now. Installation finished.

Read the information above and then press any key to exit...[ENTER]




We did it. Now your machine is fully bootable and ready to go, power off the system and remove your virtual CD-ROM from VMWare configuration menu, it's not needed anymore.

Next step will prepare your new build machine to host a “simple binary toolchain”, with it you'll be able to create appliances and understand Slax configuration as well

As normal just drop me a note if you'd like to have information about it or if you'd like to have more details on what I've done


Previous Chapters

Next Chapters


Andrea (Ben) Benini