-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisk-create.sh
executable file
·157 lines (140 loc) · 3.57 KB
/
disk-create.sh
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
# This file is part of Jehanne.
#
# Copyright (C) 2016-2017 Giacomo Tesio <giacomo@tesio.it>
if [ "$JEHANNE" = "" ]; then
echo $0 requires the shell started by ./hacking/devshell.sh
exit 1
fi
if [ "$SYSLINUXMBR" == "" ]; then
export SYSLINUXMBR=/usr/lib/syslinux/mbr/mbr.bin # GNU/Linux Debian way
fi
if [ "$SYSLINUXBIOS" == "" ]; then
export SYSLINUXBIOS=/usr/lib/syslinux/modules/bios/ # GNU/Linux Debian way
fi
if [ ! -d "$SYSLINUXBIOS" ]; then
echo 'Missing $SYSLINUXBIOS: install syslinux-utils or set it to the proper path.'
exit 1
fi
if [ "$TRAVIS_BUILD_DIR" != "" ]; then
echo "Syslinux's version, supported options and file list"
syslinux --version
syslinux --help
ls $SYSLINUXBIOS
ls $SYSLINUXMBR
echo "Fdisk's version, supported options, help"
/sbin/fdisk -v
/sbin/fdisk -h
fi
if [ -d $JEHANNE/hacking/disk-setup/bios/ ]; then
rm $JEHANNE/hacking/disk-setup/bios/*
else
mkdir $JEHANNE/hacking/disk-setup/bios/
fi
if [ -d $SYSLINUXBIOS/com32/ ]; then
cp $SYSLINUXBIOS/com32/lib* $JEHANNE/hacking/disk-setup/bios/
else
cp $SYSLINUXBIOS/lib* $JEHANNE/hacking/disk-setup/bios/
fi
cp $SYSLINUXBIOS/elf.c32 $JEHANNE/hacking/disk-setup/bios/
cp $SYSLINUXBIOS/mboot.c32 $JEHANNE/hacking/disk-setup/bios/
cp $SYSLINUXBIOS/menu.c32 $JEHANNE/hacking/disk-setup/bios/
# Create the data disk
if [ "$DISK" == "" ]; then
export DISK=$JEHANNE/hacking/sample-disk.img
fi
if [ ! -f $DISK ]; then
qemu-img create $DISK 4G
sed -e 's/^\s*\([\+0-9a-zA-Z]*\)[ ].*/\1/' << EOF | /sbin/fdisk $DISK
o #clear partition table
n #new partition
p #primary partition
1 #partition 1
#start at beginning of disk
+40M #reserve 40 megabytes
t #change type
c #W95 FAT32 (LBA)
n #new partition
p #primary partition
2 #partition 2
#start at first free sector
#end at the end of disk
t #change type
2 #partition 2
39 #Plan 9
a #set bootable partition
1 #partition 1
p #print partition table
w #write partition table
q #quit
EOF
export KERNEL=$JEHANNE/hacking/bin/workhorse.32bit
export KERNDIR=$JEHANNE/hacking/bin/
if [ "$DISK_KERNEL" = "" ]; then
export DISK_KERNEL=/arch/$ARCH/kern/jehanne.32bit
fi
if [ "$DISK_INITRD" = "" ]; then
export DISK_INITRD=/arch/amd64/kern/initrd
fi
# install everything
cat << EOF | runqemu
disk/fdisk -p /dev/sdE0/data >> /dev/sdE0/ctl
disk/prep -w -a nvram -a fs /dev/sdE0/plan9
disk/prep -p /dev/sdE0/plan9 >> /dev/sdE0/ctl
cat /dev/sdE0/ctl
disk/format -d /dev/sdE0/dos /hacking/disk-setup/syslinux.cfg /hacking/disk-setup/bios/* $DISK_INITRD $DISK_KERNEL
dd -if /hacking/nvram -of /dev/sdE0/nvram
hjfs -n hjfs -Srf /dev/sdE0/fs
/hacking/disk-setup/configure-hjfs >>/srv/hjfs.cmd
hjfs -n hjfs -Sf /dev/sdE0/fs
mount -c /srv/hjfs /n/newfs
cd /n/newfs
cd cfg
dircp /root/cfg .
cd /n/newfs
mkdir arch
cd arch
dircp /root/arch .
cd /n/newfs
mkdir lib
cd lib
dircp /root/lib .
cd /n/newfs
mkdir mnt
cd mnt
mkdir temp
mkdir term
mkdir acme
mkdir wsys
cd /n/newfs
mkdir usr
cd usr
dircp /root/usr .
cd /n/newfs
mkdir sys
cd sys
mkdir include
mkdir src
dircp /root/sys/src src/
dircp /root/sys/include include/
mkdir log
cd /n/newfs
mkdir qa
cd qa
dircp /root/qa .
cd /n/newfs
lc
$AFTER_DISK_FILL
unmount /n/newfs
echo df >> /srv/hjfs.cmd
echo sync >> /srv/hjfs.cmd
sleep 60
echo halt >> /srv/hjfs.cmd
sleep 20
EOF
OFFSETSECTOR=`echo p |/sbin/fdisk $DISK|grep img1|awk '{print $3}'`
syslinux --offset $(($OFFSETSECTOR*512)) $DISK
dd bs=440 count=1 conv=notrunc if=$SYSLINUXMBR of=$DISK
else
echo Root disk already exists: $DISK
fi