#!/bin/sh #---------------------------------------------------------------------------- # etc/setup.partition - partition hard disk, called by etc/setup # # Creation: 15.10.2001 fm # Last Update: $Id$ # # Copyright (c) 2001-2007 The Eisfair Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # create partions #---------------------------------------------------------------------------- diskDevice=$1 sizeKB=`sfdisk -s $diskDevice 2>/dev/null` minimumSizeMB=4096 minimumBootSizeMB=64 maximumBootSizeMB=128 # only for XEN minimumSwapSizeMB=256 minimumRootSizeMB=6144 memsizeKB=`cat /proc/meminfo | grep "MemTotal" | sed 's/.* \([0-9]\+\).*/\1/g'` if [ $memsizeKB -gt 1000000 ] then swapsizeMB=`expr $memsizeKB / 1024` # >1GB RAM swap space should be 1x RAM else swapsizeMB=`expr $memsizeKB / 1024 \* 2` # swap space should be 2x RAM fi if [ $swapsizeMB -gt 2048 ] then swapsizeMB=2048 fi if [ -e /xen ] then bootsizeMB="$maximumBootSizeMB" else bootsizeMB="$minimumBootSizeMB" fi rootsizeMB=0 # 0 means: rest restsizeMB=0 boot_idx=1 root_idx=0 data_idx=0 if [ -z "$sizeKB" ] then echo "Cannot determine size of disk $diskDevice. Exit." sleep 100000 exit 1 fi sizeMB=`expr $sizeKB / 1024` if [ $sizeMB -lt $minimumSizeMB ] then mecho -warn "Sorry, your harddisk must have a minimum capacity of $minimumSizeMB MB. Exit." sleep 100000 exit 1 fi # the following code block is deactivated userChoiceOk=false while [ "$userChoiceOk" = "true" ] do echo -e "Swap space in MB [${swapsizeMB}]: \c" read userChoiceSwapSpace case "$userChoiceSwapSpace" in [0-9]+) userChoiceOk=true break ;; esac [ "$userChoiceOk" = "false" ] && continue if [ -n "$userChoiceSwapSpace" ] then if [ $userChoiceSwapSpace -lt $minimumSwapSizeMB ] then mecho -warn "Swap size must be at least $minimumSwapSizeMB." userChoiceOk=false continue fi restsizeMB=`expr $sizeMB - $bootsizeMB - $swapsizeMB` if [ $restsizeMB -lt $minimumRootSizeMB ] then mecho -error -n "With a swap space of $userChoiceSwapSpace MB, " if [ $restsizeMB -le 0 ] then mecho -error "there is no space left for the root/data partition." else mecho -error "the root/data partition will have only a capacity of $restsizeMB MB. But must be at minimum $minimumRootSizeMB MB." fi userChoiceOk=false continue fi swapsizeMB=$userChoiceSwapSpace fi done restsizeMB=`expr $sizeMB - $bootsizeMB - $swapsizeMB` swap_idx=`expr $boot_idx + 1` root_idx=`expr $swap_idx + 1` # if rest size of hd > 9 Gb then create # root partition = 6GB # data partition = rest if [ $restsizeMB -ge 9216 ] then echo "" if [ `installerAsk "Create extra data partition /data" "yes" "yesno"` = "yes" ] then data_format=yes # format data partition rootsizeMB=$minimumRootSizeMB data_idx=`expr $root_idx + 1` restsizeMB=`expr $restsizeMB - $rootsizeMB` else useRestSizeForRootPartition="true" fi else useRestSizeForRootPartition="true" fi echo "" echo "Following partitions will be created" > /tmp/partitions if [ $bootsizeMB -gt 0 ] then echo ",$bootsizeMB,83,*" >>/tmp/partitions # create boot partition fi if [ $swapsizeMB -gt 0 ] then echo ",$swapsizeMB,82" >>/tmp/partitions # create swap partition fi if [ $rootsizeMB -gt 0 ] # 0 means rest then echo ",$rootsizeMB,83" >>/tmp/partitions # create root partition echo ",,8e" >>/tmp/partitions # create data partition (8e=LVM) useRestForRootPartition=false else echo ",,83" >>/tmp/partitions # create root partition useRestForRootPartition=true fi