32 |
#TOTALLINES=11072 # -> now in images.conf |
#TOTALLINES=11072 # -> now in images.conf |
33 |
|
|
34 |
# standard kernel opts |
# standard kernel opts |
35 |
KERNELOPTS="quiet splash=silent,theme=default" |
KERNELOPTS="quiet video=1024x768" |
36 |
|
|
37 |
|
# grub options |
38 |
|
GRUBLEGACYOPTS="" |
39 |
|
GRUB2OPTS="" |
40 |
|
|
41 |
|
# fdisk options |
42 |
|
FDISKPARTIONBELOW256MB=0 |
43 |
|
|
44 |
# default specialdevices |
# default specialdevices |
45 |
SPECIALDEVICE="" |
SPECIALDEVICE="" |
207 |
run_hardware_detection |
run_hardware_detection |
208 |
case "${SPECIALDEVICE}" in |
case "${SPECIALDEVICE}" in |
209 |
zotac) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
zotac) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
210 |
|
rangee) echo " \n\n\n \\Z2Rangee Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
211 |
*) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
*) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
212 |
esac |
esac |
213 |
|
|
439 |
################################################# |
################################################# |
440 |
run_hardware_detection() |
run_hardware_detection() |
441 |
{ |
{ |
442 |
|
local hwinfo |
443 |
|
|
444 |
|
hwinfo="$(hwinfo --bios --storage)" |
445 |
|
|
446 |
# check for special devices/clients: |
# check for special devices/clients: |
447 |
# if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd |
# if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd |
448 |
local removable=0 |
local removable=0 |
449 |
if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]] |
if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
450 |
then |
then |
451 |
for i in /sys/block/[hs]d*/removable |
for i in /sys/block/[hs]d*/removable |
452 |
do |
do |
456 |
fi |
fi |
457 |
done |
done |
458 |
|
|
459 |
export KERNELOPTS="${KERNELOPTS} rootdelay=8" |
# only add this for grub legacy, grub2 detect these settings on its own |
460 |
|
export GRUBLEGACYOPTS="rootdelay=8" |
461 |
export SPECIALDEVICE="zotac" |
export SPECIALDEVICE="zotac" |
462 |
fi |
fi |
463 |
|
|
464 |
|
# check for special devices/clients: |
465 |
|
# if a rangee and disk ist smaller then 256mb move partion one block further ahead |
466 |
|
if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] |
467 |
|
then |
468 |
|
# for a rangee always define partion startblock +1 |
469 |
|
export FDISKPARTIONBELOW256MB="1" |
470 |
|
export SPECIALDEVICE="rangee" |
471 |
|
export GRUBLEGACYOPTS="" |
472 |
|
fi |
473 |
|
} |
474 |
|
|
475 |
|
hdd_size_below_256mb() |
476 |
|
{ |
477 |
|
local hdd="$1" |
478 |
|
local size |
479 |
|
local retval |
480 |
|
[[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!" |
481 |
|
|
482 |
|
size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') |
483 |
|
if [[ ${size} -le 257000000 ]] |
484 |
|
then |
485 |
|
retval="0" |
486 |
|
else |
487 |
|
retval="1" |
488 |
|
fi |
489 |
|
|
490 |
|
return "${retval}" |
491 |
} |
} |
492 |
|
|
493 |
setup_hdd_partitions_auto() |
setup_hdd_partitions_auto() |
494 |
{ |
{ |
495 |
ROOTHDD="${HDD}1" |
ROOTHDD="${HDD}1" |
496 |
|
|
497 |
|
# run this only if FDISKPARTITIONBELOW256MB is not already 1 |
498 |
|
if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] |
499 |
|
then |
500 |
|
if hdd_size_below_256mb ${HDD} |
501 |
|
then |
502 |
|
FDISKPARTIONBELOW256MB=1 |
503 |
|
else |
504 |
|
FDISKPARTIONBELOW256MB=0 |
505 |
|
fi |
506 |
|
fi |
507 |
|
|
508 |
## delete disk |
## delete disk |
509 |
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die |
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die |
510 |
|
|
511 |
## setup one bootable partition |
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
512 |
#1. n= new disk |
then |
513 |
#2. p= primary disk |
## setup one bootable partition |
514 |
#3. 1= first partition |
#1. n= new disk |
515 |
#4. ''= default sector start |
#2. p= primary disk |
516 |
#5. ''= defaul sector end |
#3. 1= first partition |
517 |
#6. a= bootable flag |
#4. 2= default sector start // small disk needs more space for grub2 mbr sector |
518 |
#7. 1= boot flag for partition 1 |
#5. ''= defaul sector end |
519 |
#8. w= write/quit |
#6. a= bootable flag |
520 |
fdisk ${HDD} &> /dev/null << EOF |
#7. 1= boot flag for partition 1 |
521 |
|
#8. w= write/quit |
522 |
|
fdisk ${HDD} &> /dev/null << EOF |
523 |
|
n |
524 |
|
p |
525 |
|
1 |
526 |
|
2 |
527 |
|
|
528 |
|
a |
529 |
|
1 |
530 |
|
w |
531 |
|
EOF |
532 |
|
else |
533 |
|
## setup one bootable partition |
534 |
|
#1. n= new disk |
535 |
|
#2. p= primary disk |
536 |
|
#3. 1= first partition |
537 |
|
#4. ''= default sector start |
538 |
|
#5. ''= defaul sector end |
539 |
|
#6. a= bootable flag |
540 |
|
#7. 1= boot flag for partition 1 |
541 |
|
#8. w= write/quit |
542 |
|
fdisk ${HDD} &> /dev/null << EOF |
543 |
n |
n |
544 |
p |
p |
545 |
1 |
1 |
549 |
1 |
1 |
550 |
w |
w |
551 |
EOF |
EOF |
552 |
|
fi |
553 |
} |
} |
554 |
|
|
555 |
setup_hdd_partitions_manuell() |
setup_hdd_partitions_manuell() |
607 |
{ |
{ |
608 |
local my_roothdd |
local my_roothdd |
609 |
local grubconf=${INSTALLPATH}/boot/grub/grub.conf |
local grubconf=${INSTALLPATH}/boot/grub/grub.conf |
610 |
local grub2conf=${INSTALLPATH}/boot/grub/grub.cfg |
local grub2conf=/boot/grub/grub.cfg |
611 |
|
|
612 |
# check for grub2 |
# check for grub2 |
613 |
if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]] |
if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]] |
615 |
# needed by grub-mkconfig on the first run |
# needed by grub-mkconfig on the first run |
616 |
if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]] |
if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]] |
617 |
then |
then |
618 |
install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst /boot/grub/video.lst |
install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die |
619 |
|
fi |
620 |
|
|
621 |
|
# set kernelopts |
622 |
|
if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]] |
623 |
|
then |
624 |
|
sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die |
625 |
|
else |
626 |
|
echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALLPATH}/etc/conf.d/grub || die |
627 |
fi |
fi |
628 |
echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.bashrc |
echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die |
629 |
echo "LC_ALL=C grub-mkconfig -o ${grub2conf}" >> ${INSTALLPATH}/root/.bashrc |
echo "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die |
630 |
echo "grub-install --no-floppy ${HDD}" >> ${INSTALLPATH}/root/.bashrc |
echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die |
631 |
|
echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die |
632 |
|
|
633 |
# grub-legacy |
# grub-legacy |
634 |
else |
else |
666 |
echo "# normal boot" >> ${grubconf} || die |
echo "# normal boot" >> ${grubconf} || die |
667 |
echo "title ${KRNVER}" >> ${grubconf} || die |
echo "title ${KRNVER}" >> ${grubconf} || die |
668 |
echo "root (hd0,0)" >> ${grubconf} || die |
echo "root (hd0,0)" >> ${grubconf} || die |
669 |
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS}" >> ${grubconf} || die |
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die |
670 |
if is_initrd_supported |
if is_initrd_supported |
671 |
then |
then |
672 |
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
677 |
echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die |
echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die |
678 |
echo "lock" >> ${grubconf} || die |
echo "lock" >> ${grubconf} || die |
679 |
echo "root (hd0,0)" >> ${grubconf} || die |
echo "root (hd0,0)" >> ${grubconf} || die |
680 |
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 |
681 |
if is_initrd_supported |
if is_initrd_supported |
682 |
then |
then |
683 |
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
687 |
echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die |
echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die |
688 |
echo "lock" >> ${grubconf} || die |
echo "lock" >> ${grubconf} || die |
689 |
echo "root (hd0,0)" >> ${grubconf} || die |
echo "root (hd0,0)" >> ${grubconf} || die |
690 |
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 |
691 |
if is_initrd_supported |
if is_initrd_supported |
692 |
then |
then |
693 |
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
694 |
fi |
fi |
695 |
|
|
696 |
# bootsector schreiben chrooted schreiben (lfs/magellan) |
# bootsector schreiben chrooted schreiben (lfs/magellan) |
697 |
cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF |
cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF |
698 |
/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null |
/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null |
699 |
root (hd0,0) |
root (hd0,0) |
700 |
setup (hd0) |
setup (hd0) |
708 |
mount -t proc proc ${INSTALLPATH}/proc |
mount -t proc proc ${INSTALLPATH}/proc |
709 |
mount -t sysfs sysfs ${INSTALLPATH}/sys |
mount -t sysfs sysfs ${INSTALLPATH}/sys |
710 |
mount -o bind /dev ${INSTALLPATH}/dev |
mount -o bind /dev ${INSTALLPATH}/dev |
711 |
chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i |
chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i |
712 |
umount ${INSTALLPATH}/proc |
umount ${INSTALLPATH}/proc |
713 |
umount ${INSTALLPATH}/sys |
umount ${INSTALLPATH}/sys |
714 |
umount ${INSTALLPATH}/dev |
umount ${INSTALLPATH}/dev |
715 |
rm ${INSTALLPATH}/root/.bashrc |
rm ${INSTALLPATH}/root/.installrc |
716 |
} |
} |
717 |
|
|
718 |
is_initrd_supported() |
is_initrd_supported() |
727 |
# only generate initrds if the cmd exists |
# only generate initrds if the cmd exists |
728 |
is_initrd_supported || return 0 |
is_initrd_supported || return 0 |
729 |
|
|
730 |
cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF |
DISKMODS="sd_mod" |
731 |
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 |
OLDPATAMODS="amd74xx piix sis5513 via82cxxx" |
732 |
|
PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" |
733 |
|
SATAMODS="sata_via sata_sis sata_nv" |
734 |
|
DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" |
735 |
|
case ${SPECIALDEVICE} in |
736 |
|
zotac) FBMODS="" ;; |
737 |
|
rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards |
738 |
|
*) FBMODS="uvesafb" ;; |
739 |
|
esac |
740 |
|
|
741 |
|
# install an appropriate uvesafb.conf |
742 |
|
install -d ${INSTALLPATH}/etc/modprobe.d || die |
743 |
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die |
744 |
|
|
745 |
|
# install an appropriate viafb.conf |
746 |
|
echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die |
747 |
|
|
748 |
|
cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF |
749 |
|
echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd |
750 |
mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null |
mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null |
751 |
exit 0 |
exit 0 |
752 |
CHROOTEOF |
CHROOTEOF |
755 |
mount -t proc proc ${INSTALLPATH}/proc |
mount -t proc proc ${INSTALLPATH}/proc |
756 |
mount -t sysfs sysfs ${INSTALLPATH}/sys |
mount -t sysfs sysfs ${INSTALLPATH}/sys |
757 |
mount -o bind /dev ${INSTALLPATH}/dev |
mount -o bind /dev ${INSTALLPATH}/dev |
758 |
chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i |
chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i |
759 |
umount ${INSTALLPATH}/proc |
umount ${INSTALLPATH}/proc |
760 |
umount ${INSTALLPATH}/sys |
umount ${INSTALLPATH}/sys |
761 |
umount ${INSTALLPATH}/dev |
umount ${INSTALLPATH}/dev |
762 |
rm ${INSTALLPATH}/root/.bashrc |
rm ${INSTALLPATH}/root/.installrc |
763 |
} |
} |
764 |
|
|
765 |
is_uuid_supported() |
is_uuid_supported() |