-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcreate-usb.new
executable file
·90 lines (81 loc) · 2.03 KB
/
create-usb.new
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
#
# SPDX-License-Identifier: CDDL-1.0
#
# {{{ CDDL HEADER
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# }}}
#
# Copyright 2025 Peter Tribble
#
#
# To write: find the device with rmformat -l and make sure it's unmounted
# cat 1G.header image.usb | dd bs=1024k of=/dev/rdsk/cXtYdZ
# note, no slice or fdisk partition, just the bare device
#
RELEASE="0m36.1"
DESTDIR=/export/tribblix/dist
ISODIR=/var/tmp
ISONAME=tribblix-${RELEASE}.usb
USIZE=1000000000
case $# in
1)
DESTDIR=${DESTDIR}.$1
ISONAME=tribblix-${RELEASE}-${1}.usb
;;
esac
UFILE=/tmp/${ISONAME}.img.$$
BFS=/tmp/nb.usb.$$
FTAB=/tmp/ftab.$$
mkfile -n ${USIZE} $UFILE
LOFIDEV=`lofiadm -a $UFILE`
LOFINUM=`echo $LOFIDEV|awk -F/ '{print $NF}'`
LOFIRDEV=`echo $LOFIDEV| sed s:/lofi:/rlofi:`
cat > $FTAB <<EOF
12 128 9 34 0 144 63 121 600 1952400
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
EOF
fdisk -F $FTAB $LOFIRDEV
rm $FTAB
echo "y" | mkfs -F pcfs -o fat=32 ${LOFIRDEV}:c
mkdir $BFS
mount -F pcfs ${LOFIDEV}:c $BFS
#
# copy files
#
# pcfs doesn't allow symlinks
# to get any sane performance, you need to do this on tmpfs
#
# at current sizing as of the 0m8 rc:
# /dev/lofi/1:c 939M 886M 54M 95% /tmp/nb.usb.5565
#
cp -r ${DESTDIR}/boot $BFS
#cp -r ${DESTDIR}/pkgs $BFS
cp -r ${DESTDIR}/platform $BFS
#cp ${DESTDIR}/solaris.zlib $BFS
cd /
umount $BFS
lofiadm -d /dev/lofi/$LOFINUM
/bin/ls -lh $UFILE
#
# don't compress in-place to avoid filling /tmp
# we would copy the file over in any event
#
# in this case, most of the data is already compressed, gzip gives better
# overall compression than bzip2
#
gzip -c $UFILE > ${ISODIR}/${ISONAME}.gz
rm ${UFILE}
rmdir $BFS
/bin/ls -lh ${ISODIR}/${ISONAME}.gz