Unix Technical Forum

installing in chroot

This is a discussion on installing in chroot within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> Someone here recently talked about chroot'ing to a loop-mounted initrd and running the setup therein. Has anyone done this? ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-19-2008, 12:42 PM
/dev/rob0
 
Posts: n/a
Default installing in chroot

Someone here recently talked about chroot'ing to a loop-mounted initrd
and running the setup therein. Has anyone done this? Is anything other
than having /proc mounted in the chroot necessary for this?
--
/dev/rob0 - preferred_email=i$((28*28+28))@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-19-2008, 12:45 PM
Alan Hicks
 
Posts: n/a
Default Re: installing in chroot

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In alt.os.linux.slackware, /dev/rob0 dared to utter,
> Someone here recently talked about chroot'ing to a loop-mounted initrd
> and running the setup therein. Has anyone done this? Is anything other
> than having /proc mounted in the chroot necessary for this?


Gentoo's install does something similar. As I recall, the instructions
are:
mount proc -o bind
cat /etc/resolv.conf > newresolv.conf
chroot /bin/bash /newdir
source /etc/profile

I can't imagine much more else that would be needed.

- --
It is better to hear the rebuke of the wise,
Than for a man to hear the song of fools.
Ecclesiastes 7:5
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFA3HTGlKR45I6cfKARAjuQAJ0TgLkxEWVgXNPUumeR9d S24mC9cgCfXve3
k/2Av/DTlUg8ZGq2xTpmaIU=
=25ei
-----END PGP SIGNATURE-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-19-2008, 12:45 PM
An Metet
 
Posts: n/a
Default Re: installing in chroot

NOTE: This message was sent thru a mail2news gateway.
No effort was made to verify the identity of the sender.
--------------------------------------------------------

pgp trash troll delete

Alan Hicks <alan@lizella.network> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1


> In alt.os.linux.slackware, /dev/rob0 dared to utter,
> > Someone here recently talked about chroot'ing to a loop-mounted initrd
> > and running the setup therein. Has anyone done this? Is anything other
> > than having /proc mounted in the chroot necessary for this?


> Gentoo's install does something similar. As I recall, the instructions
> are:
> mount proc -o bind
> cat /etc/resolv.conf > newresolv.conf
> chroot /bin/bash /newdir
> source /etc/profile


> I can't imagine much more else that would be needed.


> - --
> It is better to hear the rebuke of the wise,
> Than for a man to hear the song of fools.
> Ecclesiastes 7:5
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)


> iD8DBQFA3HTGlKR45I6cfKARAjuQAJ0TgLkxEWVgXNPUumeR9d S24mC9cgCfXve3
> k/2Av/DTlUg8ZGq2xTpmaIU=
> =25ei
> -----END PGP SIGNATURE-----












Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-19-2008, 12:47 PM
Menno Duursma
 
Posts: n/a
Default Re: installing in chroot

On Thu, 24 Jun 2004 17:06:25 -0500, /dev/rob0 wrote:

> Someone here recently talked about chroot'ing to a loop-mounted initrd
> and running the setup therein. Has anyone done this? Is anything other
> than having /proc mounted in the chroot necessary for this?


Yes, and not much. Assuming this:

mount /mnt/cdrom
gzip -cd /mnt/cdrom/isolinux/initrd.img >/boot/setup.img
mkdir /boot/install
# And maybe: "umount -a" (or some such).
mount -t ext2 -o loop /boot/setup.img /boot/install

Something like this:

mount --bind /proc /boot/install/proc
chroot /boot/install /bin/bash sh --login

# Here you might want to edit and exec: /etc/rc.d/rc.S
# In which case following command might not be needed/wanted
../linuxrc

HTH, and have fun.

--
-Menno.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-19-2008, 12:49 PM
/dev/rob0
 
Posts: n/a
Default Re: installing in chroot

On Sat, 26 Jun 2004 12:59:14 +0000, Menno Duursma wrote:
> mount --bind /proc /boot/install/proc


THIS was what I missed. I tried mounting inside the chroot.

> chroot /boot/install /bin/bash sh --login


Aha! But there's still a lot of cruft in the environment. I did
unset PATH ; . /etc/profile
to at least get the $PATH right. I found that you can't just cd to your
directory and "chroot ." I did "chroot . /bin/sh".

> # Here you might want to edit and exec: /etc/rc.d/rc.S
> # In which case following command might not be needed/wanted
> ./linuxrc


Since you're not running the /sbin/init in the chroot this would have
no effect.

> HTH, and have fun.


