device2grub
Michael Goetze
mgoetze at mgoetze.net
Thu Feb 10 23:15:43 CET 2011
Hi,
as some of you have may have heard I'm working on CentOS support for FAI
4.0. One of the problems I have is the following: during the
installation, I have a Squeeze kernel with a Squeeze udev. After the
installation, I will have a much older CentOS kernel with a much older
CentOS udev, and devices may have different names (hda vs. sda and so
on). However, device2grub depends on $target/boot/grub/device.map. I
would have to generate this file, even though the contents would
possibly be wrong after the installation.
Therefore, I propose to make device2grub independent of $target. An
example implementation can be found below. However, this may have
unforeseen consequences, so I would like to ask whether anyone sees a
problem with this change for FAI 4.0.
--- device2grub.orig 2011-02-10 21:29:03.394046849 +0100
+++ device2grub 2011-02-10 21:51:43.217071970 +0100
@@ -2,6 +2,7 @@
# $Id: device2grub 5910 2010-07-29 23:50:20Z lange $
# copyright Thomas Lange 2001-2010, lange at debian.org
+# copyright Michael Goetze 2011, mgoetze at mgoetze.net
# map "normal" device notation to grub notation
# TODO: read from stdin if no parameter given
@@ -14,10 +15,13 @@
my %map;
my $device=shift;
-my $devicemap="$ENV{target}/boot/grub/device.map";
+my $devicemap = `mktemp`;
+chomp $devicemap;
my $devbyid = "/dev/disk/by-id";
-open (DEVICEMAP,"<$devicemap") || die "Can't open $devicemap\n";
+system("/usr/sbin/grub-mkdevicemap", "-m", "$devicemap") == 0 or die
"Could not run grub-mkdevicemap\n";
+
+open (DEVICEMAP,"<$devicemap") || die "Can't open device map $devicemap\n";
while (<DEVICEMAP>) {
my ($grubdevice,$olddevice) = split;
$map{$olddevice} = $grubdevice;
@@ -53,4 +57,5 @@
}
print "$grubdevice\n";
+unlink("$devicemap");
exit 0;
Regards,
Michael
More information about the linux-fai-devel
mailing list