source: install/initdata.sh @ ab298e7

Last change on this file since ab298e7 was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 4.0 KB
Line 
1#!/bin/bash
2#Syn-3 diskinit (C)2005 DatuX
3#-Combine all the specified partitions into a Syn-3 md1 data device
4#-lvm stuff, swap etc will also be initialized.
5#-Partitions should be type FD
6
7.       dialoglib.sh || exit 1
8
9exec 2>&1
10
11PART_COUNT=0
12for PART in $*; do
13        echo -e "\n* Clearing partion $PART:"
14
15        #remove raid partition superblocks
16        #(may fail)
17        mdadm --misc --zero-superblock --force $PART &>/dev/null
18
19        #remove other confusing stuff thats in the partition
20        dd if=/dev/zero of=$PART bs=4k count=1 &>/dev/null || exit 1
21
22        (( PART_COUNT++ ))
23
24done
25
26
27######################## Combine partitions into one raid array or volume group
28
29if [ "$USE_MD" ]; then
30        # Combines all the discs into a RAID1 or RAID5 array:
31        # /dev/md1 will contain LVM partitions
32        # create LVM raid array md1
33        echo -e "\n* Creating Data RAID ARRAY (md1):"
34
35        if [ $PART_COUNT == 1 ]; then
36                # 1 disc: degraded RAID 1
37                MDCMD="mdadm --create --run -l1 -n2 -amd /dev/md1 $* missing"
38        elif [ $PART_COUNT == 2 ]; then
39                # 2 discs: RAID 1
40                MDCMD="mdadm --create --run -l1 -n2 -amd /dev/md1 $*"
41        else
42                # 3 or more discs: RAID 5
43                MDCMD="mdadm --create --run -l5 -n$PART_COUNT -amd /dev/md1 $*"
44        fi
45        $MDCMD || exit 1
46
47        # Try to autodetect the RAID array, just like we do in our initrd.
48        # This will fail if a single disk if we use GPT with a disk thats >2TB it seems?
49        # With this test we make sure it works, before continiuing.
50        echo "* Stopping and re-detecting RAID array, to test the bootprocess:"
51
52        #speed up creation, because we have no udev rules for this:
53        mkdir /dev/md
54        mknod /dev/md/0 b 9 0
55        mknod /dev/md/1 b 9 1
56
57        mdadm --manage /dev/md0 -S || exit 1
58        mdadm --manage /dev/md1 -S || exit 1
59        udevadm settle #for some reason we have to wait..
60        sleep 1
61        mdadm --assemble --scan  || exit 1
62        if ! grep md0 /proc/mdstat >/dev/null || ! grep md1 /proc/mdstat >/dev/null; then
63                echo "ERROR ASSEMBLING RAID ARRAY. (are there unused disks with a different syn3 installation in the system?)"
64                exit 1
65        fi
66       
67
68        # Creates LVM volume group from /dev/md1
69        #init disk
70        echo -e "\n* Creating LVM:"
71        pvcreate -y -ff /dev/md1 || exit 1 #-ff = force
72
73        #create a volume group
74        echo -e "\n* Creating SYN3 VOLUMEGROUP:"
75        vgcreate -y syn3 /dev/md1 || exit 1
76else
77        #Not using MD, so just create a volumegroup by combining the partitions.
78        #init disk
79        echo -e "\n* Creating LVM:"
80        pvcreate -y -ff $* || exit 1 #-ff = force
81
82        #create a volume group
83        echo -e "\n* Creating SYN3 VOLUMEGROUP:"
84        vgcreate -y syn3 $* || exit 1
85fi
86
87
88##################### Activate LVM and create volumes
89
90
91#activate all volume groups
92echo -e "\n* Activating LVM groups:"
93vgchange -a y || exit 1
94
95#create lvm parititons
96echo -e "\n* Creating paritions:"
97lvcreate --yes -L $SIZE_ROOT syn3 -n root || exit 1
98if [ "$SIZE_SWAP" ]; then
99        lvcreate --yes -L $SIZE_SWAP syn3 -n swap || exit 1
100fi
101
102#metadata voor drbd
103lvcreate --yes -n boot.meta -L128M syn3 || exit 1
104lvcreate --yes -n root.meta -L128M syn3 || exit 1
105lvcreate --yes -n home.meta -L128M syn3 || exit 1
106
107#we need to automaticly determine the rest of the free space?
108if [ "$SIZE_HOME" = "" ]; then
109        #temporary reserve the free space, if specified
110        if [ "$SIZE_FREE" ]; then
111                lvcreate --yes -L $SIZE_FREE syn3 -n tmp || exit 1
112        fi
113        #use the extends that are left:
114        EXTENDS=`vgdisplay syn3 -c | cut -f16 -d:`
115        lvcreate --yes -l $EXTENDS syn3 -n home || exit 1
116
117        #remove temporary space
118        if [ "$SIZE_FREE" ]; then
119                sleep 3 #sometimes complains its still busy
120                lvremove -f /dev/syn3/tmp || exit 1
121        fi
122else
123        #Size of home manually specified.
124        lvcreate --yes -L $SIZE_HOME syn3 -n home || exit 1
125fi
126
127
128#make /dev device nodes
129echo -e "\n* Creating DEVICE NODES:"
130lvscan || exit 1
131
132
133####################### Create filesystems
134# Other filesystems will be in LVM group: /dev/syn3/
135
136#create filesystems
137echo -e "\n* Creating filesystems:"
138mkfs.xfs -f -s size=4096  /dev/syn3/root -L ROOT || exit 1
139if [ "$SIZE_SWAP" ]; then
140        mkswap /dev/syn3/swap || exit 1
141fi
142mkfs.xfs -f -s size=4096  /dev/syn3/home -L HOME || exit 1
143
144
145
146echo -e "\n* DONE"
147#release the flying monkeys:
148exit 0
Note: See TracBrowser for help on using the repository browser.