summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-06-10 21:08:33 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-06-10 21:08:33 +0000
commit5e08e5a12f3a890b9622e7fe9c6ec96d7aff4b41 (patch)
tree0bd479dbe1cbff81634a1d73aaae1378bdd95fa4
parent7602c9f67bac536046cc9ab34f254cae35b72eef (diff)
downloaddrakx-backup-do-not-use-5e08e5a12f3a890b9622e7fe9c6ec96d7aff4b41.tar
drakx-backup-do-not-use-5e08e5a12f3a890b9622e7fe9c6ec96d7aff4b41.tar.gz
drakx-backup-do-not-use-5e08e5a12f3a890b9622e7fe9c6ec96d7aff4b41.tar.bz2
drakx-backup-do-not-use-5e08e5a12f3a890b9622e7fe9c6ec96d7aff4b41.tar.xz
drakx-backup-do-not-use-5e08e5a12f3a890b9622e7fe9c6ec96d7aff4b41.zip
- add 'guessmounts' that mimics RH's detecting of partitions when rescue starts
-rw-r--r--rescue/Makefile6
-rwxr-xr-xrescue/guessmounts80
-rwxr-xr-xrescue/make_rescue_img1
-rwxr-xr-xrescue/tree/etc/rc.sysinit10
4 files changed, 96 insertions, 1 deletions
diff --git a/rescue/Makefile b/rescue/Makefile
index 4d3015b81..59de38f3d 100644
--- a/rescue/Makefile
+++ b/rescue/Makefile
@@ -1,9 +1,13 @@
+ARCH := $(patsubst i%86,i386,$(shell uname -m))
+ARCH := $(patsubst sparc%,sparc,$(ARCH))
+
+
ROOTDEST = /export
install: rescue_stage2.bz2
cp -f $< $(ROOTDEST)/Mandrake/base
-rescue_stage2.bz2: kernel_read_part list
+rescue_stage2.bz2: kernel_read_part list list.$(ARCH) drvinst guessmounts make_rescue_img
./make_rescue_img
clean:
diff --git a/rescue/guessmounts b/rescue/guessmounts
new file mode 100755
index 000000000..b62f8d870
--- /dev/null
+++ b/rescue/guessmounts
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+
+#
+# Guillaume Cottenceau (gc@mandrakesoft.com)
+#
+# Copyright 2001 MandrakeSoft
+#
+# This software may be freely redistributed under the terms of the GNU
+# public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+
+sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; my @l = <F>; wantarray ? @l : join '', @l }
+
+
+#- start
+system('drvinst'); #- class2text seems broken, I can't detect easily only modules for SCSI storage :-(
+
+print "\nPlease wait, trying to find your root device...\n";
+
+my $target = '/mnt/sysimage';
+(-d $target) or mkdir($target) or die "couldn't create $target\n";
+
+
+my @parts = cat_('/proc/partitions');
+splice @parts, 0, 2; #- doesn't contain partitions
+
+my @fstab;
+my $root;
+
+for my $dirtypart (@parts) {
+ next if $dirtypart !~ /^\s*\w+\s+\w+\s+\w+\s+(\w+)\s/;
+ my $dev = "/dev/$1";
+
+ for my $fs ('ext2', 'reiserfs') {
+ my $where = $target;
+ if (!system("mount -t $fs $dev $where 2>/dev/null")) {
+ if (-f "$where/etc/fstab") {
+ print "Found a probable root partition on $dev (type $fs)\n";
+ @fstab = cat_("$where/etc/fstab");
+ $root = $dev;
+ } else {
+ system('umount', $where) and die "error unmounting $mntpoint: $!\n";
+ }
+ last;
+ }
+ }
+ last if @fstab;
+}
+
+if ($root) {
+ print "\nMounting other partition from fstab on $target...\n";
+ for my $fstabline (@fstab) {
+ my ($dev, $where, $type, $opts) = $fstabline =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s/;
+ next if (!$type || $dev eq 'none' || $where eq '/' || $type eq 'supermount' ||
+ $type eq 'swap' || $type eq 'nfs' || $where =~ /cdrom/ ||
+ $where =~ /floppy/ || $opts =~ /noauto/ || $where =~ /proc/ ||
+ $where =~ /mnt\/zip/);
+ $opts = join(',', grep { !/codepage=/ && !/iocharset/ } split(/,/, $opts)); #- vfat opts, we don't have the modules in rescue
+ $where = "/mnt/sysimage$where";
+ (-d $where) or mkdir($where) or die "couldn't create $where\n";
+ print "Mounting $dev on $where type $type\n";
+ system("mount -t $type $dev $where -o $opts");
+ }
+ print "Your partitions are mounted on $target.\n".
+ "For example you can use 'chroot $target' to simulate your system.\n".
+ "(you can reinstall lilo that way if necessary).\n\n";
+}
+
+
+#-------------------------------------------------
+#- $Log$
+#- Revision 1.1 2001/06/10 21:08:33 gc
+#- - add 'guessmounts' that mimics RH's detecting of partitions when rescue starts
+#-
+#-
diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img
index df4cbca15..89792cbd2 100755
--- a/rescue/make_rescue_img
+++ b/rescue/make_rescue_img
@@ -74,6 +74,7 @@ _ "cp ../all.modules/modules.cz-$main $tmp/modules/modules.cz";
_ "cp ../all.modules/$main/modules.dep $tmp/modules";
installown("drvinst", "/usr/bin");
+installown("guessmounts", "/usr/bin");
#_ "install -s kernel_read_part $tmp/sbin" if $arch =~ /i.86/;
__ "$sudo strip $tmp/{lib,bin,sbin}/* $tmp/usr/{bin,sbin}/* 2>/dev/null";
diff --git a/rescue/tree/etc/rc.sysinit b/rescue/tree/etc/rc.sysinit
index 78d6cb257..f31b4598d 100755
--- a/rescue/tree/etc/rc.sysinit
+++ b/rescue/tree/etc/rc.sysinit
@@ -36,3 +36,13 @@ grep -q oem /proc/cmdline && exec /etc/oem -f
/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0
/sbin/route add 127.0.0.1 lo
+
+grep -q noguessmounts /proc/cmdline
+if [ $? != 0 ]; then
+ echo "I will try now to guess your mountpoints;"
+ echo -e "If any problems, reboot with \\033[1;37mrescue noguessmounts\\033[0;39m to disable this."
+ echo ""
+ guessmounts
+ echo "Press <enter> to continue"
+ read
+fi