LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   'chroot'ing into the system (http://www.linuxquestions.org/questions/slackware-14/chrooting-into-the-system-4175429853/)

clifford227 10-01-2012 05:45 AM

'chroot'ing into the system
 
Hello,

Following on from my thread about a boot problem with my notebook computer, which suddenly make's the screen go black while running through the boot messages, other LQ members suspected that it may be due to an unsupported graphics chip (the Intel GMA 3600) in the stock slackware 14 3.2x kernel.

It was suggested that if I use the huge kernel 3.5.4 config file from /testing, and built a kernel from that config file and source, the correct drivers are available to make my notebook work.

It was also suggested that I 'chroot' into the system to do this. But Im not sure how involved it is. I've read some things about chroot, but I dont seem to fully understand it or how it works.

I was hoping that LQ members might try to explain chroot, what it is, and at the end of it maybe some practical advice to allow me chroot into my system to allow me to build a new kernel (which I can do already) to try and resolve the boot problem.

(*EDIT* I should say that when I attempted to resolve this problem a few days ago, I wasnt very well at all, and it was late at night, but the enthusiasm to try Slack 14 on my notebook should have waited untill I was feeling better. My apologies for the previous thread, I do however feel better this morning to attempt to resolve this problem, so any help will be appreciated and acted on)

BlackRider 10-01-2012 06:03 AM

Chrooting basically means entering in a turned off system while you are running another active system. Very, very roughly speaking :-)

For successfully chrooting into a system (for example, when you have installed a system and want to chroot to it form a Live CD), you usually have to perform these steps:

Code:

#Mount the filesystem you want to chroot into.
mount /dev/whatever /mnt/wherever

#Mount critical stuff in the filesystem you want to chroot into.
#A system will usually work badly without these.
mount -o bind /sys /mnt/wherever/sys
mount -o bind /dev /mnt/wherever/dev
mount -o bind /proc /mnt/wherever/proc

#Chroot into the system.
chroot /mnt/wherever

This should give you a root shell in the turned off system.

clifford227 10-01-2012 06:19 AM

BlackRider, so chroot allows you to get into the turned off system and to use directories that are needed for repairs or other work. Correct?

But why do would you need to mount further directories, sys, dev and proc, when you have already mounted the filesystem as a whole?

TobiSGD 10-01-2012 06:29 AM

If you have to have access to the hardware or kernel interface from within the chrooted system you first need to make them accessible. For example, Grub will complain if you want to install it and doesn't have access to those directories.

clifford227 10-01-2012 06:46 AM

Thankyou Tobi,

So when you first mount the filesystem as in BlackRiders example:

Code:

#Mount the filesystem you want to chroot into.
mount /dev/whatever /mnt/wherever

It only mounts the root, to attach the filesystem and no directories below it, so you have to then attach further directories which are needed. I understand.

To ask a further question, again using BlackRiders example

Code:

/mnt/wherever
wherever becomes root, and the other necessary area's of the system:

Code:

sys /mnt/wherever/sys
/dev /mnt/wherever/dev
/proc /mnt/wherever/proc

are mounted onto that root directory.

What is the correct label for '/mnt/wherever'? Does it need to be '/mnt/root'?

BlackRider 10-01-2012 07:08 AM

Quote:

But why do would you need to mount further directories, sys, dev and proc, when you have already mounted the filesystem as a whole?
TobISGD has mostly explained it. What is contained in sys, dev and proc is volatile ware, because it exist not in a turned off system. These folders contain kernel and hardware stuff that is generated by the kernel on boot and destroyed on shutdown, so an inactive system has not access to them.

That's why you provide the inactive system with "copies" of the stuff generated by your running system. Because the inactive system cannot generate everything by itself.

Quote:

(...)It only mounts the root, to attach the filesystem and no directories below it, so you have to then attach further directories which are needed.
Yes, if you use a multi-partition system, you have to track and mount every stuff inside the root of the inactive system.

For example, if your / is in /dev/sda1 and your /home is in /dev/sda2, you would do something like:
Code:

mount /dev/sda1 /mnt/whatever
mount /dev/sda2 /mnt/whatever/home

and so on.

Quote:

What is the correct label for '/mnt/wherever'?
That's irrelevant. Any existent directory will do. You can make a folder called "chroot", "orange", or "sdfsdf" and mount everything there if you want. It does not even have to be inside of /mnt (although the purpose or /mnt is precisely to mount this kind of things inside of it).

clifford227 10-01-2012 07:27 AM

Thanks BlackRider and TobiSGD.

I now have a better understanding of chroot, and I am able to use the make command to build the new kernel.

clifford227 10-01-2012 12:52 PM

To update, I have built and installed the new 3.5.4 kernel and modified the lilo bootloader.

Do I need to logout of chroot somehow? and then unmount sys, dev and proc, then finally the root filesystem?

TobiSGD 10-01-2012 12:56 PM

To logout from the chroot just type exit, the filesystems should be unmounted automatically when you rebbot, but to be sure you can do that manually.

clifford227 10-01-2012 01:27 PM

Thanks Toby.

I unmounted the filesystems and rebooted.

I chose the new kernel in the Lilo screen, and managed to get through all of the boot messages (although some of the new modules failed), I got to the login console, and logged in as root. Unfortunately when I did startx, in the fluxbox screen there is no keyboard or touchscreen input (although fluxbox time in bottom right is still working!)

But thats for another day.

Thanks again :)


All times are GMT -5. The time now is 11:02 AM.