Re: Anyone working on an automated install?
Aleksej Saushev <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.installation |
|---|---|
| Message-ID | <[email protected]> |
David Young <[email protected]> writes: > On Mon, Oct 22, 2012 at 10:17:29AM -0400, Greg Troxel wrote: >> >> Aleksej Saushev <[email protected]> writes: >> >> > NetBSD installation process is straightforward, it is trivial to script it. >> >> If you mean with expect, it's not, if you have a lot of machines and >> don't have consoles wired up. If you mean that it shouldn't take much >> coding time to make sysinst take a control file, I agree. > > Aleksej may have meant that to write a script that sets up a disk using > fdisk(8), disklabel(8), makefs(8), extracts sets with pax(1), runs > etcupdate(8) to complete some essential installation steps, modifies > some configuration files (e.g, sets rc_configured=YES in /etc/rc.conf) > and runs installboot(8) to configure the bootloader, is trivial. > > I wouldn't call it trivial, but it's definitely possible. -- HE CE3OH...
autoinst.sh
(application/x-sh, 1.2 KB)
#!/bin/sh
set -e
: ${SD:=vnd0} # default to virtual storage device
SIZE=$(fdisk ${SD} 2>/dev/null | sed -ne "/^total sectors:/{s/^[^:]*[^0-9]*//;p;q;}")
SWAPSIZE=$((2 "*" 1024 "*" 16))
fdisk -f -v -u -i -0 -a -s 169/64/$(($SIZE - 64)) ${SD}
fdisk -f -c /usr/mdec/mbr ${SD}
disklabel ${SD} >/tmp/image.label ||:
ed -s /tmp/image.label <<EOF
/^$/
+,\$d
a
4 partitions:
# size offset fstype [fsize bsize cpg/sgs]
a: $(($SIZE - $SWAPSIZE - 64)) 64 4.2BSD 0 0 0 # (Cyl. 2*- 522*)
b: ${SWAPSIZE} $(($SIZE - $SWAPSIZE)) swap # (Cyl. 1042*- 9364*)
c: $(($SIZE - 64)) 64 unused 0 0 # (Cyl. 2*- 969020)
d: ${SIZE} 0 unused 0 0 # (Cyl. 0 - 969020)
.
w
q
EOF
disklabel -R ${SD} /tmp/image.label
newfs -O2 ${SD}a
mkdir -p /tmp/image.target
mount /dev/${SD}a /tmp/image.target
SETSDIR=/usr/obj/releasedir/i386/binary/sets
cd /tmp/image.target
for s in base etc; do pax -zrpe -f ${SETSDIR}/$s.tgz; done
for s in kern-GENERIC modules; do pax -zrpe -f ${SETSDIR}/$s.tgz; done
cp -v /usr/mdec/boot .
installboot -vf -o timeout=2 /dev/r${SD}a /usr/mdec/bootxx_ffsv2
sync
cd
umount /tmp/image.target