DracOs Environment – My Build Lab

Home / DracOs Environment – My Build Lab

DracOs Environment – My Build Lab

December 24, 2016 | Labs | No Comments

My role on team require me to build specific environment to do development. As you know DracOs is a LFS-based linux distribution, means we build it from ground up. We are not remastering or modify another distro. A pure linux tailored for our need.

My development lab is simple. All the build is done on virtual machine, I choose VirtualBox. Two virtual machines are needed. The first VM is Builder while the second one is Target. The Target is the final product of DracOs which can be boot on (theoretically) any environment. So Target will be a VM for running tests. On development process, Target would be mounted to Builder. Builder will do all the works. Basically Builder will build two things: tools and Target.

In this article I will describe the setting I use to create build environment (version 1). This version has not integrated with much stuffs but works for first phase.

Virtual Machines Specification

Builder

  • Arch Linux template
  • Processors: 4 CPUs
  • RAM 4096 MB (4GB)
  • HDD
    • /dev/sda (20GB) Builder.vdi
      • /dev/sda1 – / (8GB) ext4
      • /dev/sda2 – (2GB) swap
      • /dev/sda3 – /tools (5GB) ext4 for x86_64
      • /dev/sda4 – /tools (5GB) ext4 for i386
    • /dev/sdb  (mounted Target.vdi)

Remaining space are unused

Target

  • Arch Linux template
  • Processors 1 CPUs
  • RAM 1024 MB (1GB)
  • HDD
    • /dev/sda (24GB GPT) Target.vdi
      • /dev/sda1 – EFI (1GB) for EFI partition
      • /dev/sda2 – swap for linux swap
      • /dev/sda1 – / (10GB) ext4 for 64bit branch
      • /dev/sda2 – / (10GB) ext4 for 32bit branch

As you see, Target will be mounted to Builder.

I choose Arch Linux because I need lightweight distro to do the job.

At this point, my lab is deviate a little from LFS build environment. The LFS guide recommended to make a partition for LFS with tools as a part of LFS partition. In my lab, I separate both tools and sources in Builder machine and bind them to Target if necessary. This way I won’t need to remove things.

Setup Target

The setup we do is to create proper partition. I know we could do this on Builder, but I decide to separate the two things so we can clearly see each roles and functions.

Boot ArchLinux ISO. Once we are prompted, run fdisk to partition.

target# fdisk /dev/sda

My final partition layout would be like this

target# fdisk -l /dev/sda
Disk /dev/sdb: 24 GiB, 25769803776 bytes, 50331648 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: gpt
Disk identifier: 84916FEB-BDFF-4860-A9C8-C4C2D351E9B9

Device        Start      End  Sectors Size Type
/dev/sda1      2048  2099199  2097152   1G EFI System
/dev/sda2   2099200  8390655  6291456   3G Linux swap
/dev/sda3   8390656 29362175 20971520  10G Linux filesystem
/dev/sda4  29362176 50331614 20969439  10G Linux filesystem

Then we format each partition.

target# mkfs.ext4 /dev/sda3
target# mkfs.ext4 /dev/sda4

Shutdown

target# shutdown -h -P now

Setup Builder

I will divide the process into three sections: prepare, install, builder. Each phase has it’s own purpose and identified by the name before the prompt.

I don’t create user other than lfs. This user is comply with LFS guide and would be the only user in system (other than root).

Actually, this is not much different to typical Arch Linux installation.

Prepare Phase

Prepare environment before doing installation.

US keymap is OK for me so nothing to change.

Make sure network is up and we can ping to internet.

prepare# ping archlinux.org

Update the system clock. Synchronize with NTP to ensure system clock is accurate.

prepare# timedatectl set-ntp true
prepare# timedatectl status

Part the dist, make following partitions

target# fdisk -l /dev/sda
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0xaec171fe

