LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 02-04-2007, 03:28 PM   #1
kz_chopper
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, 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

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

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Thanks. That's very nice of you.
 
Old 02-09-2007, 03:30 AM   #3
biniou
Member
 
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
Daws
Member
 
Registered: May 2006
Location: UK
Distribution: Debian, Linux From Scratch
Posts: 416
Blog Entries: 1

Rep: Reputation: 30
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.
 
Old 02-09-2007, 06:07 AM   #5
biniou
Member
 
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
yjy4321
Member
 
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
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: Ubuntu 12.04/12.10/13.04/LFS/Centos6.3/Debain/PCBSD/Mageia 3
Posts: 1,655
Blog Entries: 1

Rep: Reputation: 242Reputation: 242Reputation: 242
Hi yjy4321

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


Reply


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 rikpotts 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 05:05 PM.

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