mayfrost-guides/INITIATION.md
2018-03-03 07:35:55 +00:00

12 KiB

Initiation Rite

This guide is for those wanting one of the two most beautiful source based distros, either CRUX or Source Mage GNU/Linux. It was written so it can be used by both, only diverging on particular details.

  • CRUX: A ports based, BSD style init scripts, distro following true KISS principles (Keep It Simple).
  • Source Mage GNU/Linux: Without 3rd party patches, sensible defaults or masked packages, free from obfuscated and pre-configured code, use clean dependencies as they came from upstream developers and can also use flags.

NOTE: This guide attempts to describe UEFI in detail side by side with BIOS. Also describes dualbooting (and triple booting) with the bootloader. If you feel overwhelmed for the amount of information don't be afraid, most of it is OPTIONAL, like password protection of the bootloader and the different filesystems the bootloaders can use.

TOC

  1. START
  2. PARTITIONING
  3. SETUP
    3.1. CHROOT
    3.2. CHANGE NETWORK INTERFACES
    3.3. EDIT FSTAB
    3.4. SET THE ENVIRONMENT
  4. KERNEL
  5. BOOTLOADER
    5.1. LILO
    5.2. SYSLINUX
    5.3. GRUB Legacy
    5.4. GRUB 2
  6. THE END
  7. CONFIGURATION ON CRUX
    7.1. ENABLE CONTRIB REPO
    7.2. ADD EXTERNAL REPOS
    7.3. INSTALL XORG
  8. CRUX COMMANDS
    8.1. AUTOMATED INSTALLATION OF PORTS
    8.2. MANUAL DOWNLOAD AND INSTALLATION
  9. SOURCE MAGE GNU/LINUX COMMANDS

START

Boot in UEFI mode if on UEFI, BIOS if on BIOS, and select installation media.

  • Make sure your network is up (OPTIONAL)
    dhcpcd <NIC>
  • Temporarily change keyboard (available configurations can be found in the directories "/usr/share/kbd/keymaps/" for CRUX and "/usr/share/keymaps/i386/qwerty" for Source Mage GNU/Linux)
    loadkeys <KEYMAP>

PARTITIONING

Supported filesystems by bootloaders are (if on UEFI ignore this as it only supports FAT):

  • LILO: indifferent (anything?)
  • SYSLINUX: ext2, ext3, ext4, btrfs, ufs 1/2, FAT16, FAT32, iso9660, udf, NTFS
  • GRUB Legacy: FAT16, FAT32, minix, ext2, ext3, ext4, ReiserFS, JFS, XFS, VSTa fs, Btrfs
  • GRUB 2: ext2, ext3, ext4, btrfs, zfs, ufs, minix, iso9660, udf, jfs, hfs, hfs+, afs, affs, sfs, xfs, reiserfs, tar, cpio, NTFS, FAT16, FAT32

In these examples we make only two partitions but you can extend this if you know how. The partitions are one root partition, later mounted to "/mnt/drive" with "mkfs.<ROOT_FILESYSTEM>" format, and one boot partition, later mounted to "/mnt/drive/boot" and with "mkfs.<BOOTLOADER_FILESYSTEM>" format unless is UEFI in which case "mkfs.vfat" is the only format available and will be mounted to "/mnt/drive/boot/efi" instead.

  • Use parted
    parted /dev/sda

  • Inside parted, if on UEFI label the disk "gpt", but if on BIOS label it "msdos"
    mklabel <LABEL>
    unit mb
    mkpart primary 0g 128
    mkpart primary 128 -1
    toggle 1 boot
    p free
    quit

  • Make root filesystem according to your personal preference
    mkfs.<ROOT_FILESYSTEM> /dev/sda2
    mkdir /mnt/drive
    mount /dev/sda2 /mnt/drive

  • Make boot filesystem according to supported bootloader or just "mkfs.vfat" if on UEFI
    mkfs.<BOOTLOADER_FILESYSTEM> /dev/sda1

  • If on BIOS make directory and mount
    mkdir /mnt/drive/boot
    mount /dev/sda1 /mnt/drive/boot

  • If on UEFI make directory and mount
    mkdir -p /mnt/drive/boot/efi
    mount /dev/sda1 /mnt/drive/boot/efi
    cd /mnt/drive
    mount --bind /dev /mnt/drive/dev
    mount --bind /sys /mnt/drive/sys
    mount -t proc none /mnt/drive/proc
    mount -t devpts none /mnt/drive/dev/pts

