-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfbsd_mbr.sh
More file actions
executable file
·153 lines (129 loc) · 3.81 KB
/
fbsd_mbr.sh
File metadata and controls
executable file
·153 lines (129 loc) · 3.81 KB
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
#!/bin/sh
# Maintained at: git@github.com:dareni/shellscripts.git
# 20110925 dki Create ufs.sh from zfs.sh
#bud disk usage
#/ 1G
#/usr/home/jail/usr/local 1G
# /usr/packages mounted
# /usr/ports mounted
#/usr/local 1G
#/usr/ports .5G
#/usr/packages .5G
#/var .5
#swap 1G
#/ 1G
DISK1=ad4; export DISK1
#swap 1G
DISK2=ad6; export DISK2
#/usr 3G
DISK3=ad8; export DISK3
#/var .5G
DISK4=ad10; export DISK4
DISTLOC='/dist/8*'; export DISTLOC
HOSTNAME="dev.localdomain"
IFCONFIG='ifconfig_em0="inet 192.168.1.8 netmask 255.255.255.0"'
#IFCONFIG='ifconfig_em0="DHCP"'
#Use dmesg to get the network device.
# For scp:
# run ifconfig em0 192.168.1.97
# mkdir /usr/bin; cp /dist/usr/bin/ssh /usr/bin
# Creating swap
# zfs create -V 2g zroot/swap
# swapon -a /dev/zvol/zroot/swap
# fstab: /dev/zvol/zroot/swap none swap sw 0 0
if [ "$1" = "" ]; then
echo
echo "usage ufs.sh do_gpart | do_chroot | do_final"
echo "start with do_gpart, this will destroy ${DISK1}"
echo
exit
fi
if [ "$1" = "do_gpart" ]; then
echo "doing gpart"
echo
echo "Hostname: $HOSTNAME"
echo "ifconfig: $IFCONFIG"
echo "Distribution location: $DISTLOC"
echo -n ":NOTE: /dev/${DISK1} will be destroyed! continue \(y/N\):"
read ANS
echo
if [ "$ANS" != "y" ]; then
exit;
fi
#from wblock
# gpart create -s mbr da0
# gpart bootcode -b /boot/mbr da0
# gpart add -t freebsd da0
# gpart set -a active -i 1 da0
# gpart create -s bsd da0s1
# gpart bootcode -b /boot/boot da0s1
# Create the FreeBSD partitions(a,b) in the slice.
# gpart add -t freebsd-ufs -a 4k -s 2g da0s1
# gpart add -t freebsd-swap -a 4k -s 512m da0s1
#
# 1G swap 1024*1024*1024/512
gpart create -s GPT $DISK1
gpart add -b 34 -s 256 -t freebsd-boot $DISK1
gpart add -b 290 -t freebsd-ufs $DISK1
gpart bootcode -b /dist/boot/pmbr -p /dist/boot/gptboot -i 1 $DISK1
#gpart set -a active -i 1 $DISK1
newfs -nL root /dev/${DISK1}p2
newfs -nUL usr /dev/$DISK3
newfs -nUL var /dev/$DISK4
mkdir /newroot
mount /dev/${DISK1}p2 /newroot
mkdir /newroot/usr
mkdir /newroot/var
mount /dev/ufs/usr /newroot/usr
mount /dev/ufs/var /newroot/var
# mount /dev/${DISK1}p1 /root
mkdir /newroot/var/tmp
chmod 1777 /newroot/var/tmp
cd /newroot
ln -s var/tmp tmp
mkdir usr/home
ln -s usr/home home
cd $DISTLOC
export DESTDIR=/newroot
for dir in base catpages dict manpages; \
do (cd $dir ; ./install.sh) ; done
cd kernels; ./install.sh generic
rmdir /newroot/boot/kernel; mv /newroot/boot/GENERIC /newroot/boot/kernel
echo 'sshd_enable="YES"' >> /newroot/etc/rc.conf
echo 'defaultrouter="192.168.1.254"' >> /newroot/etc/rc.conf
echo "hostname=\"$HOSTNAME\"" >> /newroot/etc/rc.conf
echo $IFCONFIG >> /newroot/etc/rc.conf
cp /ufs.sh /newroot
cd /
echo "next:"
echo "1. chroot /newroot"
echo "2. /ufs.sh do_chroot"
fi
if [ "$1" = "do_chroot" ]; then
echo "doing chroot"
if [ -d /newroot ]; then
echo You did not chroot!
exit;
fi
passwd
#pwd_mkdb
tzsetup
cd /etc/mail
make aliases
echo "create users pw useradd .name. -G wheel -m"
echo "next:"
echo "1. exit the chroot."
echo "2. export LD_LIBRARY_PATH=/mnt2/lib"
echo "3. run /ufs.sh do_final"
fi
if [ "$1" = "do_final" ]; then
echo "do final"
cat << EOF > /newroot/etc/fstab
## Device Mountpoint FStype Options Dump Pass#
# /dev/ad0s3b none swap sw 0 0
/dev/ad4p2 / ufs rw 1 1
/dev/ufs/usr /usr ufs rw 2 2
/dev/ufs/var /var ufs rw 2 2
EOF
cd /
fi