1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/installer/include/read_disk.sh,v 1.2 2008-09-24 11:07:50 niro Exp $ |
# $Id$ |
3 |
|
|
4 |
source include/hwdetection.sh |
source include/hwdetection.sh |
5 |
|
|
19 |
return 0 |
return 0 |
20 |
} |
} |
21 |
|
|
|
# converts partition id to filesystem name |
|
|
partition_id_2_fs_name() |
|
|
{ |
|
|
local x="$1" |
|
|
local id |
|
|
local desc |
|
|
|
|
|
while read id desc |
|
|
do |
|
|
if [[ ${x} = ${id} ]] |
|
|
then |
|
|
echo "${desc}" |
|
|
return 0 |
|
|
fi |
|
|
done << EOF |
|
|
$(/sbin/sfdisk -T) |
|
|
EOF |
|
|
|
|
|
# if we get here the id is unkown |
|
|
echo "unkown" |
|
|
} |
|
|
|
|
22 |
query_partition_disk_setup() |
query_partition_disk_setup() |
23 |
{ |
{ |
24 |
local i |
local i |
48 |
done |
done |
49 |
} |
} |
50 |
|
|
51 |
#ALL_DISKS="$(get_hwinfo disk)" |
# all disks, but exclude all ramdisks |
|
# exclude all ramdisks |
|
52 |
ALL_DISKS="$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d' )" |
ALL_DISKS="$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d' )" |
53 |
ALL_CDROMS="$(get_hwinfo cdrom)" |
ALL_CDROMS="$(get_hwinfo cdrom)" |
54 |
|
|
57 |
# exclude cdroms |
# exclude cdroms |
58 |
nocdrom ${disk} || continue |
nocdrom ${disk} || continue |
59 |
|
|
|
OLDIFS="$IFS" |
|
|
IFS=, |
|
|
|
|
60 |
echo "${disk}|${disk}" |
echo "${disk}|${disk}" |
61 |
while read partition size id boot |
|
62 |
|
# while read partition size id boot |
63 |
|
while read partition blurb |
64 |
do |
do |
|
# partition name |
|
|
partition="$(echo ${partition} | cut -d: -f1 | sed -e s:$'\t'::g -e s:\ ::g)" |
|
65 |
# size |
# size |
66 |
size="$(echo ${size} | sed -e s:size=::g -e s:\ ::g)" |
size="$(sfdisk -s ${partition})" |
67 |
# id but converted |
# fstype |
68 |
id="$(echo ${id} | sed -e s:Id=::g -e s:\ ::g)" |
fstype="$(mount -f --guess-fstype ${partition})" |
|
idname="$(IFS=${OLDIFS} partition_id_2_fs_name ${id})" |
|
69 |
# bootable flag |
# bootable flag |
70 |
boot="$(echo ${boot} | sed -e s:\ ::g -e s:bootable:b:g)" |
boot="$(fdisk -l ${disk} | grep ${partition} | grep \* | sed 's/.*\(*\).*/b/')" |
|
|
|
71 |
# # swap |
# # swap |
72 |
# if [[ ${id} = 82 ]] |
# if [[ ${id} = 82 ]] |
73 |
# then |
# then |
76 |
# export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP} ${disk}:swap:swap" |
# export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP} ${disk}:swap:swap" |
77 |
# else |
# else |
78 |
# mountpoint, but detect any swap |
# mountpoint, but detect any swap |
79 |
mountpoint="$(IFS=${OLDIFS} query_partition_disk_setup --mountpoint ${partition})" |
mountpoint="$(query_partition_disk_setup --mountpoint ${partition})" |
80 |
# filesystem to format |
# filesystem to format |
81 |
format="$(IFS=${OLDIFS} query_partition_disk_setup --filesystem ${partition})" |
format="$(query_partition_disk_setup --filesystem ${partition})" |
82 |
# fi |
# fi |
83 |
|
|
84 |
|
# do not print unkown disk with a size of 1 |
85 |
|
# these disks are containers for secondary partition types |
86 |
|
if [[ ${fstype} = unknown ]] && [ ${size} -eq 1 ] |
87 |
|
then |
88 |
|
continue |
89 |
|
fi |
90 |
|
|
91 |
echo -n "|${partition}" |
echo -n "|${partition}" |
92 |
echo -n "|${size}" |
echo -n "|${size}" |
93 |
echo -n "|${idname}" |
echo -n "|${fstype}" |
94 |
echo -n "|${boot}" |
echo -n "|${boot}" |
95 |
echo -n "|${mountpoint}" |
echo -n "|${mountpoint}" |
96 |
echo -n "|${format}" |
echo -n "|${format}" |
97 |
echo |
echo |
98 |
|
|
99 |
done << EOF |
done << EOF |
100 |
$(${sudo} /sbin/sfdisk --dump ${disk} | sed '1,3d') |
$(get_hwinfo partition | grep ${disk}) |
101 |
EOF |
EOF |
|
IFS="${OLDIFS}" |
|
102 |
done |
done |