Custom Linux distro

Published:

Build your own small Linux. Build your linux for kiosk or PXE or Live CD or security box where it is so unique that it is painful to use

Also it is a good way to understand how linux works, how to customize it and why nothing in linux is done right, but what they do to cover up all crutches.

Buildroot

Buildroot cheat sheet

export LD_LIBRARY_PATH=""
make distclean
make ghatanothoa_defconfig
make xconfig # if any additional changes
make savedefconfig # save these additional changes
make linux-xconfig # if any additional changes
# save linux config
cp output/build/linux-5.12.10/.config \
    board/<brand>/<board>/linux.config 
make HOSTCXX=g++-11 HOSTCC=gcc-11

Reference:

FAT 32

UEFI version

kernel in buildroot should be adjusted, enable all:

CONFIG_FB_EFI=y
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_EFI=y
CONFIG_EFI_VARS=y

M.2 and NVME

<*> NVM Express block device
[*] NVMe multipath support
[*] NVMe hardware monitoring
<M> NVM Express over Fabrics FC host driver
<M> NVM Express over Fabrics TCP host driver
<M> NVMe Target support
  [*]   NVMe Target Passthrough support
  <M>   NVMe loopback device support
  <M>   NVMe over Fabrics FC target driver
  < >     NVMe over Fabrics FC Transport Loopback Test driver (NEW)
  <M>   NVMe over Fabrics TCP target support

Source: https://wiki.gentoo.org/wiki/NVMe

Autostart

Weston settings

Weston autolaunch

Test image in VirtualBox

sudo dd if=/dev/zero of=azathoth.img bs=1M count=48000
48000+0 records in
48000+0 records out
50331648000 bytes (50 GB, 47 GiB) copied, 894.784 s, 56.3 MB/s

sudo mkfs -t ext4 azathoth.img
mke2fs 1.46.2 (28-Feb-2021)
Discarding device blocks: done
Creating filesystem with 12288000 4k blocks and 3072000 inodes
Filesystem UUID: d93f9155-4fd8-4f07-be0b-ee50719f5212
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done

mkdir mountpoint
sudo mount -t auto -o loop azathoth.img mountpoint/
mount | grep azathoth
azathoth.img on mountpoint type ext4 (rw,relatime)

sudo dd if=/dev/zero of=root.img bs=1M count=7200
sudo mkfs -t ext4 root.img
mkdir root
sudo mount -t auto -o loop root.img root/
sudo rsync -rav ../builroot/output/ root/
sudo umount root

yay -S genimage
cat genimage-bios.cfg
image azathoth.img {
  hdimage {
  }
  partition boot {
    in-partition-table = "no"
    image = "boot.img"
    offset = 0
    size = 512
  }
  partition grub {
    in-partition-table = "no"
    image = "grub.img"
    offset = 512
  }
  partition root {
    partition-type = 0x83
    image = "root.img"
  }
}

rm -r tmp
genimage --inputpath ./ --outputpath ./ --config genimage-bios.cfg
VBoxManage convertfromraw azathoth.img azathoth.vdi --format VDI

sudo pacman -S qemu
sudo modprobe nbd max_part=16
sudo qemu-nbd -c /dev/nbd0 azathoth.vdi
sudo mount /dev/nbd0p1 root

Folder to image

Simplification

sudo dd if=/dev/zero of=root.img bs=1M count=7200
sudo mkfs -t ext4 root.img
mkdir root
sudo mount -t auto -o loop root.img root/
sudo rsync -rav ../builroot/output/ root/
sudo umount root

Just one command:

mkfs.ext4 -d ../builroot/output/ root.img 10G

Bootable image

mkfs.ext4 -d new-root -r 1 -N 0 -m 5 -L "rootfs" -O ^64bit new-rootfs.ext4 "250M"
image shaurash.img {
  hdimage {
    gpt = true
  }

  partition root {
    image = "new-rootfs.ext4"
  }
}

Answer this : https://unix.stackexchange.com/questions/235145/

VirtualBox default resolution

VBoxManage setextradata "Shaurash" VBoxInternal2/EfiGraphicsResolution 1920x1080

Reference

Rate this page