--- trunk/installer-simple/bin/installer.sh.in 2015/07/31 09:42:12 2883 +++ trunk/installer-simple/bin/installer.sh.in 2016/06/16 08:43:55 2950 @@ -40,14 +40,50 @@ fi done +# fetch cmdline +for argv in $* +do + case $1 in + --liveroot) shift; cmdliveroot="$1" ;; + --imageroot) shift; cmdimageroot="$1" ;; + --installroot) shift; cmdinstallroot="$1" ;; + --filesystem) shift; cmdformatfilesystem="$1" ;; + --help) + echo "$0 options:" + echo " --liveroot [path] - override default liveroot" + echo " --imageroot [path] - override default imageroot" + echo " --installroot [path] - override default installroot" + echo " --filesystem [fstype] - override default filesystem used to format the disk" + exit 0 ;; + esac + shift +done + ### System/Config Version VERSION="%VERSIONTAG%" TITLE="${DEFAULT_TITLE} - ${VERSION}" +# initialize global variables so they are exportable # some sane defaults -LIVEROOT="${DEFAULT_LIVEROOT}" -IMAGEROOT="${DEFAULT_IMAGEROOT}" -INSTALLROOT="${DEFAULT_INSTALLROOT}" +INSTALL_METHOD="" +if [[ -n ${cmdliveroot} ]] +then + LIVEROOT="${cmdliveroot}" +else + LIVEROOT="${DEFAULT_LIVEROOT}" +fi +if [[ -n ${cmdimageroot} ]] +then + IMAGEROOT="${cmdimageroot}" +else + IMAGEROOT="${DEFAULT_IMAGEROOT}" +fi +if [[ -n ${cmdinstallroot} ]] +then + INSTALLROOT="${cmdinstallroot}" +else + INSTALLROOT="${DEFAULT_INSTALLROOT}" +fi KERNELPKG="${DEFAULT_KERNELPKG}" KERNELOPTS="${DEFAULT_KERNELOPTS}" GRUBLEGACYOPTS="" @@ -55,7 +91,13 @@ FDISKPARTIONBELOW256MB=0 SPECIALDEVICE="" FORMFACTOR="${DEFAULT_FORMFACTOR}" -FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}" +if [[ -n ${cmdformatfilesystem} ]] +then + FORMAT_FILESYSTEM="${cmdformatfilesystem}" +else + FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}" +fi +FLASHDISK=0 # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 ! # -> now in images.conf @@ -81,6 +123,7 @@ is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT} + [[ -n ${SWAPHDD} ]] && swapoff ${SWAPHDD} echo $"Installation aborted." exit 1 @@ -99,28 +142,6 @@ return 0 } -install_mount_rootfs() -{ - local opts - - if [[ -n ${SWAPHDD} ]] - then - swapon ${SWAPHDD} || die - fi - if [[ -n ${ROOTHDD} ]] - then - mount -t ${FORMAT_FILESYSTEM_ROOTHDD} ${ROOTHDD} ${INSTALL_ROOT} || die - fi - if [[ -n ${BOOTHDD} ]] - then - install -d ${INSTALL_ROOT}/boot || die - mount -t ${FORMAT_FILESYSTEM_BOOTHDD} ${BOOTHDD} ${INSTALL_ROOT}/boot || die - fi - - cd ${INSTALL_ROOT} || die -} - - mount_rootfs() { local retval @@ -136,7 +157,7 @@ then echo $"${INSTALLROOT} already mounted" >&2 else - mount "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" + mount -t "${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" fi fi @@ -148,7 +169,7 @@ then echo $"${INSTALLROOT}/boot already mounted" >&2 else - mount "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'" + mount -t "${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'" fi fi } @@ -172,7 +193,6 @@ run_hardware_detection() { local hwinfo - hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" # check for special devices/clients: @@ -180,13 +200,15 @@ local removable=0 if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] then - #for i in /sys/block/[hs]d*/removable - #do - # if [[ $(< ${i}) = 1 ]] - # then - # removable=1 - # fi - #done + for i in /sys/block/[hs]d*/removable + do + if [[ $(< ${i}) = 1 ]] + then + removable=1 + # we assume that all removable disks are flash disks on a zotac + export FLASHDISK=1 + fi + done # smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card' # only add this for grub legacy, grub2 detect these settings on its own @@ -218,6 +240,32 @@ export GRUBLEGACYOPTS="" fi + # check for i845 Chipsets and enable KMS and use 915 drm driver later in initrd + if [[ ! -z $(echo "${hwinfo}" | grep -i i845) ]] + then + export SPECIALDEVICE="i845" + # unset default video=1024x768 opt or the drm driver breaks + export KERNELOPTS="quiet" + export GRUBLEGACYOPTS="" + # enable full kms support + export GRUB2GFXPAYLOAD="keep" + fi + + # check for radeon gfxcards + if [[ ! -z $(echo "${hwinfo}" | grep -i radeon) ]] + then + # enable full kms support + export GRUB2GFXPAYLOAD="keep" + fi + + # requires nomsi to prevent massive IRQ error spam + # see: http://ubuntuforums.org/showthread.php?t=1234983 + if [[ ! -z $(echo "${hwinfo}" | grep -i 'P5VD2-X') ]] || [[ ! -z $(echo "${hwinfo}" | grep -i 'VT8237') ]] || [[ ! -z $(echo "${hwinfo}" | grep -i 'VX700') ]] + then + export SPECIALDEVICE="nomsi" + export KERNELOPTS="${KERNELOPTS} pci=nomsi,noaer" + fi + # check for special devices/clients: # check for laptops and activate cpufreq scaling if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]] @@ -242,20 +290,34 @@ export ALL_CDROMS="$(get_hwinfo cdrom)" } +auto_partition_clear_disk() +{ + if [ -e ${HDD} ] + then + dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die + else + echo "clear disk: device ${HDD} does not exist" >&2 + fi +} + +auto_partition_command() +{ + if [ -e ${HDD} ] + then + fdisk ${HDD} &> /dev/null << EOF +$(echo "${PARTITION_OPTS}") +EOF + else + echo "partition command: device ${HDD} does not exist" >&2 + fi +} + setup_hdd_partitions() { - case "${INSTALL_METHOD}" in - auto) - BOOTHDD="" - SWAPHDD="" - ROOTHDD="${HDD}1" - ;; - normal) - BOOTHDD="${HDD}1" - SWAPHDD="${HDD}2" - ROOTHDD="${HDD}3" - ;; - esac + local partition_number + local partition_type + local partition_start_sector + local partition_size # sanity check - should not happen if is_mounted --device "${ROOTHDD}" @@ -286,49 +348,154 @@ fi ## delete disk - dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die + auto_partition_clear_disk + + # setup partition options + export PARTITION_OPTS - if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] + if [[ -n ${BOOTHDD} ]] then - ## setup one bootable partition - #1. n= new disk - #2. p= primary disk - #3. 1= first partition - #4. 2= default sector start // small disk needs more space for grub2 mbr sector - #5. ''= defaul sector end - #6. a= bootable flag - #7. 1= boot flag for partition 1 - #8. w= write/quit - fdisk ${HDD} &> /dev/null << EOF -n -p -1 -2 - -a -1 -w -EOF - else - ## setup one bootable partition - #1. n= new disk - #2. p= primary disk - #3. 1= first partition - #4. ''= default sector start - #5. ''= defaul sector end - #6. a= bootable flag - #7. 1= boot flag for partition 1 - #8. w= write/quit - fdisk ${HDD} &> /dev/null << EOF -n -p -1 - - -a -1 -w -EOF + # create a boot disk with 50meg size - bootable + partition_type="p" + partition_number="1" + if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] + then + # 2= default sector start // small disk needs more space for grub2 mbr sector + partition_start_sector="2" + else + # '' use default sector start + partition_start_sector="" + fi + # 50meg size + partition_size="+50M" + + # create a boot disk with 50meg size - bootable + # n= new disk + # p= primary disk + # w= write/quit + PARTITION_OPTS="n +${partition_type} +${partition_number} +${partition_start_sector} +${partition_size} +w" + # create the disk + auto_partition_command + + # mark the disk bootable + PARTITION_OPTS="a +${partition_number} +w" + auto_partition_command + + fi + + if [[ -n ${SWAPHDD} ]] + then + # p= primary disk + partition_type="p" + if [[ -n ${BOOTHDD} ]] + then + # boot disk exist, partition 2 + partition_number="2" + else + # boot disk does not exist, partition 1 + partition_number="1" + fi + if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] + then + # fake sector 2 and fdisk finds the next free sector which must be selected with enter + partition_start_sector="2 +" + else + # '' use default sector start + partition_start_sector="" + fi + partition_start_sector="" + # +2G disk size + partition_size="+2G" + + # create a swap disk with 2GB size + PARTITION_OPTS="n +${partition_type} +${partition_number} +${partition_start_sector} +${partition_size} +w" + # create the disk + auto_partition_command + + # mark disk as swap space + PARTITION_OPTS=" +t" + if [[ ${partition_number} != 1 ]] + then + PARTITION_OPTS+=" +${partition_number}" + fi + PARTITION_OPTS+=" +82 +w" + auto_partition_command + fi + + if [[ -n ${ROOTHDD} ]] + then + # p= primary disk + partition_type="p" + if [[ -z ${BOOTHDD} ]] && [[ -z ${SWAPHDD} ]] + then + # boot and swap disk does not exist, partition 1 + partition_number="1" + fi + if [[ -n ${BOOTHDD} ]] || [[ -n ${SWAPHDD} ]] + then + # boot or swap disk exist, partition 2 + partition_number="2" + fi + if [[ -n ${BOOTHDD} ]] && [[ -n ${SWAPHDD} ]] + then + # boot and swap disk does exist, partition 3 + partition_number="3" + fi + if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] + then + if [[ -z ${BOOTHDD} ]] + then + # 2= default sector start // small disk needs more space for grub2 mbr sector + partition_start_sector="2" + else + # fake sector 2 and fdisk finds the next free sector which must be selected with enter + partition_start_sector="2 +" + fi + else + # '' use default sector start + partition_start_sector="" + fi + # '' default sector end + partition_size="" + + # create system disk with remaining space + # w= write/quit + PARTITION_OPTS="n +${partition_type} +${partition_number} +${partition_start_sector} +${partition_size} +w" + # create the disk + auto_partition_command + + # no boot disk? then this is the boot disk + if [[ -z ${BOOTHDD} ]] + then + # mark the disk bootable + PARTITION_OPTS="a +${partition_number} +w" + auto_partition_command + fi fi else cfdisk ${HDD} || dialog_die @@ -360,7 +527,7 @@ umount "${BOOTHDD}" fi - mkfs."${FORMAT_FILESYSTEM}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die + mkfs."${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die fi if [[ -n ${ROOTHDD} ]] @@ -372,7 +539,7 @@ umount "${ROOTHDD}" fi - mkfs."${FORMAT_FILESYSTEM}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die + mkfs."${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die fi } @@ -392,11 +559,11 @@ clearconfig if [[ -n ${BOOTHDD} ]] then - addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t1 1" + addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM_BOOTHDD}\tdefaults,noatime\t1 1" fi if [[ -n ${ROOTHDD} ]] then - addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" + addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tdefaults,noatime\t0 0" fi if [[ -n ${SWAPHDD} ]] then @@ -503,34 +670,46 @@ zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;; rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;; maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;; + i845) message+=$"\n\Z2Intel i845 VGA device detected.\Zn" ;; + nomsi) message+=$"\n\Z2Mainboard with P5VD2-X/VT8237/VX700 chipset detected.\Zn" + message+=$"\n\Z2Disabling Message Signaled Interrupts (MSI) capability of the kernel.\Zn" ;; *) message+=$"\n\ZnCommon device detected.\Zn" ;; esac if [[ ${FORMFACTOR} = laptop ]] then message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn" fi + if [[ ${FLASHDISK} = 1 ]] + then + message+=$"\n\ZnFlash memory detected.\Zn" + message+=$"\n\ZnF2FS will be used as default filesystem within the auto installation mode.\Zn" + fi messagebox -y 12 -h $"Detected hardware:" "${message}" } +task_select_target_hdd() +{ + if [[ -z ${ALL_DISKS} ]] + then + dialog_no_harddrive_found + exit 1 + else + export HDD=$(dialog_select_target_harddrive) + fi +} + task_setup_hdd_partitions() { - local i local retval - if [[ -z ${ALL_DISKS} ]] + if [[ -z ${HDD} ]] then dialog_no_harddrive_found exit 1 else - HDD=$(dialog_select_target_harddrive) - retval=$? - [[ ${retval} -eq 1 ]] && return 1 - if [[ ${retval} -eq 0 ]] - then - dialog_setup_hdd_info - setup_hdd_partitions - fi + dialog_setup_hdd_info + setup_hdd_partitions fi } @@ -561,12 +740,58 @@ local method="$1" task_hardware_detection + task_select_target_hdd case "${method}" in auto) + if [[ ${FLASHDISK} = 1 ]] + then + export BOOTHDD="${HDD}1" + export SWAPHDD="" + export ROOTHDD="${HDD}2" + export FORMAT_FILESYSTEM_BOOTHDD="ext2" + export FORMAT_FILESYSTEM_ROOTHDD="f2fs" + else + # ext4 seems not to be compatible again + if [[ ${FORMAT_FILESYSTEM} = ext4 ]] + then + export BOOTHDD="${HDD}1" + export SWAPHDD="" + export ROOTHDD="${HDD}2" + export FORMAT_FILESYSTEM_BOOTHDD="ext2" + export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" + else + export BOOTHDD="" + export SWAPHDD="" + export ROOTHDD="${HDD}1" + export FORMAT_FILESYSTEM_BOOTHDD="" + export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" + fi + fi export INSTALL_METHOD="${method}" ;; normal) + export BOOTHDD="${HDD}1" + export SWAPHDD="${HDD}2" + export ROOTHDD="${HDD}3" + export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}" + export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" + export INSTALL_METHOD="${method}" + ;; + single) + export BOOTHDD="" + export SWAPHDD="" + export ROOTHDD="${HDD}1" + export FORMAT_FILESYSTEM_BOOTHDD="" + export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" + export INSTALL_METHOD="${method}" + ;; + flash) + export BOOTHDD="${HDD}1" + export SWAPHDD="" + export ROOTHDD="${HDD}2" + export FORMAT_FILESYSTEM_BOOTHDD="ext2" + export FORMAT_FILESYSTEM_ROOTHDD="f2fs" export INSTALL_METHOD="${method}" ;; *)