2019-04-02 18:07:53 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Vars
|
|
|
|
## Define the hard drive to use
|
|
|
|
if [ -b '/dev/sda' ]; then
|
|
|
|
hdd="/dev/sda"
|
|
|
|
else
|
|
|
|
printf '%b\n' "Please check the hard drive to use"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
## Volume Group name to use for LVM
|
|
|
|
vgname="ovhsys"
|
2019-04-02 18:30:31 +02:00
|
|
|
## If the script should manage the partitions (delete, add,…)
|
|
|
|
manage_part=0
|
2019-04-02 18:07:53 +02:00
|
|
|
|
|
|
|
# Partitionning {{{
|
2019-04-02 18:30:31 +02:00
|
|
|
if [ "${manage_part}" -eq 0 ]; then
|
|
|
|
## Remove all old partitions
|
|
|
|
for part_number in 1 2 3 4 5 6 7 8; do
|
|
|
|
[ -b "${hdd}""${part_number}" ] && parted "${hdd}" rm "${part_number}"
|
|
|
|
done
|
2019-04-02 18:07:53 +02:00
|
|
|
|
2019-04-02 18:30:31 +02:00
|
|
|
## Recreate partition (/boot and LV) {{{
|
|
|
|
### Partition type
|
|
|
|
parted "${hdd}" mklabel msdos
|
|
|
|
### /boot
|
|
|
|
parted "${hdd}" mkpart primary 0% 512MB
|
|
|
|
parted "${hdd}" set 1 boot on
|
|
|
|
### LV
|
|
|
|
parted "${hdd}" mkpart primary 4194kB 100%
|
|
|
|
parted "${hdd}" set 2 lvm on
|
|
|
|
sudo pvcreate "${hdd}"2
|
|
|
|
sudo vgcreate "${vgname}" ${hdd}2
|
|
|
|
fi
|
2019-04-02 18:07:53 +02:00
|
|
|
|
|
|
|
## }}}
|
|
|
|
# }}}
|