...
 
Commits (2)
......@@ -5,22 +5,34 @@ set -ex
DISK=$1
HOSTNAME=$2
EFI=$3
shift 2
if [[ "$HOSTNAME" = "efi" ]]; then
unset HOSTNAME
EFI=efi
fi
[[ -z "$HOSTNAME" ]] && HOSTNAME=$(host $(ip addr | grep 'inet 147.251' | cut -d/ -f1 | sed 's/.*inet //') | sed 's/^.* \([a-z0-9]*\).fi.muni.cz.*$/\1/')
echo "installing $HOSTNAME to $DISK"
getpart() {
if [[ -b ${1}${2} ]]; then
printf ${1}${2}
else
printf ${1}p${2}
fi
}
if [[ "$EFI" = "efi" ]]; then
# GPT table
# new partition 1 for EFI
# new partition 2 spanning rest of the disk
# LVM type partition
echo -e 'o\n' \
'n\n\n+128M\n' \
'n\n\n+512M\n' \
'n\n\n\n' \
'p\n' \
'w\n' \
| fdisk $DISK
PARTN=2
mkfs.fat -F32 $(getpart $DISK 1)
else
# MBR/DOS table
# new partition 1 spanning full disk
......@@ -33,11 +45,7 @@ echo -e 'o\n' \
| fdisk $DISK
PARTN=1
fi
if [[ -b ${DISK}${PARTN} ]]; then
PART=${DISK}${PART}
else
PART=${DISK}p${PART}
fi
PART=$(getpart $DISK $PARTN)
pvcreate $PART
VG=vg.$HOSTNAME
vgcreate $VG $PART
......@@ -51,4 +59,4 @@ debootstrap stable $ROOT http://ftp.cz.debian.org/debian/
cp debootstrap-stage2 $ROOT/root/
genfstab $ROOT > $ROOT/etc/fstab
echo $HOSTNAME > $ROOT/etc/hostname
arch-chroot $ROOT /bin/bash /root/debootstrap-stage2 $DISK "$@"
arch-chroot $ROOT /bin/bash /root/debootstrap-stage2 $DISK $EFI