#!/bin/bash source colors.sh export LFS="$1" if [[ -z "${LFS}" ]]; then printf "%b" " ${IGRN}preparechroot.sh${RST}: ${IRED}Require first argument as path to LFS build!${RST}\n" exit 1 fi if [[ -f chrootprepared ]]; then printf "%b" " ${IRED}CHROOT ${IGRN}already prepared\n${RST}" else printf "%b" "${GRN}Changing ownership to root...${RST}\n" { sudo chown -v root:root "${LFS}" sudo chown -Rv root:root "${LFS}"/bin sudo chown -Rv root:root "${LFS}"/etc sudo chown -Rv root:root "${LFS}"/lib sudo chown -Rv root:root "${LFS}"/sbin sudo chown -Rv root:root "${LFS}"/tools sudo chown -Rv root:root "${LFS}"/usr sudo chown -Rv root:root "${LFS}"/var case $(uname -m) in x86_64) sudo chown -Rv root:root "${LFS}"/lib64 ;; esac } >"${LFS}"/sources/log/preparechroot.log 2>&1 printf "%b" "${GRN}Creating virtual kernel filesystem mountpoints...${RST}\n" { sudo mkdir -pv "${LFS}"/dev sudo mkdir -pv "${LFS}"/proc sudo mkdir -pv "${LFS}"/run sudo mkdir -pv "${LFS}"/sys } >>"${LFS}"/sources/log/preparechroot.log 2>&1 printf "%b" "${GRN}Creating initial device nodes...${RST}\n" { sudo mknod -m 600 "${LFS}"/dev/console c 5 1 sudo mknod -m 666 "${LFS}"/dev/null c 1 3 } >>"${LFS}"/sources/log/preparechroot.log 2>&1 source mountvirtfs.sh touch chrootprepared fi