J'ai fait quelques tests et ça a l'air de marcher :)
J'écris ce message depuis un /sbin/init chrooté ;)
En gros, ce que j'ai fait:
1/- J'ai créé un environnement pour le chroot dans /chroot
2/- J'ai créé le fichier /chroot/chrootinit avec le contenu suivant:
#!/bin/bash
mount -t proc /proc /proc
mount -o bind /proc /chroot/proc
mount -o bind /dev /chroot/dev
exec /usr/sbin/chroot /chroot /bin/bash
Apparamment, le fichier chrootinit n'a pas besoin d'être compilé statiquement comme je l'ai dit par erreur... un script ça marche très bien!
3/- J'ai ajouté une entrée dans grub/lilo en mettant l'option init=/chroot/chrootinit. Pendant que j'écris ce message, j'ai ceci:
[^] # Re: linux, pas grub
Posté par Alban Crequy (site web personnel) . En réponse au journal Grub : Comment booter sur un dossier ?. Évalué à 6.
J'écris ce message depuis un /sbin/init chrooté ;)
En gros, ce que j'ai fait:
1/- J'ai créé un environnement pour le chroot dans /chroot
2/- J'ai créé le fichier /chroot/chrootinit avec le contenu suivant:
#!/bin/bash
mount -t proc /proc /proc
mount -o bind /proc /chroot/proc
mount -o bind /dev /chroot/dev
exec /usr/sbin/chroot /chroot /bin/bash
Apparamment, le fichier chrootinit n'a pas besoin d'être compilé statiquement comme je l'ai dit par erreur... un script ça marche très bien!
3/- J'ai ajouté une entrée dans grub/lilo en mettant l'option init=/chroot/chrootinit. Pendant que j'écris ce message, j'ai ceci:
$ cat /proc/cmdline
root=/dev/hdb1 devfs=mount hdd=ide-scsi acpi=ht splash=silent vga=788 init=/chroot/initchroot
4/- J'ai redémarré et j'ai choisi le chroot dans grub.
Maintenant j'ai un shell dans l'environnement chrooté. Mon shell a le PID 1.
5/- J'ai remonté hdb1 dans un sous-répertoire (/chroot/hdb1)
6/- Je me suis rechrooté dans mon vrai système avec "chroot hdb1 /sbin/init"
Et ça démarre bien ;)
Ce n'est pas exactement le même contexte que le tien mais à mon avis ça veut dire que c'est possible de booter sur un répertoire comme tu le demandes.