Device     Boot    Start      End  Sectors Size Id Type
/dev/sda1           2048 16779263 16777216   8G 83 Linux
/dev/sda2       16779264 20973567  4194304   2G 82 Linux swap / Solaris
/dev/sda3       20973568 31459327 10485760   5G 83 Linux
/dev/sda4       31459328 41943039 10483712   5G 83 Linux

and format them

prepare# mkfs.ext4 /dev/sda1
prepare# mkfs.ext4 /dev/sda3
prepare# mkfs.ext4 /dev/sda4
prepare# mkswap /dev/sda2
prepare# swapon /dev/sda2

mount the file systems.

prepare# mount /dev/sda1 /mnt
prepare# mkdir /mnt/tools
prepare# mkdir /mnt/sources
prepare# mkdir /mnt/scripts

Install Phase

Select mirrors. All packages downloaded from mirrors so we need to make sure selecting correcting server. Nearby servers are preferred. Open /etc/pacman.d/mirrorlist and start rearranging.

Strap minimum installation

install# pacstrap /mnt base

generate fstab with current condition

install# genfstab -U /mnt >> /mnt/etc/fstab

then chroot

install# arch-chroot /mnt

Set the timezone. Here we also generate /etc/localtime.

install(chroot)# ln -s /usr/share/zoneinfo/Asia/Jakarta /etc/localtime

Uncomment en-US.UTF-8 UTF-8 and other needed localization in /etc/locale.gen. Then generate them with.

install(chroot)# locale-gen

Change hostname and hosts.

install(chroot)# echo "Builder" > /etc/hostname
install(chroot)# echo "127.0.0.1    builder.localdomain   builder" >> /etc/hosts

creating new initramfs is usually not required. However I jsut want to make sure.

install(chroot)# mkinitcpio -p linux

Change root password.

install(chroot)# passwd

Create new username lfs for development only.

groupadd lfs
useradd -m -g lfs -k /dev/null -s /bin/bash lfs
passwd lfs

Update repository

install(chroot)# pacman -Syy
install(chroot)# pacman -S sudo

Install bootloader. I choose GRUB. (see this)

install(chroot)# pacman -S grub
install(chroot)# grub-install --target=i386-pc /dev/sda
install(chroot)# grub-mkconfig -o /boot/grub/grub.cfg

Enable networking services.

install(chroot)# systemctl enable dhcpcd

Reboot, make sure our base system is installed and ready to use.

install(chroot)# exit
install# reboot

Builder Phase

Install linux header. This is important for building DKMS modules. We also need base-devel for building process so it’s a crucial component.

builder# pacman -S net-tools pkgfile base-devel

Leveraging CLI to do all stuffs is interesting. However I need to produce script and stuffs for development process thus I install GUI. It is not a necessary thing for build machine.

builder# pacman -S xf86-video-vesa   # let test X window system when we don't have Virtualbox guest addition installed yet
builder# pacman -S alsa-utils
builder# pacman -S xorg-server xorg-xinit
builder# pacman -S ttf-dejavu ttf-droid ttf-inconsolata
builder# pacman -S terminus-font
builder# pacman -S xorg-twm xorg-xclock xterm
builder# pacman -S xfce4 xfce4-goodies

Next create virtualbox modules so we can interact with Builder from host system

builder# pacman -S linux-headers
builder# pacman -S virtualbox-guest-utils

builder# nano /etc/modules-load.d/virtualbox.conf
	vboxguest
	vboxsf
	vboxvideo

builder# systemctl enable vboxservice.service

Let’s see the result by starting xfce. Nice desktop and nice mouse logo should be there.

builder# startxfce4

Install and configure some tools

builder# pacman -S git
builder# pacman -S python

In most case I utilize the builder remotely using SSH so I need to install OpenSSH. This way I can use my freely copy-and-paste commands on my SSH client.

builder# pacman -S openssh

Next time, I should use this to connect (with some name registration in my local machine)

client# ssh [email protected]

About Author

about author

xathrya

A man who is obsessed to low level technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial