[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

autodetecting MBR location

My lilo configuration scripts need to be able to infer the correct location 
for the MBR.  I am currently using the following algorithm:
take root fs device from /etc/fstab and do the following:

The latter is for devfs.

Now for the benefit of RAID systems I need to do:
if($device =~ /\/dev\/md/)
  my $mdname = $device;
  $mdname =~ s/\/dev\///;
  $mdname =~ s/\///;
  my $md = `grep $mdname /proc/mdstat`;
  my @devices = split(" ", $md);
  @devices = sort(@devices[4..$#devices]);
  $root = "/dev/" . $devices[0];
  $root =~ s/\[.*$//;

Before the part of:

The debconf code that Gergely Risko <risko@atom.hu> wrote is what I'm 
building on.  Gergely's code has essentially s/[0-9]*// inlined which is ok 
for a non-RAID non-devfs system.  But I want to work with all combinations of 
RAID and non-RAID, devfs and non-devfs and also expand to LVM in the near 
future.  So I can't do that.  I currently plan to put a program to do this 
under /usr/sbin.

Now I have the following questions:
1)  Does anyone have any similar code for doing this that I can merge my code 
2)  Does anyone else need the same code?  If so please tell me what you need 
and I'll make my code as generic as I can.
3)  Can anyone see any obvious bugs in the above?

http://www.coker.com.au/bonnie++/     Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/       Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/     My home page

Reply to: