Commit 4fd46789 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

A "prepare" script for freebsd and linux, to be run as single user

just before cutting an image. Described in doc/newimage.txt. This
encapsulates a number of piddly things that must be done.
parent 38348666
From testbed-request Mon Dec 11 23:40:51 2000
Return-Path: <mike>
Received: (from mike@localhost)
by fast.cs.utah.edu (8.9.1/8.9.1) id XAA19700
for testbed-ops; Mon, 11 Dec 2000 23:40:51 -0700 (MST)
Date: Mon, 11 Dec 2000 23:40:51 -0700 (MST)
From: Mike Hibler <mike>
Message-Id: <200012120640.XAA19700@fast.cs.utah.edu>
To: testbed-ops
Subject: creating a new disk image
Leigh wanted to know all the things I do when creating a disk image,
so I'll spew it out here as I remember it for archival. This is still
assuming that you load the current image on a testbed machine and update
it "in place." The idea of having the second disk on plastic where we
keep a current image up-to-date, just ain't workin' (e.g., see Leigh's
messages about installing ports).
A. Linux:
0. Update /etc/rc.d/testbed/supfile from the source (tmcd/linux)
......@@ -34,42 +16,16 @@ A. Linux:
mount -n -o remount,rw /
so you can update files.
4. Remove /etc/ssh/ssh_host_key. This will cause /etc/rc.d/rc.sysinit
to create a new host key when the machine reboots multiuser. So make
sure you don't go multiuser before you cut the image.
5. Zero out as much of the filesystem free space as possible. I do this by
creating a big, zero-filled file in each filesystem and then removing it:
mount -at nonfs
foreach filesytem
cd <root of filesystem>
dd if=/dev/zero of=bigfile bs=1024k
rm bigfile
end
This isn't perfect since freed indirect blocks will still have non-zero
data, but its close enough. This is also extremely painful under linux
as it appears that the disk cache grows without bounds to hold the new,
worthless file. This can make the machine to thrash, causing an operation
that takes a minute or so on FreeBSD, to take 20 minutes on Linux.
6. If you are feeling frisky, zero out the swap partition as well. For the
testbed machines this is currently /dev/hda3 BUT YOU REALLY WANT TO BE
SURE, so run:
fdisk -l /dev/hda
4. Mount the rest of the filesystems so you can add/change things:
It should list a "Linux swap" partition. Then do:
mount -a -t ufs
dd if=/dev/zero of=/dev/hda3 bs=4k seek=1
5. Run the testbed prepare script:
The "bs=4k" and "seek" are very important, together they cause dd to
skip the first 4k block in the swap area, which contains the swap file
information. If it gets clobbered, it is not the end of the world, you
can always run mkswap under linux.
cd /etc/rc.d/testbed
./prepare
7. Reboot to BSD to finish. I have tried dd'ing off the linux partition
6. Reboot to BSD to finish. I have tried dd'ing off the linux partition
while running Linux, but it has always produced a corrupt image. So
I dd everything from FreeBSD.
......@@ -95,39 +51,16 @@ B. FreeBSD:
mount -u /
so you can update files.
4. Remove /etc/ssh/ssh_host_key and /etc/ssh/ssh_host_dsa_key. This will
cause /etc/rc.network to create new host keys when the machine reboots
multiuser. So make sure you don't go multiuser before you cut the
image.
rm /etc/ssh/ssh_host_key /etc/ssh/ssh_host_dsa_key
5. Zero out as much of the filesystem free space as possible. I do this by
creating a big, zero-filled file in each filesystem and then removing it:
mount -at ufs
foreach filesytem
cd <root of filesystem>
dd if=/dev/zero of=bigfile bs=1024k
rm bigfile
end
This isn't perfect since freed indirect blocks will still have non-zero
data, but its close enough.
6. If you are feeling frisky, zero out the swap partition as well. For the
testbed machines this is currently /dev/rad0s1b BUT YOU REALLY WANT TO BE
SURE, so do:
disklabel ad0
4. Mount the rest of the filesystems so you can add/change things:
and see which partition is marked as "swap". Then do:
mount -a -t ufs
dd if=/dev/zero of=/dev/rad0s1b bs=1024k
5. Run the testbed prepare script:
Note there is no meta-info in the FreeBSD swap partition so you can
just wipe away.
cd /etc/testbed
./prepare
---------------------------------------------------------------------------
C. Cutting the image:
......
#!/usr/bin/perl -wT
use English;
require 'ctime.pl';
#
# Prepare the node for cutting a new image. Should be run just prior, on
# each of the FreeBSD and Linux partitions.
#
my $SUPCHECKOUT = "/etc/testbed/sup/sup/FBSD40-STD/checkouts";
my $DUMPDATES = "/etc/dumpdates";
my $IDENTFILE = "/var/db/testbed.deltas";
my $FSTAB = "/etc/fstab";
#
# Load the testbed library.
#
push(@INC, "/etc/testbed");
require setuplib;
#
# Untaint path
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/rc.d/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Turn off line buffering on output
#
$| = 1;
#
# First clean up the node as it would be if free.
#
cleanup_node();
print "Removing old sup checkouts ...\n";
if (-e $SUPCHECKOUT) {
unlink($SUPCHECKOUT) or
die("Could not unlink $SUPCHECKOUT");
}
print "Removing old delta list ...\n";
if (-e $IDENTFILE) {
unlink($IDENTFILE) or
die("Could not unlink $IDENTFILE");
}
#
# Generate a dumpdates file. Use fstab to find out what filesystems
# need entries, and then put in entries for each filesystem using
# the current date.
#
print "Removing old /etc/dumpdates file ...\n";
if (-e $DUMPDATES) {
unlink($DUMPDATES) or
die("Could not unlink $DUMPDATES");
}
print "Creating stub /etc/dumpdates file ...\n";
open(TAB, "$FSTAB") or
die("Could not open $FSTAB: $!");
open(DMP, ">$DUMPDATES") or
die("Could not open $DUMPDATES: $!");
while (<TAB>) {
if ($_ =~ /^([\w\/]+).*(\d).*\d$/) {
if ($2 != 0) {
my $t = localtime(time);
print DMP "$1 0 $t\n";
}
}
}
close(DMP);
close(TAB);
#!/usr/bin/perl -wT
use English;
require 'ctime.pl';
#
# Prepare the node for cutting a new image. Should be run just prior, on
# each of the FreeBSD and Linux partitions.
#
my $SUPCHECKOUT = "/etc/rc.d/testbed/sup/sup/RHL62-STD/checkouts";
my $DUMPDATES = "/etc/dumpdates";
my $IDENTFILE = "/var/db/testbed.deltas";
my $FSTAB = "/etc/fstab";
#
# Load the testbed library.
#
push(@INC, "/etc/rc.d/testbed");
require setuplib;
#
# Untaint path
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/rc.d/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Turn off line buffering on output
#
$| = 1;
#
# First clean up the node as it would be if free.
#
cleanup_node();
print "Removing old sup checkouts ...\n";
if (-e $SUPCHECKOUT) {
unlink($SUPCHECKOUT) or
die("Could not unlink $SUPCHECKOUT");
}
print "Removing old $IDENTFILE file ...\n";
if (-e $IDENTFILE) {
unlink($IDENTFILE) or
die("Could not unlink $IDENTFILE");
}
#
# Generate a dumpdates file. Use fstab to find out what filesystems
# need entries, and then put in entries for each filesystem using
# the current date.
#
print "Removing old $DUMPDATES file ...\n";
if (-e $DUMPDATES) {
unlink($DUMPDATES) or
die("Could not unlink $DUMPDATES");
}
print "Creating stub /etc/dumpdates file ...\n";
open(TAB, "$FSTAB") or
die("Could not open $FSTAB: $!");
open(DMP, ">$DUMPDATES") or
die("Could not open $DUMPDATES: $!");
while (<TAB>) {
if ($_ =~ /^([\w\/]+).*(\d).*\d$/) {
if ($2 != 0) {
my $t = localtime(time);
print DMP "$1 0 $t\n";
}
}
}
close(DMP);
close(TAB);
Markdown is supported
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