LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Script to enter Chroot Environment (https://www.linuxquestions.org/questions/linux-from-scratch-13/script-to-enter-chroot-environment-525564/)

kz_chopper 02-04-2007 03:28 PM

Script to enter Chroot Environment
 
I created this file, chroot.sh to enter the chroot environment after a reboot. I saved it as root to / (You will need to change the mount command to reflect your system)
Code:

#!/bin/sh
# Enter the chroot environment
export LFS=/mnt/lfs
mount -t ext3 /dev/hda4 $LFS
mount --bind /dev $LFS/dev
mount -vt devpts devpts $LFS/dev/pts
mount -vt tmpfs shm $LFS/dev/shm
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
chroot "$LFS" /tools/bin/env -i \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /tools/bin/bash --login +h

Then...

Code:

chmod u+x chroot.sh
To run...

Code:

./chroot.sh

stress_junkie 02-05-2007 08:08 AM

Thanks. That's very nice of you. :)

biniou 02-09-2007 03:30 AM

And after entering chroot, don't forget to populate /dev (common cause of errors ...)

Daws 02-09-2007 05:44 AM

Quote:

And after entering chroot, don't forget to populate /dev (common cause of errors ...)
?
?
?

Me thinks its bedtime for you... If you actually LOOK at the script above you will see

"mount --bind /dev $LFS/dev" BEFORE chrooting. :rolleyes: :rolleyes: :rolleyes:

biniou 02-09-2007 06:07 AM

Yep, you're right, should go to bed !!! I skipped this line !

Sometimes I should just shut up ... :p

yjy4321 02-17-2013 03:06 PM

After export and before mount, you need to make the directory $LFS.

spiky0011 02-17-2013 03:23 PM

Hi yjy4321

Are you asking a Qustion or answering this 5year old post???


All times are GMT -5. The time now is 03:28 PM.