38 |
GRUBLEGACYOPTS="" |
GRUBLEGACYOPTS="" |
39 |
GRUB2OPTS="" |
GRUB2OPTS="" |
40 |
|
|
41 |
|
# fdisk options |
42 |
|
FDISKPARTIONBELOW256MB=0 |
43 |
|
|
44 |
# default specialdevices |
# default specialdevices |
45 |
SPECIALDEVICE="" |
SPECIALDEVICE="" |
46 |
|
|
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+256mb") echo " \n\n\n \\Z2Rangee Device mit Flashdisk (=< 256MB) erkannt!\\Zn \\" >> ${hwtmp} ;; |
211 |
|
rangee) echo " \n\n\n \\Z2Rangee Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
212 |
*) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
*) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
213 |
esac |
esac |
214 |
|
|
440 |
################################################# |
################################################# |
441 |
run_hardware_detection() |
run_hardware_detection() |
442 |
{ |
{ |
443 |
|
local hwinfo |
444 |
|
|
445 |
|
hwinfo="$(hwinfo --bios --storage)" |
446 |
|
|
447 |
# check for special devices/clients: |
# check for special devices/clients: |
448 |
# 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 |
449 |
local removable=0 |
local removable=0 |
450 |
if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]] |
if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
451 |
then |
then |
452 |
for i in /sys/block/[hs]d*/removable |
for i in /sys/block/[hs]d*/removable |
453 |
do |
do |
461 |
export GRUBLEGACYOPTS="rootdelay=8" |
export GRUBLEGACYOPTS="rootdelay=8" |
462 |
export SPECIALDEVICE="zotac" |
export SPECIALDEVICE="zotac" |
463 |
fi |
fi |
464 |
|
|
465 |
|
# check for special devices/clients: |
466 |
|
# if a rangee and disk ist smaller then 256mb move partion one block further ahead |
467 |
|
if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] |
468 |
|
then |
469 |
|
# for a rangee always define partion startblock +1 |
470 |
|
export FDISKPARTIONBELOW256MB="1" |
471 |
|
export SPECIALDEVICE="rangee" |
472 |
|
export GRUBLEGACYOPTS="" |
473 |
|
fi |
474 |
|
} |
475 |
|
|
476 |
|
hdd_size_below_256mb() |
477 |
|
{ |
478 |
|
local hdd="$1" |
479 |
|
local size |
480 |
|
local retval |
481 |
|
[[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!" |
482 |
|
|
483 |
|
size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') |
484 |
|
if [[ ${size} -le 257000000 ]] |
485 |
|
then |
486 |
|
retval="0" |
487 |
|
else |
488 |
|
retval="1" |
489 |
|
fi |
490 |
|
|
491 |
|
return "${retval}" |
492 |
} |
} |
493 |
|
|
494 |
setup_hdd_partitions_auto() |
setup_hdd_partitions_auto() |
495 |
{ |
{ |
496 |
ROOTHDD="${HDD}1" |
ROOTHDD="${HDD}1" |
497 |
|
|
498 |
|
# run this only if FDISKPARTITIONBELOW256MB is not already 1 |
499 |
|
if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] |
500 |
|
then |
501 |
|
if hdd_size_below_256mb ${HDD} |
502 |
|
then |
503 |
|
FDISKPARTIONBELOW256MB=1 |
504 |
|
else |
505 |
|
FDISKPARTIONBELOW256MB=0 |
506 |
|
fi |
507 |
|
fi |
508 |
|
|
509 |
## delete disk |
## delete disk |
510 |
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die |
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die |
511 |
|
|
512 |
## setup one bootable partition |
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
513 |
#1. n= new disk |
then |
514 |
#2. p= primary disk |
## setup one bootable partition |
515 |
#3. 1= first partition |
#1. n= new disk |
516 |
#4. ''= default sector start |
#2. p= primary disk |
517 |
#5. ''= defaul sector end |
#3. 1= first partition |
518 |
#6. a= bootable flag |
#4. 2= default sector start // small disk needs more space for grub2 mbr sector |
519 |
#7. 1= boot flag for partition 1 |
#5. ''= defaul sector end |
520 |
#8. w= write/quit |
#6. a= bootable flag |
521 |
fdisk ${HDD} &> /dev/null << EOF |
#7. 1= boot flag for partition 1 |
522 |
|
#8. w= write/quit |
523 |
|
fdisk ${HDD} &> /dev/null << EOF |
524 |
|
n |
525 |
|
p |
526 |
|
1 |
527 |
|
2 |
528 |
|
|
529 |
|
a |
530 |
|
1 |
531 |
|
w |
532 |
|
EOF |
533 |
|
else |
534 |
|
## setup one bootable partition |
535 |
|
#1. n= new disk |
536 |
|
#2. p= primary disk |
537 |
|
#3. 1= first partition |
538 |
|
#4. ''= default sector start |
539 |
|
#5. ''= defaul sector end |
540 |
|
#6. a= bootable flag |
541 |
|
#7. 1= boot flag for partition 1 |
542 |
|
#8. w= write/quit |
543 |
|
fdisk ${HDD} &> /dev/null << EOF |
544 |
n |
n |
545 |
p |
p |
546 |
1 |
1 |
550 |
1 |
1 |
551 |
w |
w |
552 |
EOF |
EOF |
553 |
|
fi |
554 |
} |
} |
555 |
|
|
556 |
setup_hdd_partitions_manuell() |
setup_hdd_partitions_manuell() |