LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 09-05-2010, 09:09 PM   #1
Kenny_Strawn
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
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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
Siljrath
Bedrock Linux Advocate
 
Registered: Nov 2004
Location: the internet
Distribution: server:Gentoo | workstation:Bedrock (hijacked:void, fetched:Gentoo,Devuan,Artix)
Posts: 226

Rep: Reputation: 66
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:
Code:
chroot /mnt/$DISTRONAME /bin/bash
becomes
Code:
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?
 
  


Reply

Tags
chroot, maverick meerkat, shell script



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:52 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
Open Source Consulting | Domain Registration