-
Notifications
You must be signed in to change notification settings - Fork 0
/
part.sh
96 lines (88 loc) · 2.64 KB
/
part.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
#!/bin/bash
#
# (c) 2015 Vladimir Smolensky <[email protected]> under the GPL
# http://www.gnu.org/licenses/gpl.html
#
#
#Quick partitioning for gentoo rescue
#
echo -n "Partitioning sda..."
DEVICE_TARGET="/dev/sda"
parted --script ${DEVICE_TARGET} mklabel gpt
parted --script ${DEVICE_TARGET} unit MB mkpart primary linux-swap 2048s 4096M
parted --script ${DEVICE_TARGET} unit MB mkpart primary ext4 4096M 99%
echo "Done."
echo -n "Partitioning sdb..."
DEVICE_TARGET="/dev/sdb"
parted --script ${DEVICE_TARGET} mklabel gpt
parted --script ${DEVICE_TARGET} unit MB mkpart primary ext4 2048s 100%
echo "Done."
echo -n "Formating swap"
mkswap /dev/sda1
echo "Done."
echo -n "Formating root..."
mkfs.ext4 /dev/sda2
echo "Done."
# Input params for next section
# filesystem: xfs, ext4
# raid level: 0,1,5,6,10
# number of disks:
# stripe size:
#
echo "Select filesystem for /cdn"
select FILESYSTEM in xfs ext4;
do
case $FILESYSTEM in
"xfs")
echo "xfs selected"
echo "Enter su and sw params for mkfs.xfs "
echo "sunit = stripe / 512"
echo "swidth = sunit * num data disks"
echo -n "Enter sunit?"
read SUNIT
echo -n "Enter swidth?"
read SWIDTH
mkfs.xfs -d sunit=${SUNIT},swidth=${SWIDTH} /dev/sdb1
break
;;
"ext4")
# stride = chunk / block = 128kB / 4k = 32
# stripe-width = stride * n data disks = 32 * ( (3) - 1 ) = 32 * 2 = 64
#
echo "ext4 selected"
echo "Go to http://busybox.net/~aldot/mkfs_stride.html and get STRIDE AND STRIPE_WIDTH params"
echo "for mkfs.ext4 /dev/sdb1 -b 4096 -E stride=STRIDE,stripe-width=STRIPE-WIDTH"
echo -n "Enter STRIDE?"
read STRIDE
echo -n "Enter STRIPE-WIDTH?"
read STRIPE
mkfs.ext4 /dev/sdb1 -b 4096 -E stride=${STRIDE},stripe-width=${STRIPE}
break
;;
*)
exit
;;
esac
done
mount /dev/sda2 /mnt/gentoo/
if mountpoint /mnt/gentoo; then
echo "Select sync source?"
select SOURCE in host1 host2 host2.com;
do
echo "${SOURCE} selected"
break
done
echo -n "Downloading rsync..."
wget -O /tmp/rsync http://gett.ucdn.com/rsync
chmod +x /tmp/rsync
echo "Done."
echo -n "Syncing root..."
/tmp/rsync -a ${SOURCE}::org/ /mnt/gentoo/
echo "Done."
mkdir -v /mnt/gentoo/sys
mkdir -v /mnt/gentoo/proc
mkdir -v /mnt/gentoo/cdn
mount -o bind /dev/ /mnt/gentoo/dev/
mount -o bind /sys/ /mnt/gentoo/sys/
mount -o bind /proc/ /mnt/gentoo/proc/
fi