Difference between revisions of "Installing your system"

From LFScript
(Added instructions to install from Live CD (commands are yet to be explained))
Line 1: Line 1:
This page will explain how to install a system using LFScript. However, it is also possible to [[Installing your system from a Live CD|install your system from a Live CD]] you built.
+
This page will explain how to install a system using either LFScript, or your own Live CD.
  
 
== Some notes before you begin ==
 
== Some notes before you begin ==
It is assumed you already have compiled your system; LFScript is set up on a writeable partition and the <code>packages</code> directory is populated. It is possible you have transferred your packages directory from another machine.
+
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 <code>packages</code> 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.
 
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.
+
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 <code>os-prober</code> script to your extra packages. If you want <code>os-prober</code> to detect your existing Windows installations, your host system's kernel must have FAT and/or NTFS support.
 
If you intend to overwrite an existing boot loader, it is recommended you add the <code>os-prober</code> script to your extra packages. If you want <code>os-prober</code> to detect your existing Windows installations, your host system's kernel must have FAT and/or NTFS support.
  
 
== Format your partitions ==
 
== 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'''.
+
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 <code>/usr</code> hierarchy of your new system.
 
The '''sda2''' partition is optional, but in this example we shall use it to mount the <code>/usr</code> hierarchy of your new system.
Line 37: Line 37:
 
You can also change <code>usr</code> to <code>home</code> in the previous commands if you want to have your home directory on the second partition in stead.
 
You can also change <code>usr</code> to <code>home</code> in the previous commands if you want to have your home directory on the second partition in stead.
  
== Edit 'install.conf' (optional) ==
+
== Install with LFScript ==
 +
 
 +
=== Edit 'install.conf' (optional) ===
 
LFScript is going to configure your system based on the contents of a file called <code>install.conf</code>. Edit that file if you like.
 
LFScript is going to configure your system based on the contents of a file called <code>install.conf</code>. Edit that file if you like.
  
Line 44: Line 46:
 
<pre>nano scripts/install.conf    # or use any other text editor</pre>
 
<pre>nano scripts/install.conf    # or use any other text editor</pre>
  
== Install your system ==
+
=== Install your system ===
 
To actually install the system, run LFScript like you would normally do to build a system and add <code>-i /mnt/install_root</code>. If you want to automatically add an existing OS to the boot menu, be sure to also install <code>os-prober</code>.
 
To actually install the system, run LFScript like you would normally do to build a system and add <code>-i /mnt/install_root</code>. If you want to automatically add an existing OS to the boot menu, be sure to also install <code>os-prober</code>.
  
Line 60: Line 62:
 
./lfscript -Bux "&#119;get nano os-prober" -i /mnt/install_root -I install_overhead
 
./lfscript -Bux "&#119;get nano os-prober" -i /mnt/install_root -I install_overhead
 
rm -rf install_overhead</pre>
 
rm -rf install_overhead</pre>
 +
 +
== Install from your own Live CD ==
 +
<pre>cd /mnt/.boot/medium/boot/$(uname -m)</pre>
 +
 +
<pre>unsquashfs -da 64 -fr 64 -f -d /mnt/install_root root.sqfs</pre>
 +
 +
<pre>chroot /mnt/install_root passwd root</pre>
  
 
== Create /etc/fstab ==
 
== Create /etc/fstab ==
Line 93: Line 102:
 
To let your own system configure the boot loader, execute the following commands:
 
To let your own system configure the boot loader, execute the following commands:
  
<pre>mount --bind /sys  /mnt/install_root/sys   # Only required for 'os-prober'
+
<pre>mount --bind /sys  /mnt/install_root/sys
mount --bind /proc /mnt/install_root/proc # Only required for 'os-prober'
+
mount --bind /proc /mnt/install_root/proc
 
mount --bind /dev  /mnt/install_root/dev
 
mount --bind /dev  /mnt/install_root/dev
  
Line 100: Line 109:
 
chroot /mnt/install_root grub-mkconfig -o /boot/grub/grub.cfg
 
chroot /mnt/install_root grub-mkconfig -o /boot/grub/grub.cfg
  
umount /mnt/install_root/sys   # If mounted...
+
umount /mnt/install_root/sys
umount /mnt/install_root/proc # If mounted...
+
umount /mnt/install_root/proc
 
umount /mnt/install_root/dev</pre>
 
umount /mnt/install_root/dev</pre>
  

Revision as of 16:18, 5 February 2012

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

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

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
mount --bind /proc /mnt/install_root/proc
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
umount /mnt/install_root/proc
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.