LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 02-08-2004, 03:28 PM   #1
shanenin
Member
 
Registered: Aug 2003
Location: Rochester, MN, U.S.A
Distribution: Gentoo
Posts: 987

Rep: Reputation: 30
bash shell script problem


I am trying to write a script that will mount my partiton, chroot into my mounted partition, then mount proc and devpts from with in the chroot environment. Here is what I have.
Code:
#! /bin/bash
mount /dev/hda6 /mnt/lfs -o atime
chroot /mnt/lfs /usr/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
mount proc /proc -t proc
mount devpts /dev/pts -t devpts
It is not working the way I want it to. It mounts my partition and chroots into it but the last two commands after the chroot command and not getting executed. It is giving me no output, as if the last two command are not being executed.

I tried an experiment I wrote this script
Code:
mount /dev/hda6 /mnt/lfs -o atime
chroot /mnt/lfs /usr/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
echo "test"
in my second experiment script the word test is not being echoed. It gets as far as mounting the partition and chrooting into it, but stops, not executing the line echo "test".

Both of my scripts are not getting past the chroot line, that seems to be the problem. Any input would be appreciated.
 
Old 02-08-2004, 03:50 PM   #2
bnice
Member
 
Registered: Feb 2004
Location: Sacramento, CA
Distribution: Slack 9.1, slackware-current
Posts: 284

Rep: Reputation: 30
Re: bash shell script problem

Quote:
Originally posted by shanenin
I am trying to write a script that will mount my partiton, chroot into my mounted partition, then mount proc and devpts from with in the chroot environment. Here is what I have.
Code:
#! /bin/bash
mount /dev/hda6 /mnt/lfs -o atime
chroot /mnt/lfs /usr/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
mount proc /proc -t proc
mount devpts /dev/pts -t devpts
.
Try this:

Code:
#! /bin/bash
mount /dev/hda6  -o atime
mount proc /mnt/lfs/proc -t proc
mount devpts /mnt/lfs/dev/pts -t devpts
chroot /mnt/lfs /usr/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
 
Old 02-08-2004, 04:33 PM   #3
shanenin
Member
 
Registered: Aug 2003
Location: Rochester, MN, U.S.A
Distribution: Gentoo
Posts: 987

Original Poster
Rep: Reputation: 30
thanks for the effort, it is still not mounting my proc and devpts file systems. Do I need to be in the chroot enviroment to mount those to systems?
 
Old 02-09-2004, 05:10 PM   #4
bnice
Member
 
Registered: Feb 2004
Location: Sacramento, CA
Distribution: Slack 9.1, slackware-current
Posts: 284

Rep: Reputation: 30
Quote:
Originally posted by shanenin
thanks for the effort, it is still not mounting my proc and devpts file systems. Do I need to be in the chroot enviroment to mount those to systems?
No, I think you need to mount them first, otherwise / isn't /, it's /mnt/lfs/ and absolute paths will break.

I screwed up the order in the last post...(blush)
It should go like this:

#! /bin/bash
mount /dev/hda6 -o atime
mount -t proc proc /mnt/lfs/proc
mount -t devpts devpts /mnt/lfs/dev/pts
chroot /mnt/lfs /usr/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
 
Old 02-09-2004, 06:57 PM   #5
stirling
Member
 
Registered: Feb 2004
Distribution: LFS, Ubuntu
Posts: 52

Rep: Reputation: 16
any commands after the chroot command will be executed after you exit the chroot environment.

you could add these to your /mnt/lfs/root/.bash_profile to get what you're expecting
mount proc /proc -t proc
mount devpts /dev/pts -t devpts
 
Old 02-09-2004, 10:22 PM   #6
shanenin
Member
 
Registered: Aug 2003
Location: Rochester, MN, U.S.A
Distribution: Gentoo
Posts: 987

Original Poster
Rep: Reputation: 30
I made one command called lfs: it mounts and chroots me. Once I am in the chroot environment I made a command lfsm to mount those two file systems.

Thanks for everyones help
 
  


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
help with bash shell script !! taiwf Linux - Newbie 5 06-11-2006 07:07 PM
bash shell script problem sorno Programming 1 07-30-2005 06:02 AM
bash shell script problem evilchild Programming 7 02-08-2004 11:09 PM
bash/shell script mikis Programming 2 10-14-2003 12:39 PM
bash shell script MaryM Linux - Newbie 0 02-16-2002 12:45 AM


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

Main Menu
Advertisement
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