Difference between revisions of "Installing your system"

From LFScript
 
(9 intermediate revisions by 3 users not shown)
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.
+
[[Category:Documentation]]
 +
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 38:
 
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 47:
 
<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 59: Line 62:
 
<pre>mkdir install_overhead
 
<pre>mkdir install_overhead
 
./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&nbsp;-rf install_overhead</pre>
 +
 
 +
== 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.''
 +
 
 +
<pre>cd /mnt/.boot/medium/boot/$(uname -m)</pre>
 +
 
 +
<pre>unsquashfs -da 64 -fr 64 -f -d /mnt/install_root root.sfs</pre>
 +
(Note: File 'root.sfs', is named 'root.sqfs' prior to rev. 21)
 +
 
 +
<pre>chroot /mnt/install_root passwd root</pre>
  
== Create /etc/fstab ==
+
== Modify /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.
+
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 <code>fsck</code> on boot, you can skip this step ('''but only if you are using LFScript 4 revision 21 or newer''').
  
First, create the '/etc/fstab' file (based on LFS-SVN20120130):
+
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:
  
 
<pre>cat > /mnt/install_root/etc/fstab << "EOF"
 
<pre>cat > /mnt/install_root/etc/fstab << "EOF"
Line 84: Line 97:
 
EOF</pre>
 
EOF</pre>
  
Be sure to change the first three entries so that they correspond with your set up.
+
'''Notes:'''
 +
* Leave out the last line (defining a <code>devtmpfs</code>) if you are using LFScript 4 revision 12.
 +
* If you are not using the command above, but are editing <code>fstab</code> by hand, be sure to remove (or comment out) the existing first line, which defines the <code>rootfs</code>.
  
 
== Installing a boot loader ==
 
== 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.
+
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.
 
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.
Line 93: Line 108:
 
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
  
chroot /mnt/install_root grub-install /dev/sda1
+
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
 
chroot /mnt/install_root grub-mkconfig -o /boot/grub/grub.cfg
  
umount /mnt/install_root/sys   # If mounted...
+
umount /mnt/install_root/{sys,proc,dev}</pre>
umount /mnt/install_root/proc # If mounted...
 
umount /mnt/install_root/dev</pre>
 
  
 
== Cleaning up ==
 
== Cleaning up ==
Line 108: Line 121:
  
 
<pre>umount /mnt/install_root
 
<pre>umount /mnt/install_root
rm -rf /mnt/install_root</pre>
+
rm&nbsp;-rf /mnt/install_root</pre>
  
 
Reboot your system, and enjoy your new OS:
 
Reboot your system, and enjoy your new OS:

Latest revision as of 19:21, 31 March 2019

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.