--- alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2011/07/04 18:24:30 2557 +++ alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2013/08/07 10:42:07 5003 @@ -34,8 +34,16 @@ # standard kernel opts KERNELOPTS="quiet video=1024x768" +# grub options +GRUBLEGACYOPTS="" +GRUB2OPTS="" + +# fdisk options +FDISKPARTIONBELOW256MB=0 + # default specialdevices SPECIALDEVICE="" +FORMFACTOR="desktop" # target filesystem FORMAT_FILESYSTEM="ext4" @@ -199,9 +207,15 @@ # other devices run_hardware_detection case "${SPECIALDEVICE}" in - zotac) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;; + zotac*) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;; + rangee) echo " \n\n\n \\Z2Rangee Device erkannt!\\Zn \\" >> ${hwtmp} ;; + maxdata) echo " \n\n\n \\Z2Maxdata Device erkannt!\\Zn \\" >> ${hwtmp} ;; *) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;; esac + if [[ ${FORMFACTOR} = laptop ]] + then + echo " \n\n\n \\ZnFormfactor Laptop erkannt, Powersave Modus 'ondemand' wird aktiviert!\\Zn \\" >> ${hwtmp} ;; + fi echo " \" 13 70" >> ${hwtmp} chmod a+x ${hwtmp} @@ -431,10 +445,14 @@ ################################################# run_hardware_detection() { + local hwinfo + + hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" + # check for special devices/clients: # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd local removable=0 - if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]] + if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] then for i in /sys/block/[hs]d*/removable do @@ -444,28 +462,112 @@ fi done - export KERNELOPTS="${KERNELOPTS} rootdelay=8" - export SPECIALDEVICE="zotac" + # only add this for grub legacy, grub2 detect these settings on its own + export GRUBLEGACYOPTS="rootdelay=8" + # there are to zotac types in the wild, nvidia based gfx and intel + if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] + then + export SPECIALDEVICE="zotac_nvidia" + else + export SPECIALDEVICE="zotac_intel" + fi + fi + + # check for special devices/clients: + # if a rangee and disk ist smaller then 256mb move partion one block further ahead + if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] + then + # for a rangee always define partion startblock +1 + export FDISKPARTIONBELOW256MB="1" + export SPECIALDEVICE="rangee" + export GRUBLEGACYOPTS="" + fi + + # check for special devices/clients: + # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer + if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]] + then + export SPECIALDEVICE="maxdata" + export GRUBLEGACYOPTS="" + fi + + # check for special devices/clients: + # check for laptops and activate cpufreq scaling + if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]] + then + export FORMFACTOR="laptop" + export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand" fi } +hdd_size_below_256mb() +{ + local hdd="$1" + local size + local retval + [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!" + + size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') + if [[ ${size} -le 257000000 ]] + then + retval="0" + else + retval="1" + fi + + return "${retval}" +} + setup_hdd_partitions_auto() { ROOTHDD="${HDD}1" + # run this only if FDISKPARTITIONBELOW256MB is not already 1 + if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] + then + if hdd_size_below_256mb ${HDD} + then + FDISKPARTIONBELOW256MB=1 + else + FDISKPARTIONBELOW256MB=0 + fi + fi + ## delete disk dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die - ## 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 + if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] + 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 @@ -475,6 +577,7 @@ 1 w EOF + fi } setup_hdd_partitions_manuell() @@ -532,7 +635,7 @@ { local my_roothdd local grubconf=${INSTALLPATH}/boot/grub/grub.conf - local grub2conf=${INSTALLPATH}/boot/grub/grub.cfg + local grub2conf=/boot/grub/grub.cfg # check for grub2 if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]] @@ -540,19 +643,20 @@ # needed by grub-mkconfig on the first run if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]] then - install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst /boot/grub/video.lst || die + install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die fi # set kernelopts if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]] then - sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT\)=.*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die + sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die else echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALLPATH}/etc/conf.d/grub || die fi - echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.bashrc || die - echo "LC_ALL=C grub-mkconfig -o ${grub2conf}" >> ${INSTALLPATH}/root/.bashrc || die - echo "grub-install --no-floppy ${HDD}" >> ${INSTALLPATH}/root/.bashrc || die + echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die + echo "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die + echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die + echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die # grub-legacy else @@ -590,7 +694,7 @@ echo "# normal boot" >> ${grubconf} || die echo "title ${KRNVER}" >> ${grubconf} || die echo "root (hd0,0)" >> ${grubconf} || die - echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS}" >> ${grubconf} || die + echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die if is_initrd_supported then echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die @@ -601,7 +705,7 @@ echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die echo "lock" >> ${grubconf} || die echo "root (hd0,0)" >> ${grubconf} || die - echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} hardware-auto-detection" >> ${grubconf} || die + echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || die if is_initrd_supported then echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die @@ -611,14 +715,14 @@ echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die echo "lock" >> ${grubconf} || die echo "root (hd0,0)" >> ${grubconf} || die - echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} alx-reset-settings" >> ${grubconf} || die + echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || die if is_initrd_supported then echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die fi # bootsector schreiben chrooted schreiben (lfs/magellan) - cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF + cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null root (hd0,0) setup (hd0) @@ -632,11 +736,11 @@ mount -t proc proc ${INSTALLPATH}/proc mount -t sysfs sysfs ${INSTALLPATH}/sys mount -o bind /dev ${INSTALLPATH}/dev - chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i + chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i umount ${INSTALLPATH}/proc umount ${INSTALLPATH}/sys umount ${INSTALLPATH}/dev - rm ${INSTALLPATH}/root/.bashrc + rm ${INSTALLPATH}/root/.installrc } is_initrd_supported() @@ -651,8 +755,39 @@ # only generate initrds if the cmd exists is_initrd_supported || return 0 - cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF -echo "MODULES=\"${FORMAT_FILESYSTEM} amd74xx piix sis5513 via82cxxx sd_mod ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via sata_via sata_sis sata_nv\"" > /etc/conf.d/mkinitrd + DISKMODS="sd_mod" + OLDPATAMODS="amd74xx piix sis5513 via82cxxx" + PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" + SATAMODS="sata_via sata_sis sata_nv" + DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" + OTHERMODS="" + case ${SPECIALDEVICE} in + zotac_intel) FBMODS=""; DRMMODS="i915" ;; + zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;; + rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards + # not working with kms enabled drivers -> segfaults + #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer + maxdata) FBMODS="" ;; + *) FBMODS="uvesafb" ;; + esac + + if [[ ${FORMFACTOR} = laptop ]] + then + OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave" + fi + + # install an appropriate uvesafb.conf + install -d ${INSTALLPATH}/etc/modprobe.d || die + echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die + + # install an appropriate viafb.conf + echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die + + # install an appropriate i810fb.conf + echo "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60" > ${INSTALLPATH}/etc/modprobe.d/i810fb.conf || die + + cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF +echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null exit 0 CHROOTEOF @@ -661,11 +796,11 @@ mount -t proc proc ${INSTALLPATH}/proc mount -t sysfs sysfs ${INSTALLPATH}/sys mount -o bind /dev ${INSTALLPATH}/dev - chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i + chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i umount ${INSTALLPATH}/proc umount ${INSTALLPATH}/sys umount ${INSTALLPATH}/dev - rm ${INSTALLPATH}/root/.bashrc + rm ${INSTALLPATH}/root/.installrc } is_uuid_supported() @@ -719,6 +854,19 @@ # install network config skeleton install -m0644 ${INSTALLPATH}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLPATH}/etc/conf.d/ || die + + # intel framebufer quirk + if [[ -e /proc/fb ]] + then + if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] + then + fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') + if [[ ${fbdev} != 0 ]] + then + sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLPATH}/etc/splash/splash.conf || die + fi + fi + fi } install_system_settings_flash()