Ha, well, it might have! Last night I decided to quit messing with
it and just get it done; I set up the initrd.img and 10.0 bare.i in
LILO and just ran a more typical setup. Choosing the "install from
pre-mounted directory" source option, I found a small bug in the
installer. I try to conserve keystrokes so I gave my directory a
single-letter name, which unfortunately was the same as one of the
series directory (it was "x".)

I got into the setup to the selection of series to install and the mode
of installation (these days I'm lazy; I always choose "full".) When it
started installing packages, it installed "x" first, followed by "x",
and again by "x" until I hit Ctrl-C. I am guessing that the first path
element being the same as that series directory is what confused it.

So I had to try again before I could get a clean 10 installed. And bit
by bit I copied over all my junk such that it's no longer a clean
install.

My custom 2.6.6 kernel had trouble, but not really, just that I chose
not to enable hotplug. I'm ashamed to admit I was depending on that!

Another thing, and this IS a real bug, is that udev overrides the
/dev/mouse symlink as is set by mouseconfig, if you don't happen to be
using /dev/psaux for the mouse.
--
/dev/rob0 - preferred_email=i$((28*28+28))@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-19-2008, 12:51 PM
Menno Duursma
 
Posts: n/a
Default Re: installing in chroot

On Sat, 26 Jun 2004 19:54:08 -0500, /dev/rob0 wrote:
> On Sat, 26 Jun 2004 12:59:14 +0000, Menno Duursma wrote:
>> mount --bind /proc /boot/install/proc

>
> THIS was what I missed. I tried mounting inside the chroot.
>
>> chroot /boot/install /bin/bash sh --login

>
> Aha! But there's still a lot of cruft in the environment. I did
> unset PATH ;


No need for this, however if you where to want that done, in my example
execute it before the "chroot" instead.

> . /etc/profile


That is what the "--login" option does ...

> to at least get the $PATH right.


Again, no need.

> I found that you can't just cd to your directory and "chroot ."


Normally, on Linux, you can. Not for this though. Read no.

> I did "chroot . /bin/sh".


That isn't going to work, becouse BusyBox expects to be told how it
should act, as an argument - hence:

chroot /some/path /bin/bash sh --login

Might as well have been:

cd /some/path
chroot . /bin/busybox sh --login

>> # Here you might want to edit and exec: /etc/rc.d/rc.S
>> # In which case following command might not be needed/wanted
>> ./linuxrc

>
> Since you're not running the /sbin/init in the chroot this would have
> no effect.


Well, just try it out then ...

(FWIW: there are some symlinks being overwritten by rc.S which is
called from init. And that's probably realy needed, and stuff, idunno.)

>> HTH, and have fun.

>
> Ha, well, it might have!


Now you'll know how to go about this, should there ever be a next time ...

[ ... Install problems, you might want to report to Patrick . ]

> My custom 2.6.6 kernel had trouble, but not really, just that I chose
> not to enable hotplug. I'm ashamed to admit I was depending on that!


<AOL>
Yeah, me too, i'll just:
let hotplug figure it out
awk lsmod output into rc.modules
and disable it :-).
</AOL>

> Another thing, and this IS a real bug, is that udev overrides the
> /dev/mouse symlink as is set by mouseconfig, if you don't happen to be
> using /dev/psaux for the mouse.


Hey, thanks! ATM i'm using 2.4.x on this very machine still. But it does
have a (3-button Logitech) serial mouse installed. And i _was_ planning on
switching to 2.6.x now that i upgraded to the great Slackware 10 !

Cheers

--
-Menno.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-19-2008, 12:51 PM
/dev/rob0
 
Posts: n/a
Default Re: installing in chroot

On Sun, 27 Jun 2004 09:06:34 +0000, Menno Duursma wrote:
>>> # Here you might want to edit and exec: /etc/rc.d/rc.S # In which case
>>> following command might not be needed/wanted ./linuxrc

>>
>> Since you're not running the /sbin/init in the chroot this would have no
>> effect.

>
> Well, just try it out then ...
>
> (FWIW: there are some symlinks being overwritten by rc.S which is called
> from init. And that's probably realy needed, and stuff, idunno.)


That's just it: nothing is calling the rc.S or other init scripts in
the chroot.

>>> HTH, and have fun.

>>
>> Ha, well, it might have!

>
> Now you'll know how to go about this, should there ever be a next time ...


Oh there certainly will be. I'm going to try to upgrade /dev/wife to
10.0, and she cannot tolerate any down time.

> [ ... Install problems, you might want to report to Patrick . ]


Did it before I posted.

>> Another thing, and this IS a real bug, is that udev overrides the
>> /dev/mouse symlink as is set by mouseconfig, if you don't happen to be
>> using /dev/psaux for the mouse.

>
> Hey, thanks! ATM i'm using 2.4.x on this very machine still. But it does
> have a (3-button Logitech) serial mouse installed. And i _was_ planning on
> switching to 2.6.x now that i upgraded to the great Slackware 10 !


I plan to change /dev/mouse in my rc.gpm and xorg.conf to point to
/dev/ttyS0. That will work for now. But perhaps this bug is already
fixed in the new -current tree?

Thanks for your reply, and you too, Alan.
--
/dev/rob0 - preferred_email=i$((28*28+28))@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-19-2008, 12:54 PM
Mike Denhoff
 
Posts: n/a
Default Re: installing in chroot

On Thu, 24 Jun 2004 17:06:25 -0500, /dev/rob0 wrote:

> Someone here recently talked about chroot'ing to a loop-mounted initrd
> and running the setup therein. Has anyone done this? Is anything other
> than having /proc mounted in the chroot necessary for this?


Well, that would be me. Mark Hill gave a different suggestion so I decided
to try that. I'll give a quick summary.

From my running Slack 9.1 installation, I downloaded the Slack 10 series
that I wanted.
I mounted the target directory for Slackware 10 on /slack10.
I cd'ed into the series 'a' directory and ran
installpkg -root /slack10 *.tgz
The same for series ap l n x xap, after moving some packages that I didn't
want to install.

Then I tried to chroot into the new Slack10 root, but chroot said
something about /bin/bash was not a file. A bit of investigating found
that a bunch of sym links were missing in /slack10/lib. I'm guessing that
on a normal install these would be made by ldconfig during the first
bootup. Anyway, the doinst.sh in the glibc-solibs package has a bunch of
lines which build these links, which didn't get run during my installpkg.
I didn't manage to understand the script well enough to know why. I
copied only the link building lines to a file in /slack10/lib and ran
that. Now with these links in place, I could do

chroot /slack10 /bin/bash -i
mount -t proc /proc /proc

Then using pkgtool I ran the various setup scripts. The only unusual
think here was that the netconfig script did not probe for my network
card. Maybe because I had hotplug enabled? Anyway I added a rc.netdevice
for my old ISA nic.

Then I made a /etc/fstab modelled after the fstab in my Slack 9.1 install.
I exited the chroot, edited lilo.conf in slack 9.1 to add a section for
the new kernel and new partition, and ran lilo.

Rebooted, chose slack10, and it came up running fine.

Hmm, I wonder how I could move my normal users over with their same
passwords.

Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-19-2008, 12:55 PM
/dev/rob0
 
Posts: n/a
Default Re: installing in chroot

On Mon, 28 Jun 2004 13:28:59 -0400, Mike Denhoff wrote:
> Then using pkgtool I ran the various setup scripts. The only unusual
> think here was that the netconfig script did not probe for my network
> card. Maybe because I had hotplug enabled?


Probably without /proc the probing does not work. I haven't delved into
the code to know for sure, but that would be my guess.

> Anyway I added a rc.netdevice for my old ISA nic.


Probing often didn't work for ISA NIC's anyway.

> Hmm, I wonder how I could move my normal users over with their same
> passwords.


Copy from the old /etc the files group, passwd, and *shadow. However
you should merge some of the new groups added in 10.0.
--
/dev/rob0 - preferred_email=i$((28*28+28))@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-19-2008, 12:55 PM
Mike Denhoff
 
Posts: n/a
Default Re: installing in chroot

On Mon, 28 Jun 2004 13:57:30 -0500, /dev/rob0 wrote:

> On Mon, 28 Jun 2004 13:28:59 -0400, Mike Denhoff wrote:
>> Then using pkgtool I ran the various setup scripts. The only unusual
>> think here was that the netconfig script did not probe for my network
>> card. Maybe because I had hotplug enabled?

>
> Probably without /proc the probing does not work. I haven't delved into
> the code to know for sure, but that would be my guess.
>

Okay, you made me look. netconfig contains

# Check for existing network driver:
unset DONOTPROBE
if cat /proc/net/dev | grep eth0 1> /dev/null 2> /dev/null ; then
DONOTPROBE=true
fi

After I chroot'ed from the running Slack 9.1 into the new Slack 10, I did
mount /proc. I guess netconfig found the eth0 in Slack 9.1 and did not
do the probe.

>> Hmm, I wonder how I could move my normal users over with their same
>> passwords.

>
> Copy from the old /etc the files group, passwd, and *shadow. However
> you should merge some of the new groups added in 10.0.


Thanks,
Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:12 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com