Project

General

Profile

Bug #1221 ยป usbstick.sh

mneumann, 01/08/2009 12:56 AM

 
IMG=/tmp/df.img
MNT=/mnt
SZ=450
VN=vn0

ISO=/tmp/LATEST-Devel.iso
CDDEV=/dev/vn1

CDMNT=/cdrom

FILES=".cshrc .profile COPYRIGHT README README.USB index.html kernel.BOOTP"
DIRS="bin boot dev etc etc.hdd root sbin sys usr var"
MKDIRS="mnt proc tmp"

dd if=/dev/zero of=${IMG} bs=1m count=${SZ}
fdisk -IB -p ${IMG}

vnconfig -e -s labels ${VN} ${IMG}

# write standard disklabel
disklabel -w -r ${VN}s1 auto

# read back disklabel
disklabel -r ${VN}s1 > ${IMG}.label

# determine number of sectors of whole disk
secs=`tail -n 1 ${IMG}.label | cut -f 3 -w`

# add a: partition
echo " a: ${secs} 0 4.2BSD" >> ${IMG}.label

# write modified disklabel back
disklabel -R -r ${VN}s1 ${IMG}.label

# write bootsector
disklabel -B ${VN}s1

newfs /dev/${VN}s1a

mount /dev/${VN}s1a ${MNT}

vnconfig -c -v ${CDDEV} ${ISO}

#mkdir -p ${CDMNT}
mount -t cd9660 ${CDDEV} ${CDMNT}

for file in ${FILES}; do
cp ${CDMNT}/${file} ${MNT}/${file}
done

for dir in ${DIRS}; do
cpdup -vvv ${CDMNT}/${dir} ${MNT}/${dir}
done

for dir in ${MKDIRS}; do
mkdir -p ${MNT}/${dir}
done

#
# fix /etc/fstab
#

cp ${MNT}/etc/fstab ${MNT}/etc/fstab.old
cat ${MNT}/etc/fstab.old | grep -v "cd9660" > ${MNT}/etc/fstab
echo "${USBDEV}s1a / ufs rw 0 0" >> ${MNT}/etc/fstab

umount ${CDMNT}
umount ${MNT}

vnconfig -u ${CDDEV}

vnconfig -u ${VN}

gzip ${IMG}
    (1-1/1)