You are not logged in.

#1 2007-07-24 19:04:22

fede
Member
Registered: 2007-06-29
Posts: 126

Correct way of chrooting whole system (was Might break my system?... )

<< EDIT: The original issue for my post was solved, thanks for your help, but I am looking for advice on the proper way of using chroot to access the whole system for repair purposes (as in installing the standard kernel via pacman in case of breakage), please see posts below. Thanks! >>

Hello,

I have just upgraded the kernel via pacman to current release 2.6.22. But there was an error message because my /boot partition (separate) was not mounted.

So now I realize that /boot was not being mounted, I suspect because my kernel (using -ck version from extra or community) does not support ext2: mount /dev/sda7 /boot -t ext2 returns "unknown filesystem type: 'ext2'"; same thing with similar mount commands.

The problem is I fear  that if I restart the machine something bad might happen. I would like to go back to previous kernel, fix the issue of my ext2 boot partition not mounting (maybe by using standard kernel), and only then upgrading to current kernel version, with /boot properly mounted.

Now, what I want to try is recover the standard kernel, previous version. I am doing makepkg from the abs tree, which was synched a few days ago, so it contains the older kernel. The question is: will installing that version now enable me to reboot safely? Please consider I will install it with my boot partition not mounted, because I can't mount it now, because I'm stuck with a kernel without ext2 support.

If not, can you help me by suggesting a safe way to upgrade the kernel?

Thanks!

Last edited by fede (2007-07-26 11:54:43)

Offline

#2 2007-07-24 19:39:36

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Correct way of chrooting whole system (was Might break my system?... )

One thing to remember here is that you can always boot the installation CD and use it as a rescue disc. I would just do that, and chroot into your real system. That way you know you're working with a reasonable kernel, and can mount /boot while you're working.

Offline

#3 2007-07-24 20:07:37

Obi-Lan
Member
From: Finland
Registered: 2007-05-23
Posts: 179

Re: Correct way of chrooting whole system (was Might break my system?... )

Err I had same situation once. Pacman just installed /boot stuff to root partition instead of boot partition. I just copied stuff over from root/boot to boot. I guess pacman removes all stuff related to old kernel version? In my gentoo boxes I usually keep two versions of kernel in /boot and I compile them manually and put needed drivers statically.

Offline

#4 2007-07-26 03:34:55

fede
Member
Registered: 2007-06-29
Posts: 126

Re: Correct way of chrooting whole system (was Might break my system?... )

Thanks for the replies. I actually got it working by installing the previous version of the kernel from my abs sources. It complained that it couldn 't find boot. Thanks for the tip, ataraxia. I would have done that but I'm not very comfortable with chrooting, I should learn the necessary commands and the correct order (and reasons for that) for mounting /boot, /proc, /sys. Did it once, but I was just taking the plunge, not really knowing why or in what order I had to mount those.

I should look for a good chroot tutorial in my spare time. If you know where I can find one, I 'd be grateful. Thanks.

Offline

#5 2007-07-26 10:23:50

Obi-Lan
Member
From: Finland
Registered: 2007-05-23
Posts: 179

Re: Correct way of chrooting whole system (was Might break my system?... )

1. mount root partition /mnt/root (or whatever)
2. mount other partitions under root partition
3. mount proc, mount -t proc proc /mnt/root/proc
4. mount dev (needed?) mount -o bind /dev /mnt/root/dev
5. cp /etc/resolv.conf to /mnt/root/etc/
6. chroot /mnt/root/ /bin/bash

Correct me if I'm wrong or if I'm missing something. This method can be used also recovering root password, just do passwd after chroot.

Last edited by Obi-Lan (2007-07-26 10:24:31)

Offline

#6 2007-07-26 11:50:40

fede
Member
Registered: 2007-06-29
Posts: 126

Re: Correct way of chrooting whole system (was Might break my system?... )

Thanks, obilan,

Searching the wiki and forums I also found these recipes:

# mount /dev/sda1 /mnt
# mount --bind /dev /mnt/dev
# chroot /mnt /bin/bash
( http://bbs.archlinux.org/viewtopic.php?id=34631 )

modprobe xfs
mount -t xfs /dev/discs/discX/partY /mnt
mount -t xfs /dev/discs/discV/partW /mnt/boot (if you have it)
mount -t devfs none /mnt/dev
mount -t proc none /mnt/proc
chroot /mnt /sbin/lilo

( for fixing lilo on xfs, but I can ignore that part ; http://wiki.archlinux.org/index.php/Pos … el_Updates )

mount /dev/sdaX /mnt
mount -t proc   proc      /mnt/proc
mount -t sysfs  sys       /mnt/sys
mount -o bind   /dev      /mnt/dev
chroot /mnt /bin/bash

( http://bbs.archlinux.org/viewtopic.php?id=31942 )

So the question is why the differences and which is best? Specifically:

Which command is correct for mounting /dev - if necessary, as you suggest -, or do they all work properly?
Is it necessary to mount sys?

thanks a lot!

PS: I edited the thread title.

Offline

#7 2007-07-26 13:10:30

Obi-Lan
Member
From: Finland
Registered: 2007-05-23
Posts: 179

Re: Correct way of chrooting whole system (was Might break my system?... )

Devfs is deprecated I think so mount -t devfs none wont work. mount -o bind or mount --bind seems to do same thing. I've never mounted sysfs but it might be needed for some operations.

Offline

Board footer

Powered by FluxBB