chroot doesn't work during distribution stage!

Chris Lingard chris at stockwith.co.uk
Fri Apr 30 08:57:40 PDT 2004


ke chen wrote:

> Dear all,
>  
> I tried to distribute my LFS5.0 system to another host. After booting the
> host with a bootable CD, i made disk partition, just three partitions,
> /hda1 for boot directory, /hda5 for root directory, swap, and format them.
>  
> then mount partition to /mnt
> "mount -t ext2 /dev/hda5 /mnt"
> "mkdir /mnt/boot"
> "mount -t ext2 /dev/hda1 /mnt/boot"
>  
> After that,copy pre-established LFS distribution to /mnt
> "cp -a distro/* /mnt"
>  
> Then I wanted to use "chroot /mnt", but it doesn't work.
> "chroot /mnt" when pressing enter, cursor stops at the next line, no
> response.
>  
> But i can run it appending command options
> "chroot /mnt grub"
> when entering grub shell, I also encountered something strange.
> root (hd0,0)
> setup (hd0)
> it printed out messages like the followings:
> **************************************
> checking if "/boot/grub/stage1" exsits no
>      "/grub/stage1" exsits yes
>             "/grub/stage2" exsits yes
>             "/grub/e2fs_stage1_5" exsits no
> Running "install /grub/stage1 (hd0) /grub/stage2 p /grub/menu.list" ...
> succeed done *************************************
> Actually my binary files stage1,stage2 are located within /boot/grub
> directory, why it said there is no file exist there instead they are in
> directory /grub.
> The good thing is that  I can get grub menu after rebooting the
> system,while the bad thing is  that the system can not start, since it can
> not find files.
>  
> I browse the mailing list, this article
>
(http://linuxfromscratch.org/pipermail/lfs-support/2004-February/022272.html)
> gave me hints, I modified menu.list, then it works.
> kernel /boot/lfskernel root=/dev/hda5  >>>> kernel (hd0,0)/lfskernel
> root=/dev/hda5
>  
> Can somebody help me out on "chroot /mnt"? i really need it work. As for
> the grub, i am still confused and hopefully someone can make me clear.

Try:
chroot  /mnt  /bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin

But the boot partition is not mounted on /boot within the chroot;
try  ls /boot and see what you get
So mount the boot partition as soon as you chroot

You will then be able to run commands with your new system
You are mounting /boot as a partition; so to grub this will
appear as containing just the files within that partition

There is no directory boot in that partition.

The thing to do is set a symbolic link
In chrooted in do
cd /boot
ln  -s  .  boot

It now appears that your boot partition contains a boot
and a boot/grub; and you wil be able to run grub

Chris




More information about the lfs-support mailing list