LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 02-24-2013, 11:29 PM   #1
leader1201
LQ Newbie
 
Registered: Feb 2013
Posts: 22

Rep: Reputation: Disabled
Need help on executing chroot command


Hi all,

I am trying to execute chroot command by changing the root in ubuntu machine.

Let me explain the situation.
I was mounted an ubuntu image in /mnt/ubuntu directory using follwoing command :
mount /dev/mapper/loop1p1 /mnt/ubuntu
it was successfully executed. so finally i want to install new package in the ubuntu image which is ther /mnt/ubuntu . In order to execute the chroot command i was setting chroot environment by following commands:

mount -o bind /dev /mnt/ubuntu/dev
mount -o bind /proc /mnt/ubuntu/proc
mount -o bind /sys /mnt/ubuntu/sys


The above commands also executing successfully.
finally i am trying to install linux-image kernel package on mounted image which is there in /mnt/ubuntu.

chroot /mnt/ubuntu dpkg -i tmp/linux-image.deb
chroot: failed to run command `dpkg': No such file or directory

this is the error i am getting .
please help me.

regards,
Prasad.
 
Old 02-24-2013, 11:34 PM   #2
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.0
Posts: 583
Blog Entries: 2

Rep: Reputation: 76
I think you would have to mount -o bind whatever directory dpkg is in.
 
Old 02-24-2013, 11:35 PM   #3
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,275

Rep: Reputation: 668Reputation: 668Reputation: 668Reputation: 668Reputation: 668Reputation: 668
Try passing the location of dpkg explicitly. Otherwise, try chrooting into it and executing the command manually so you can see what's happening.
Code:
# chroot /mnt/ubuntu
# /usr/bin/dpkg -i /tmp/linux-image.deb
 
Old 02-24-2013, 11:59 PM   #4
leader1201
LQ Newbie
 
Registered: Feb 2013
Posts: 22

Original Poster
Rep: Reputation: Disabled
Hi T3slider,

I have tried both the cases which you mentioned in the comments.

chroot /mnt/ubuntu /usr/bin/dpkg /tmp/linux-image.deb
chroot: failed to run command `/usr/bin/dpkg': No such file or directory

second option :
first i have this command . this command it self showing error.
chroot /mnt/ubuntu
chroot: failed to run command `/bin/bash': No such file or directory

regards,
prasad.
 
Old 02-25-2013, 05:31 PM   #5
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,275

Rep: Reputation: 668Reputation: 668Reputation: 668Reputation: 668Reputation: 668Reputation: 668
I think you need to have a look in /mnt/ubuntu when it's mounted -- it seems it does not contain files necessary for chrooting (or booting). Either some important directory is not being mounted, or you do not have a complete Ubuntu install on /dev/mapper/loop1p1.
 
Old 02-25-2013, 09:28 PM   #6
leader1201
LQ Newbie
 
Registered: Feb 2013
Posts: 22

Original Poster
Rep: Reputation: Disabled
Today i will change the ubuntu image and try again.
 
Old 02-26-2013, 07:20 AM   #7
leader1201
LQ Newbie
 
Registered: Feb 2013
Posts: 22

Original Poster
Rep: Reputation: Disabled
chroot /mnt/ubuntu it self fails

hi ,

i am unable to execute the chroot /mnt/ubuntu command this command showing following error.

chroot: failed to run command `/bin/bash': No such file or directory

please help me.

regards,
Prasad.
 
Old 02-26-2013, 07:29 AM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,597
Blog Entries: 2

Rep: Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058
As said before, check the directory for existance of /bin/bash, it seems that you don't have a fully functional install in that image.
 
Old 02-26-2013, 07:42 AM   #9
leader1201
LQ Newbie
 
Registered: Feb 2013
Posts: 22

Original Poster
Rep: Reputation: Disabled
first i have taken one ubuntu image which is ubuntu-flat.vmdk .
this i have converted into raw format using qemu converter

qemu-img convert ubuntu-flat.vmdk -O raw ubuntu-flat.raw

i find out the free loop device . suppose i have taken loop5 in /dev/loop5 location.

losetup /dev/loop5 ubuntu-flat.raw.
kpartx -a /dev/loop5
mkdir /mnt/ubuntu
mount /dev/mapper/loop5p1 /mnt/ubuntu
mount -o bind /dev /mnt/ubuntu/dev (for this befor i have created dev directory in the /mnt/ubuntu location manually)
mount -o bind /proc /mnt/ubuntu/proc(proc also created before executing)
mount -o bind /sys /mnt/ubuntu/sys(sys also created before executing)

next i am trying to execute
chroot /mnt/ubuntu dpkg -i /tmp/somepackage.deb

Problems coming now as i mentioned above.

so is there any wrong procedure i am following .

regards,
prasad
 
Old 02-26-2013, 09:34 AM   #10
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,597
Blog Entries: 2

Rep: Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058
After you mount the Ubuntu image, just check, using ls, if /bin/bash is present in the image:
Code:
ls -l /mnt/ubuntu/bin/bash
 
Old 02-26-2013, 11:03 PM   #11
leader1201
LQ Newbie
 
Registered: Feb 2013
Posts: 22

Original Poster
Rep: Reputation: Disabled
its not there in that image.

ls /mnt/server/bin/bash
ls: cannot access /mnt/server/bin/bash: No such file or directory
 
Old 02-26-2013, 11:31 PM   #12
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,597
Blog Entries: 2

Rep: Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058Reputation: 4058
Then the image is most likely not a complete system image and chrooting into it won't work.
 
Old 03-04-2013, 12:32 AM   #13
leader1201
LQ Newbie
 
Registered: Feb 2013
Posts: 22

Original Poster
Rep: Reputation: Disabled
yes, My image gets corrupted and i have taken new image.I followed same procedure as i written in previous.
This time i am able to perform chroot command.
 
  


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
host: dst_lib_init: openssl failure in chroot jail when executing host binary golden_boy615 Linux - General 0 09-10-2012 07:16 AM
Executing Command on Remote Windows System from a Local Windows Command Prompt devUnix General 8 05-30-2012 07:51 AM
Executing shell command from JSP file with command line arg from URL orcusomega Programming 2 01-13-2012 03:38 PM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 11:21 AM
mount command not working in chroot. and now chroot not working mohit.jain Linux From Scratch 5 07-14-2006 03:57 AM


All times are GMT -5. The time now is 09:01 AM.

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