usbstick.sh

mneumann, 01/08/2009 12:56 AM

Download (1.3 KB)

 
1
IMG=/tmp/df.img
2
MNT=/mnt
3
SZ=450
4
VN=vn0
5

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

    
9
CDMNT=/cdrom
10

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

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

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

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

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

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

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

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

    
35
# write bootsector
36
disklabel -B ${VN}s1 
37

    
38
newfs /dev/${VN}s1a
39

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

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

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

    
47
for file in ${FILES}; do
48
  cp ${CDMNT}/${file} ${MNT}/${file}
49
done
50

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

    
55
for dir in ${MKDIRS}; do
56
  mkdir -p ${MNT}/${dir}
57
done
58

    
59
#
60
# fix /etc/fstab
61
#
62

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

    
67
umount ${CDMNT}
68
umount ${MNT}
69

    
70
vnconfig -u ${CDDEV}
71

    
72
vnconfig -u ${VN}
73

    
74
gzip ${IMG}