Installing your system: Difference between revisions
Line 97: | Line 97: | ||
mount --bind /dev /mnt/install_root/dev | mount --bind /dev /mnt/install_root/dev | ||
chroot /mnt/install_root grub-install /dev/ | chroot /mnt/install_root grub-install /dev/sda | ||
chroot /mnt/install_root grub-mkconfig -o /boot/grub/grub.cfg | chroot /mnt/install_root grub-mkconfig -o /boot/grub/grub.cfg | ||
Revision as of 20:35, 31 January 2012
This page will explain how to install a system using LFScript. However, it is also possible to install your system from a Live CD you built.
Some notes before you begin
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. It is assumed that you already have established (writable) access to the LFScript folder.
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 is 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.
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
Create /etc/fstab
Because partition configurations are unique to your preferences, LFScript can not make the system bootable for you. There are two things you have to configure before the system is able to boot.
First, create the '/etc/fstab' file (based on LFS-SVN20120130):
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
Be sure to change the first three entries so that they correspond with your set up.
Installing a boot loader
The second thing to do to be able to boot your system, is configuring 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 # Only required for 'os-prober' mount --bind /proc /mnt/install_root/proc # Only required for 'os-prober' mount --bind /dev /mnt/install_root/dev chroot /mnt/install_root grub-install /dev/sda chroot /mnt/install_root grub-mkconfig -o /boot/grub/grub.cfg umount /mnt/install_root/sys # If mounted... umount /mnt/install_root/proc # If mounted... umount /mnt/install_root/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.