Core OS Index

1.4. Prepare for Reboot

Follow this instructions with active chroot, first mount partitions and before chroot mount follow file systems;

        $ sudo mount --bind /dev $CHROOT/dev
        $ sudo mount -vt devpts devpts $CHROOT/dev/pts
        $ sudo mount -vt tmpfs shm $CHROOT/dev/shm
        $ sudo mount -vt proc proc $CHROOT/proc
        $ sudo mount -vt sysfs sysfs $CHROOT/sys
        

Now you can chroot;

        $ sudo chroot $CHROOT /usr/bin/env -i \
          HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
          PATH=/bin:/usr/bin:/sbin:/usr/sbin \
          /bin/bash --login
        

1.4.1. Kernel

Install linux-gnu port, linux libre kernel is a true source based kernel that respects your freedoms. Read linux kernel for more information.

Default crux configuration can be obtained from iso, kernel port depend on dracut, grub2 and grub2-efi. You don't need them to build with pkgmk, to install boot related tools use prt-get;

	$ prt-get depinst linux-gnu
	

If you don't have the port binary package build it;

        # cd /usr/ports/c9-ports/linux-gnu
        # pkgmk -d
        

Install kernel;

        # pkgadd /usr/ports/packages/linux-gnu#4.9.86-2.pkg.tar.gz
        

1.4.2. Dracut

Install dracut;

        # cd /usr/ports/c9-ports/dracut
        # pkgmk -d
        # pkgadd /usr/ports/packages/dracut#044-2.pkg.tar.gz
        

Review configuration file;

        # PUT YOUR CONFIG IN separate files
        # in /etc/dracut.conf.d named ".conf"

        # Equivalent to -H
        hostonly="no"

        # Mount / and /usr read-only by default.
        ro_mnt="no"

        # Equivalent to -m "module module module"
        dracutmodules+="dash kernel-modules rootfs-block udev-rules usrmount base fs-lib shutdown"

        # Equivalent to -a "module"
        add_dracutmodules+="caps debug"

        # Equivalent to -o "module"
        #omit_dracutmodules+="systemd systemd-bootchart systemd-networkd systemd-initrd"

        # SEE man dracut.conf(5) for options
        

Run dracut to create init ram filesystem for port linux-blob kernel;

        # dracut --kver 4.9.86-gnu
        

1.4.3. Grub

Create grub file in /etc/default/grub with values;

        GRUB_DISABLE_LINUX_UUID=false
        GRUB_ENABLE_LINUX_LABEL=false
        

Grub Manual, install grub on MBR of disk sdb;

        # grub-install /dev/sdb
        Installation finished. No error reported.
        

If you are installing on removable media;

        # grub-install --removable /dev/sdb
        Installation finished. No error reported.
        

grub-mkconfig generates grub.cfg, it will try to discover available kernels and attempt to generate menu entries for them;

        # grub-mkconfig -o /boot/grub/grub.cfg
        Generating grub.cfg ...
        Found linux image: /boot/vmlinuz-4.9.86-gnu
        Found initrd image: /boot/initramfs-4.9.86-gnu.img
        done
        #
        

Check /boot/grub/grub.cfg, if is wrong add menu to /etc/grub.d/40_custom, replace correct partition from grub-prob output and correct UUID from fstab or blkid

        # grub-probe --target=hints_string /
        

1.4.3.1. Rescue iso

Simple way to have "resque" system is to mount boot as read only, this assures that even as root nothing can be changed without remount. To have different system independent from host grub will have entry to boot small iso on /boot partition;

Crux iso is not used because at the moment it fails to find "crux-media" during or after init.

        $ wget http://ftp.nluug.nl/os/Linux/distr/tinycorelinux/7.x/x86/release/CorePlus-current.iso
        $ sudo mv CorePlus-current.iso /boot/tinycore.iso
        

Edit /etc/grub.d/40_custom


        menuentry "Rescue" {
            load_video
            set gfxpayload=keep

            set isofile="/tinycore.iso"
            loopback loop $isofile
            linux (loop)/boot/vmlinuz64 loglevel=3 cde
            initrd (loop)/boot/corepure64.gz
        }
        

1.4.4. Checkup

If you have qemu installed you can see if it boots, in this example sdb is usb external drive;

        # qemu-system-x86_64 -kernel /boot/vmlinuz-linux -initrd /boot/initramfs-linux.img -append root=/dev/sdb /dev/sdb2
        

Debug Grub

Debug initram

        /usr/lib/dracut/skipcpio /boot/initramfs-4.9.86-gnu.img | gunzip -c | cpio -i -d
        36875 blocks
        
Core OS Index

This is part of the c9-doc Manual. Copyright (C) 2017 c9 team. See the file Gnu Free Documentation License for copying conditions.