gentoo:install_gentoo_in_lfs

아래의 내용 중 VERSION에서 Gentoo_HOME까지의 내용중 필요한 것을 수정해서 사용하시면 됩니다.

#!/bin/bash
# Begin auto-lfs
#
# For Gentoo 12.1-systemd
# you can use it after proceeding with <7.2 Changing Owner> 
# Mount and unmount kernel virtual file system and entering to chroot environment

VERSION=0.1.7
Gentoo=/mnt/gentoo
Gentoo_PART=/dev/nvme0n1p10
Gentoo_BOOT=/dev/nvme0n1p6
Gentoo_EFI=/dev/nvme0n1p2
Gentoo_HOME=/dev/nvme0n1p7
# Dedicated partition mount argument is s , -s , start
if [ "$1" == "s" ] || [ "$1" == "-s" ] || [ "$1" == "start" ]; then
        if ! mountpoint -q $Gentoo;          then mount $Gentoo_PART $Gentoo; fi
        if ! mountpoint -q $Gentoo/boot;     then mount $Gentoo_BOOT $Gentoo/boot; fi
        if ! mountpoint -q $Gentoo/boot/efi; then mount $Gentoo_EFI $Gentoo/boot/efi; fi
        if ! mountpoint -q $Gentoo/home;     then mount $Gentoo_HOME $Gentoo/home; fi
        if ! mountpoint -q /mnt/n40l/Gentoo; then mount n40l:/mnt/1st-bay/Gentoo /mnt/n40l/Gentoo; fi

        # Mount point dirctory check
        if [ ! -d $Gentoo/dev ]; then
                echo "Make necessary directories"
                mkdir -pv $Gentoo/{dev,proc,sys,run}
        else
                echo "All required directories have been verified."
        fi
fi
# To prepare for run 'chroot', run 'umount' block if a directory exists, or run 'mount' block
case $1 in
    clean|c|-c)
        if mountpoint -q $Gentoo; then
            # Unmount Kernel Virtual File System used in previous Gentoo sessions.
            echo "Gentoo is now set to '"$Gentoo"'"
            echo "Now proceed with the unmount of <Kernel Virtual File System> for chroot"
            umount -q -l $Gentoo/dev/{shm,pts}
            umount -q -R $Gentoo
            sleep 10
            for kvfs in dev/shm dev/pts sys proc run dev ; do
                    if mountpoint $Gentoo/$kvfs; then umount -q $Gentoo/$kvfs; fi
            done
            findmnt -o FSTYPE,SIZE,USED,AVAIL,USE%,TARGET | grep lfs
            echo "Ok unmount unnecessary devices"
            echo "Good bye"
            exit 0
        else
            echo "Cleanup of Kernel Virtual File System is Complete."
            findmnt -o FSTYPE,SIZE,USED,AVAIL,USE%,TARGET | grep gentoo
            exit 0
        fi
    ;;
    start|s|-s)
        # Mount the Kernel Virtual File System to Enter Gentoo chroot environment.
        echo "Now proceed with the mount of <Kernel Virtual File System> for chroot"
        echo "Gentoo is now set to '"$Gentoo"'"
        if ! mountpoint -q $Gentoo/proc; then mount --type proc /proc $Gentoo/proc; fi
        if ! mountpoint -q $Gentoo/dev; then mount --rbind /dev $Gentoo/dev; mount --make-rslave $Gentoo/dev; fi
        if ! mountpoint -q $Gentoo/sys; then mount --rbind /sys $Gentoo/sys; mount --make-rslave $Gentoo/sys; fi
        if ! mountpoint -q $Gentoo/run; then mount --rbind /run $Gentoo/run; mount --make-rslave $Gentoo/run; fi
        if ! mountpoint -q $Gentoo/mnt/Gentoo; then mount --rbind /mnt/n40l/Gentoo $Gentoo/Gentoo; fi
        findmnt -o FSTYPE,SIZE,USED,AVAIL,USE%,TARGET | grep gentoo
        # Run 'chroot'
        chroot "$Gentoo" $(type -p env) -i \
            HOME=/root                  \
            TERM="$TERM"                \
            PS1='<Gentoo> \u@\h [ \w ] \$ '\
            PATH=/usr/bin:/usr/sbin     \
            MAKEFLAGS="-j$(nproc)"      \
            TESTSUITEFLAGS="-j$(nproc)" \
            NINJAJOBS="$(nproc)"        \
            /bin/bash --login
        exit 0
    ;;
    version|v|-v)
        echo "Gentoo chroot script $VERSION"
        exit 0
    ;;
    help|h|-h)
        echo "Gentoo chroot script $VERSION"
        echo "Usage:"
        echo "clean   or c- Unmount Kernel Virtual File System"
        echo "start   or s- Mount and run 'chroot' command with necessary variables"
        echo "version or v- Print script version"
        echo "help    or h - This screen"
        exit 0
    ;;
    *)
        #Guidance on the factors needed to execute script
        echo "sh ./Auto_Gentoo.sh [ start | clean | help | version ]"
        exit 0
    ;;
esac

  • gentoo/install_gentoo_in_lfs.txt
  • 마지막으로 수정됨: 2024/05/08 00:11
  • 저자 baecy