Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-05-2010, 09:09 PM   #1
Senior Member
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Rep: Reputation: 56
Chroot in shell scripts: Ensuring that subsequent commands execute within the chroot

I currently am writing a shell script to install and configure a full system without Ubiquity and have run into a roadblock: When the script gets to the chroot (that being "sudo chroot <install drive mount point>, inside the chroot nothing happens. It just leaves me with the main prompt. Any ideas on how to fix this?
Old 09-06-2010, 02:09 PM   #2
Registered: May 2001
Posts: 29,370
Blog Entries: 55

Rep: Reputation: 3555Reputation: 3555Reputation: 3555Reputation: 3555Reputation: 3555Reputation: 3555Reputation: 3555Reputation: 3555Reputation: 3555Reputation: 3555Reputation: 3555
The manual page says 'chroot NEWROOT [COMMAND...]' as in 'sudo chroot echo "Hello World!";'? meaning you can either run a command directly or drop a shell script in the chroot and execute that.
Old 05-21-2012, 12:25 PM   #3
Bedrock Linux Advocate
Registered: Nov 2004
Location: the internet
Distribution: Gentoo mostly, currently. Bedrock Linux (+gentoo,+others) again, soon.
Posts: 198

Rep: Reputation: 62
sry for being slow with this.

just to clarify,
so where one might normally add /bin/bash, one can replace it with a script?

like in my case the line:
chroot /mnt/$DISTRONAME /bin/bash
chroot /mnt/$DISTRONAME witchroot
witchroot being the script i had just generated.

does that seem right?

or would the ~ no, i'll simply ask that^ before i get any more confused.

...also... i wonder if there's a way (~sorry, perhaps veering somewhat off-topic with this~) to pass variables to the chrooted environment too. is there?


chroot, maverick meerkat, shell script

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
chroot: cannot execute /bin/sh: Exec format error jnojr Linux - General 8 06-24-2012 12:52 AM
[SOLVED] in chroot compiled programs do not work in chroot graphit Linux From Scratch 2 04-11-2010 03:04 AM
start init.d scripts before a chroot script using schroot? arobinson74 Linux - Software 1 10-11-2009 04:05 PM
chroot to run hd-installed distro's programs from chroot in live distro? silencestone Linux - Software 0 10-12-2007 06:29 AM
wu-ftp help with chroot - ls command does not execute bock Linux - Software 2 09-18-2002 01:47 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:37 AM.

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