#include
#include
#include
#define ROOT_DEVICE "/dev/hde1"
#define ROOT_FILESYSTEM "reiserfs"
#define CHROOT_TARGET "/debian"
int main(int argc, char** argv)
{
mount(ROOT_DEVICE, "/", ROOT_FILESYSTEM, MS_REMOUNT, "") ;
chroot(CHROOT_TARGET);
mount(ROOT_DEVICE, "/", ROOT_FILESYSTEM, MS_REMOUNT | MS_RDONLY, "");
return 0;
}
Compile it via:
gcc -static chrootinit.c -o chrootinit -Wall
and copy it to /sbin/chrootinit. Once that wrapper is in place and the given ROOT_DEVICE, ROOT_FILESYSTEM, CHROOT_TARGET variables are adjusted to your needs its time to modify the boot loader configuration, todo that all you need is to add a init=/sbin/chrootinit parameter and adjust the kernel location:
title Debian GNU/Linux, kernel 2.6.15-1-k7 (chrootinit)Once done with it you might also want to remove the root filesystem entry from /debian/etc/fstab to avoid some error messages at boot. The old system should now be bootable again, in the case of Debian it even works without any noticable error messages, other distributions might varry here.
root (hd1,0)
kernel /debian/boot/vmlinuz-2.6.15-1-k7 root=/dev/hde1 init=/chrootinit
initrd /debian/boot/initrd.img-2.6.15-1-k7
No comments:
Post a Comment