LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 01-14-2023, 01:30 AM   #1
cola
Senior Member
 
Registered: Sep 2007
Posts: 1,045

Rep: Reputation: 65
How can I chroot to some partition?


I have compiled and installed glibc, ncurses, bash in /mnt/lfs.
I have installed in this way:
Code:
./configure --prefix=/mnt/lfs/usr
make
make install
Now when I try to chroot /mnt/lfs /usr/bin/bash --login, I get error:
Code:
chroot: failed to run command ‘/usr/bin/bash’: No such file or directory
Why am I getting this error?

Running ldd command has the following output:
Code:
ldd /mnt/lfs/usr/bin/bash
	linux-vdso.so.1 (0x00007fffc70ab000)
	libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007fb0e6689000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb0e6683000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb0e64ae000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fb0e6818000)
 
Old 01-14-2023, 04:14 AM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,650
Blog Entries: 19

Rep: Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480Reputation: 4480
If you are making an LFS system, you must make it step by step exactly as the book says. You can't just install a few packages and expect to be able to chroot.

With the current LFS release , you start chrooting in Chapter 7, by which time you have a lot more compiled than just glibc, ncurses and bash! And you need a more complicated chroot command with some preset environmental values. See https://www.linuxfromscratch.org/lfs...07/chroot.html.

btw I think this thread should be in the LFS forum. Try self-reporting and asking the mods to move it.

Last edited by hazel; 01-14-2023 at 04:16 AM.
 
Old 01-23-2023, 09:45 AM   #3
derguteweka
Member
 
Registered: Sep 2018
Distribution: BLFS
Posts: 74

Rep: Reputation: 21
Moin,

Quote:
Originally Posted by cola View Post
Why am I getting this error?
At least one of the libraries/files mentioned by your ldd command seems to be not present where suspected by ldd.
You might check that and copy them by hand to the desired locations. But even if you mange to run the bash binary in your chroot - there will be many other things missing, preventing you from doing something useful with your bash.

cheers,
WK
 
Old 01-29-2023, 06:52 PM   #4
xlfs-0.2
Member
 
Registered: Oct 2022
Posts: 207

Rep: Reputation: 44
> chroot: failed to run command ‘/usr/bin/bash’: No such file or directory

If you check the source of chroot.c you find it prints that message on any failure.

I assume you already checked that /usr/bin/bash is installed (usually in /bin/sh btw).

Probably the failure is your /lib /lib64 are wrong (if glibc cannot load that binary you will get the message seen: try strace you'll see)

If your lucky, delete 'ld.so.cache', try again. maybe your cache is incorrect, so let ld search when loading.

TIP: try

$ chroot /foo path-to/ldconfig

Why try that? Because it is different from other binaries it doesn't need to (load libraries to run). If it runs it means your chroot is parly working but broken and strace can show what doesn't load. If it doesn't run: your chroot is totally broken if ldconfig cannot run - start over?

Last edited by xlfs-0.2; 01-29-2023 at 06:54 PM.
 
  


Reply



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
[SOLVED] in chroot compiled programs do not work in chroot graphit Linux From Scratch 2 04-11-2010 03:04 AM
chroot to run hd-installed distro's programs from chroot in live distro? silencestone Linux - Software 0 10-12-2007 06:29 AM
sudo /usr/bin/chroot /home/chroot /bin/su - xxx| /bin/su: user xxx does not exist saavik Linux - General 3 07-04-2007 10:30 AM
mount command not working in chroot. and now chroot not working mohit.jain Linux From Scratch 5 07-14-2006 03:57 AM
to chroot or not to chroot complus Linux - Security 4 02-29-2004 04:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 06:18 AM.

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