SETUP

  • On CRUX run "setup", and if on UEFI select on setup grub2-efi (if using GRUB 2), efibootmgr, and elfutils from opt (only select core, and say yes when you're asked if you want to select individual packages). And if you are not using LILO de-select it from core.
  • On Source Mage GNU/Linux get the tarball
    cd /mnt/drive
    wget -c "http://download.sourcemage.org/image/official/smgl-stable-<version>-basesystem-x86_64.<compression>"
    tar xvf smgl-stable-<version>-basesystem-x86_64.<compression>

CHROOT

  • Chroot specifying Bash in case live media has another shell
    chroot /mnt/drive /bin/bash
  • Change root password in chroot (TEST IF YOUR KEYBOARD HAS ALL THE CORRECT MAPPINGS before you change the password)
    passwd root

CHANGE NETWORK INTERFACES

  • On CRUX modify "/etc/rc.d/net" with the rules you want (IP, gateway, domain, etc)
  • On Source Mage GNU/Linux add preferred interfaces to "/etc/network/interfaces" for example
    auto eth0
    allow-hotplug eth0
    iface eth0 inet dhcp
  • On the "/etc/resolv.conf.head" file set your preferred DNS provider (this example is from OpenNIC)
    nameserver 193.41.79.236
  • Or copy "/etc/resolv.conf" to "/mnt/etc/resolv.conf" BEFORE chrooting

EDIT FSTAB

  • Change the "/etc/fstab" file with appropriate filesystems
    /dev/sda1 /boot <BOOTLOADER_FILESYSTEM> defaults 0 2
    /dev/sda2 / <ROOT_FILESYSTEM> noatime 0 1
  • On CRUX uncomment the lines referring to devpts, tmp, and shm as some programs require it (Firefox), also USB and or cdrom if using those
  • If on UEFI replace "/boot" with "/boot/efi"

SET THE ENVIRONMENT

  • On CRUX change the font, keyboard, timezone, hostname and services on the "/etc/rc.conf" file
    ls /usr/share/kbd/keymaps/
  • On Source Mage GNU/Linux change keymaps on the "/etc/sysconfig/keymap" file
    ls /usr/share/keymaps/i386/qwerty
  • On CRUX generate locales (change interface language)
    localedef -i <LOCALE> -f ISO-<CODE> <LOCALE>
  • On Source Mage GNU/Linux generate locales (change interface language)
    cast -r locale

KERNEL

  • Include the filesystem support the boot partition is format in.

  • Include UEFI options if on UEFI.

  • Include device drivers you need, build the rest as modules.

  • On CRUX
    cd /usr/src/linux-<VERSION>
    make all modules_install install

  • On Source Mage GNU/Linux (OPTIONAL)
    cast -r linux

BOOTLOADER

  • The drive where bootloaders and OSes are installed on these examples is "/dev/sda", but could be anywhere.
  • The bootloader installation IS inside chroot AND with drives mounted, so this guide assumes you are inside "/mnt/drive".
  • "<PARTITION_NUMBER_OF_DISTRO>", "<PARTITION_NUMBER_OF_FREEDOS>" and "<PARTITION_NUMBER_OF_WINDOWS>" are just the numbers of partitions.
  • The "vmlinuz" file makes reference to the kernel image, you can rename it or simlink to it in all cases, the only rule is you have to make sure the name is referenced correctly in the bootloader. By default it can have names like "vmlinuz-linux", "vmlinuz-<KERNEL_VERSION>" and so on. The same with "initramfs.img", it can be "initramfs-<KERNEL_VERSION>.img" and such.
  • All bootloader examples have included other OS inside what is called "stanzas".
  • FreeDOS and Windows stanzas are OPTIONAL.
  • If dualbooting with Windows remember that it likes to be in the first partition.
  • If on UEFI check if module is loaded by issuing "modprobe efivars".
  • On CRUX do "prt-get remove lilo" if you dont use LILO.
  • On Source Mage GNU/Linux do "cast <BOOTLOADER>" to install the preferred bootloader.

LILO

  • If on UEFI use elilo and change names to "/etc/elilo.conf" instead of "/etc/lilo.conf" and "elilo" instead of "lilo" in commands
    nano /etc/lilo.conf
  • Inserting "password=<PASSWORD>" inside an OS stanza will protect with a password that OS, but inserting "password=<PASSWORD>" just before the stanzas and outside any of them will protect with a password the bootloader itself (notice the space inside stanzas)
    boot = /dev/sda
    image = /boot/vmlinuz
    Label = <DISTRO_NAME>
    root = /dev/sda<PARTITION_NUMBER_OF_DISTRO>
    other = /dev/sda<PARTITION_NUMBER_OF_FREEDOS>
    table = /dev/sda
    Label = FreeDOS
    other = /dev/sda<PARTITION_NUMBER_OF_WINDOWS>
    table = /dev/sda
    Label = Windows7
  • Set boot entry
    lilo -A /dev/sda 1
    lilo
  • Prevent anyone but root of reading the config file (in case you used a password)
    chmod 600 /etc/lilo.conf

THE END

  • Exit the chroot
    exit
  • Shutdown the machine
    shutdown -h now

And done.

CONFIGURATION ON CRUX

ENABLE CONTRIB REPO

  • Enable contrib for ports
    cd /etc/ports
    mv contrib.rsync.inactive contrib.rsync
  • Enable contrib for prt-get
    nano /etc/prt-get.conf
  • Uncomment line "prtdir /usr/ports/contrib"

ADD EXTERNAL REPOS

  • Download httpup/rsync file and pub file
    cd /etc/ports/
    wget -c <URL>

  • Add repo location to "/etc/prt-get.conf" (order sets precedence)
    nano /etc/prt-get.conf

  • Add line "prtdir /usr/ports/<REPO>"

  • Populate repo
    ports -u <REPO>

  • Enable pre-/post-install scripts in "/etc/prt-get.conf" (usually safe to run repeatedly, usually used to rebuild caches and add system users when installing certain software)
    nano /etc/prt-get.conf

  • Uncomment line "runscripts yes"

  • Ignore footprint mismatches due to new files (usually not a bad thing)
    nano /etc/pkgmk.conf

  • Set line "PKGMK_IGNORE_NEW="yes""

INSTALL XORG

  • Install a minimal set of xorg and xorg dependent tools one by one prtget depinst xorg-server xorg-xf86-video-<DRIVER> xorg-font-<FONT> xkeyboard-config xorg-xinit
  • Alternatively just install the metapackage "xorg"

CRUX COMMANDS

AUTOMATED INSTALLATION OF PORTS

  • Populate ports tree (is empty by default)
    ports -u
  • Automatically download and build a package with its required dependencies ignoring signature mismatch
    prt-get -in depinst <PORT>
  • Remove a package
    prt-get remove <PORT>
  • Search package
    prt-get search <PORT>
  • Get info from package
    prt-get info <PORT>
  • Get dependency info from package
    prt-get depends <PORT>
  • Update all packages
    prt-get sysup
  • List all installed packages
    pkginfo -i

MANUAL DOWNLOAD AND INSTALLATION

  • Go to apropriate directory for all these tasks
    cd to /usr/ports/<REPO>/<PORT>
  • To download a package
    pkgmk -d <PORT>
  • To install a downloaded package
    pkgmk -i <PORT>
  • In case of signature mismatch
    pkgadd -f <PORT>
  • To clean directory from downloaded package and build
    pkgadd -c <PORT>
  • To remove installed package
    pkgrm <PORT>

SOURCE MAGE GNU/LINUX COMMANDS

  • To get a manual
    cast smgl-setup
    man smgl-setup
  • To change general things like the color scheme
    sorcery
  • To update the package manager
    sorcery update
  • To update the package list
    scribe update
  • To check for any changes in the architecture specs
    cast smgl-archspecs
  • To rebuild everything from source
    sorcery rebuild
  • To recompile the kernel
    cast -r linux
  • To get a list of spells needing upgrade
    sorcery -q
  • To upgrade the spells themselves known to be available for upgrade
    cast --queue
  • To check for broken installations
    cleanse --fix
  • After casting new spells you need this to have apropos, man -k, and whatis
    makewhatis
  • To install new packages
    cast <spell>
  • To update an existing package
    cast <spell>
  • To search for packages
    gaze search <spell>
  • To search by package name
    gaze search -name <spell>
  • To list installed packages
    gaze installed
  • To remove a spell
    dispel <spell>
  • To delete completely a package
    dispel --nosustain <spell>
  • To list repositories
    scribe index
  • To add a repository
    scribe add <grimoire>
  • To remove a repository
    scribe remove <grimoire>