Installing your system

From LFScript

This page will explain how to install a system using either LFScript, or your own Live CD.

Some notes before you begin

If you are using LFScript to install your system, it is assumed you already have compiled your system; LFScript is set up on a writeable partition and the packages directory is populated. It is possible you have transferred your packages directory from another machine.

If the hard disk is not yet partitioned, see the Quick Start page for information on how to do that.

All commands presented here should be executed by the root user.

If you intend to overwrite an existing boot loader, it is recommended you add the os-prober script to your extra packages. If you want os-prober to detect your existing Windows installations, your host system's kernel must have FAT and/or NTFS support.

Format your partitions

If you have partitioned your system as explained on the Quick Start page, you should have two partitions reserved for your new system: sda1 and sda2. You might also have set up a third (sda3) for SWAP space. And LFScript may be installed on sda4.

The sda2 partition is optional, but in this example we shall use it to mount the /usr hierarchy of your new system.

mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda2    # Optional

These commands will install an ext4 file system on your partitions. You can use any Linux file system you want, but make sure you have configured your kernel to support it.

If you have not yet configured your swap space, do it now:

mkswap /dev/sda3

Mount your partitions

Mount the partition where your are going to install the system:

mkdir /mnt/install_root
mount /dev/sda1 /mnt/install_root

If you have set up sda2, then mount it as well:

mkdir /mnt/install_root/usr
mount /dev/sda2 /mnt/install_root/usr

You can also change usr to home in the previous commands if you want to have your home directory on the second partition in stead.

Install with LFScript

Edit 'install.conf' (optional)

LFScript is going to configure your system based on the contents of a file called install.conf. Edit that file if you like.

By default, the file is empty, in which case LFScript will use either default values or ask you for input to configure certain aspects of your system.

nano scripts/install.conf    # or use any other text editor

Install your system

To actually install the system, run LFScript like you would normally do to build a system and add -i /mnt/install_root. If you want to automatically add an existing OS to the boot menu, be sure to also install os-prober.

./lfscript <options> -i /mnt/install_root

For. example:

./lfscript -Bux "wget nano os-prober" -i /mnt/install_root

If the target partition only has just enough space to hold the OS that you have built, you might want to add the -I switch to lfscript and specify a directory which has enough space to temporarily store the source code and tool chain.

For example:

mkdir install_overhead
./lfscript -Bux "wget nano os-prober" -i /mnt/install_root -I install_overhead
rm -rf install_overhead

Install from your own Live CD

Note: The Live CD structure is currently under review, and may vary between releases of LFScript. Therefore, this section is subject to change.

cd /mnt/.boot/medium/boot/$(uname -m)
unsquashfs -da 64 -fr 64 -f -d /mnt/install_root root.sfs

(Note: File 'root.sfs', is named 'root.sqfs' prior to rev. 21)

chroot /mnt/install_root passwd root

Modify /etc/fstab

If you installed your system on a single partition (it does not matter which one), and you don't care about swap partitions or running fsck on boot, you can skip this step (but only if you are using LFScript 4 revision 21 or newer).

Modify the '/etc/fstab' file, so that it lists all partitions which make up your file system. Be sure to adjust the following command, so that the first three entries correspond with your set up:

cat > /mnt/install_root/etc/fstab << "EOF"
# Begin /etc/fstab

# file system  mount-point  type     options             dump  fsck
#                                                              order
/dev/sda1      /            ext4     defaults            1     1
/dev/sda2      /usr         ext4     defaults            1     1
/dev/sda3      swap         swap     pri=1               0     0

proc           /proc        proc     nosuid,noexec,nodev 0     0
sysfs          /sys         sysfs    nosuid,noexec,nodev 0     0
devpts         /dev/pts     devpts   gid=4,mode=620      0     0
tmpfs          /run         tmpfs    defaults            0     0
devtmpfs       /dev         devtmpfs mode=0755,nosuid    0     0

# End /etc/fstab
EOF

Notes:

  • Leave out the last line (defining a devtmpfs) if you are using LFScript 4 revision 12.
  • If you are not using the command above, but are editing fstab by hand, be sure to remove (or comment out) the existing first line, which defines the rootfs.

Installing a boot loader

To make your system bootable, you must configure a boot loader. This is a potentially dangerous thing to do to a system which already has an OS installed, as it could render your existing OS unbootable. You should search the web for instructions on how to recover the bootloader of your existing OS, prior to executing the following commands.

If you already have a Linux OS installed on the system, it may even be better to let it set up the bootloader for you. However, you will need to find out how to do this on your own.

To let your own system configure the boot loader, execute the following commands:

mount --bind /sys  /mnt/install_root/sys
mount --bind /proc /mnt/install_root/proc
mount --bind /dev  /mnt/install_root/dev

chroot /mnt/install_root grub-install /dev/sda --target i386-pc #or --target x86_64-efi
chroot /mnt/install_root grub-mkconfig -o /boot/grub/grub.cfg

umount /mnt/install_root/{sys,proc,dev}

Cleaning up

You can now unmount your system:

umount /mnt/install_root
rm -rf /mnt/install_root

Reboot your system, and enjoy your new OS:

shutdown -r now

If your system will not boot...

Kernel panic - not syncing: VFS:  Unable to mount root fs on unknown-block

This message is caused by the kernel not having been configured properly. You forgot to include support for your hard drive or file system. Remember that in order to boot, these drivers should not be compiled as a module.