diff options
author | Antoine Ginies <aginies@mandriva.com> | 2011-01-19 10:44:49 +0000 |
---|---|---|
committer | Antoine Ginies <aginies@mandriva.com> | 2011-01-19 10:44:49 +0000 |
commit | 530a16ec071db0e24e6e949e265a96848864967c (patch) | |
tree | fe40cacd28d67b98186754c551b7fd339ebc7e17 /rescue/guessmounts | |
download | drakx-530a16ec071db0e24e6e949e265a96848864967c.tar drakx-530a16ec071db0e24e6e949e265a96848864967c.tar.gz drakx-530a16ec071db0e24e6e949e265a96848864967c.tar.bz2 drakx-530a16ec071db0e24e6e949e265a96848864967c.tar.xz drakx-530a16ec071db0e24e6e949e265a96848864967c.zip |
add mes5-2.6.33 branch
Diffstat (limited to 'rescue/guessmounts')
-rwxr-xr-x | rescue/guessmounts | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/rescue/guessmounts b/rescue/guessmounts new file mode 100755 index 000000000..c755e0743 --- /dev/null +++ b/rescue/guessmounts @@ -0,0 +1,97 @@ +#!/usr/bin/perl +# +# Guillaume Cottenceau +# +# Copyright 2001-2005 Mandriva +# +# 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. +# + +use lib qw(/usr/lib/libDrakX); +use common; +use fs; +use fs::proc_partitions; +use fs::type; + + +my @proc_mounts = fs::read_fstab('', '/proc/mounts'); + +my $target = '/mnt'; + +if (fs::get::mntpoint2part($target, \@proc_mounts)) { + print STDERR "$target is already mounted (according to /proc/mounts)\n"; + exit 0; +} + +system('drvinst', 'STORAGE'); + +print STDERR "\nPlease wait, trying to find your root device...\n"; + +mkdir_p($target); + +my @parts = map { + $_->{device} = delete $_->{dev}; + put_in_hash($_, fs::type::type_subpart_from_magic($_)); +} fs::proc_partitions::read_raw(); +my ($raid_parts, $normal_parts) = partition { isRawRAID($_) } @parts; + +if (@$raid_parts) { + require raid; + raid::detect_during_install_once(@$raid_parts); + my $raids = raid::get_existing(@$raid_parts); + push @$normal_parts, @$raids; +} + +my @fstab; +my $root; + +foreach (@$normal_parts) { + my $dev = devices::make($_->{device}); + + my $fs = find { + system("mount -t $_ $dev $target 2>/dev/null") == 0; + } fs::type::true_local_fs_types() or next; + + if (my $release_file = common::release_file($target)) { + print STDERR "=> found a Mandriva Linux root partition on $dev\n=> type $fs, version `", + chomp_(cat_("$target$release_file")), "'\n"; + @fstab = fs::read_fstab($target, '/etc/fstab'); + $root = $dev; + last; + } else { + system('umount', $target) == 0 or die "error unmounting $target\n"; + } +} + +if ($root) { + print STDERR "\nMounting other partitions from fstab on $target...\n"; + foreach (@fstab) { + my ($valued_options, $options) = fs::mount_options::unpack($_); + + next if + !$_->{fs_type} || $_->{device} eq 'none' + || $valued_options->{noauto} + || $_->{mntpoint} eq '/' + || member($_->{fs_type}, 'swap', 'nfs', 'ntfs', 'ntfs-3g'); + + delete $valued_options->{'iocharset='}; + delete $valued_options->{'codepage='}; + fs::mount_options::pack($_, $valued_options, $options); #- vfat opts, we don't have the modules in rescue + + my $where = "$target$_->{mntpoint}"; + my $dev = fs::wild_device::from_part('', $_); + mkdir_p($where); + print STDERR "\t$dev on $where type $_->{fs_type} options $_->{options}\n"; + system("mount -t $_->{fs_type} $dev $where -o $_->{options}"); + system("cp -f /etc/mtab $target/etc/mtab"); #- to allow a nice chrooted "mount" or "df" + } + print STDERR "\nYour system is ready on $target.\n\n"; +} else { + die "Could not find your root device :-(.\n"; +} + |