Commit 939b0ae7 authored by Mike Hibler's avatar Mike Hibler
Browse files

Tweaks to the agreement between mkextrafs and the blockstore system.

For the case in which mkextrafs is used to create local homedirs/projdirs:

Look for the desired mount point (/local) in /etc/fstab and use that if
it exists (i.e., that FS was already setup by the blockstore system or a
previous mkextrafs).

Otherwise, look for /var/emulab/boot/extrafs which should contain info
left behind by the local blockstore setup code indicating a FS or unused
device to use. For an unused device, rc.storage will identify the largest
available device that is at least 10MB.
parent f2b73ecd
......@@ -366,14 +366,16 @@ sub doboot()
#
# First see if there is an unused partition or disk.
# Remember the largest.
# XXX make sure it is at least 10MB.
#
my $edev;
my $isdisk = 0;
$size = 0;
$size = 9;
foreach my $dev (keys %$dinfo) {
my $href = $dinfo->{$dev};
if ($href->{'inuse'} == 0 && $href->{'size'} > $size) {
$edev = $dev;
$size = $href->{'size'};
if ($href->{'type'} eq "DISK") {
$isdisk = 1;
}
......
......@@ -1192,7 +1192,30 @@ sub os_mountextrafs($)
my $part = "";
#
# If the extrafs file was written, use the info from there.
# Parse /etc/fstab
#
my %fses = ();
if (open(FD, "</etc/fstab")) {
while (<FD>) {
if (/^#/) {
next;
}
if (/^(\S+)\s+(\S+)/) {
$fses{$2} = $1;
}
}
close(FD);
}
#
# If the desired directory name is already a mount point, just use it.
#
if (exists($fses{$dir})) {
return $dir;
}
#
# Otherwise, if the extrafs file was written, use the info from there.
#
my $extrafs = libsetup::TMEXTRAFS();
if (-f "$extrafs" && open(FD, "<$extrafs")) {
......@@ -1215,15 +1238,18 @@ sub os_mountextrafs($)
}
#
# XXX this is a most bogus hack right now, we look for partition 4
# in /etc/fstab.
# Finally, we look for partition 4 of the root disk and use that!
# XXX this is a most bogus hack.
#
my $fstabline = `grep '0s4[ae]' /etc/fstab`;
if ($fstabline =~ /^\/dev\/\S*0s4[ae]\s+(\S+)\s+/) {
$mntpt = $1;
return $mntpt;
foreach $mntpt (keys %fses) {
if ($fses{$mntpt} =~ /^\/dev\/\S+0[sp]4[ae]$/) {
return $mntpt;
}
}
print STDERR "os_mountextrafs: no suitable device found!\n";
return "";
makeit:
my $args = "-f";
......
......@@ -2424,7 +2424,30 @@ sub os_mountextrafs($)
my $part = "";
#
# If the extrafs file was written, use the info from there.
# Parse /etc/fstab
#
my %fses = ();
if (open(FD, "</etc/fstab")) {
while (<FD>) {
if (/^#/) {
next;
}
if (/^(\S+)\s+(\S+)/) {
$fses{$2} = $1;
}
}
close(FD);
}
#
# If the desired directory name is already a mount point, just use it.
#
if (exists($fses{$dir})) {
return $dir;
}
#
# Otherwise, if the extrafs file was written, use the info from there.
#
my $extrafs = libsetup::TMEXTRAFS();
if (-f "$extrafs" && open(FD, "<$extrafs")) {
......@@ -2447,20 +2470,23 @@ sub os_mountextrafs($)
}
#
# XXX this is a most bogus hack right now, we look for partition 4
# in /etc/fstab.
# Finally, we look for partition 4 of the root disk and use that!
# XXX this is a most bogus hack.
#
my $fstabline = `grep -E '(hda|sda|xvda)4' /etc/fstab`;
if ($fstabline =~ /^\/dev\/\S*4\s+(\S+)\s+/) {
$mntpt = $1;
return $mntpt;
foreach $mntpt (keys %fses) {
if ($fses{$mntpt} =~ /^\/dev\/(hd|sd|xvd)a4$/) {
return $mntpt;
}
}
print STDERR "os_mountextrafs: no suitable device found!\n";
return "";
makeit:
my $args = "-f";
if ($part) {
if ($part =~ /^((?:hd|sd)[a-z])(\d+)$/) {
if ($part =~ /^((?:hd|sd|xvd)[a-z])(\d+)$/) {
$args .= " -r $1 -s $2";
}
} elsif ($disk) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment