Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.


  Search this Thread
Old 02-04-2007, 03:28 PM   #1
LQ Newbie
Registered: Feb 2007
Location: Halifax
Distribution: Debian Etch & Lenny
Posts: 14

Rep: Reputation: 0
Script to enter Chroot Environment

I created this file, 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)
# 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

chmod u+x
To run...


Last edited by kz_chopper; 02-04-2007 at 03:43 PM.
Old 02-05-2007, 08:08 AM   #2
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Thanks. That's very nice of you.
Old 02-09-2007, 03:30 AM   #3
Registered: Feb 2007
Location: Belgium
Distribution: Ubuntu (7.04), (B)LFS (6.2), ...
Posts: 105

Rep: Reputation: 15
And after entering chroot, don't forget to populate /dev (common cause of errors ...)
Old 02-09-2007, 05:44 AM   #4
Registered: May 2006
Location: UK
Distribution: Debian
Posts: 448

Rep: Reputation: 37
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.
Old 02-09-2007, 06:07 AM   #5
Registered: Feb 2007
Location: Belgium
Distribution: Ubuntu (7.04), (B)LFS (6.2), ...
Posts: 105

Rep: Reputation: 15
Yep, you're right, should go to bed !!! I skipped this line !

Sometimes I should just shut up ...
Old 02-17-2013, 03:06 PM   #6
Registered: Apr 2011
Distribution: Ubuntu
Posts: 42

Rep: Reputation: Disabled
After export and before mount, you need to make the directory $LFS.
Old 02-17-2013, 03:23 PM   #7
Senior Member
Registered: Jan 2011
Distribution: /LFS/Centos6.3/Debian
Posts: 2,074
Blog Entries: 1

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
Hi yjy4321

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't enter into X- Desktop Environment shipon_97 Linux - Newbie 2 12-09-2006 08:36 AM
enter chroot for blfs devavictrix Linux From Scratch 3 03-02-2006 12:01 PM
Cannot Enter chroot /usr/bin/env directory not found Zero-0-Effect Linux From Scratch 2 03-13-2004 12:41 PM
Out of the chroot environment? R2RO Linux - Networking 0 05-14-2003 04:01 PM
Getting in and out and in again in the CHROOT environment? kRu_ZaDeR Linux From Scratch 8 01-13-2003 12:20 AM

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration