Visit our website:
www.linutop.com


Tutorials/BootScripts

From LinutopWiki

Version 1.1.5

Contents

Custom boot scripts

The Linutop OS boot is handled by lrd (fork of casper), a set of scripts which customize a standard debian based OS to make it run as a live CD. Everything is done using the kernel initrd.

The last script run by lrd will run all the shell scripts found in the casper-local directory on the first partition of the system (This directory doesn't exist by default, you need top create it if you want to use custom scripts).

Those scripts act on what will become the "real" system. So when writing scripts, keep the following in mind:

  • the final system is mounted on /root, so you might need to chroot in this folder to perform certain actions (apt-get install'ing softwares for instance)
  • all the mounts have been performed already. If you boot in the default mode, /root/home/linutop already exists, so you can add/remove data in the user dir
  • the USB stick (or internal flash) is mounted on /root/cdrom

Simple examples

Install a package

#!/bin/sh

chroot /root apt-get install gftp

exit 0

Load a kernel module

#!/bin/sh

insmod /root/cdrom/mymodule.ko

exit 0

Modify a file

#!/bin/sh

INTERFACES="/root/etc/network/interfaces"
cat >$INTERFACES <<EOF
auto eth0
iface eth0 inet static
address 192.168.0.18
netmask 255.255.255.0
gateway 192.168.0.250
EOF

Use an external drive as /home

This will only work on Linutop 2 due to BIOS limitation on Linutop 1. Make sure to first boot from the internal drive (hdd0) in the BIOS settings.

Change the device ID and filesystem to fit your needs.

#!/bin/sh

mount -t ext3 /dev/sda1 /root/home
if [ ! -d /root/home/linutop ]; then
  cp -R /root/etc/skel /root/home/linutop
  chown -R 1000:1000 /root/home/linutop
fi

exit 0