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 /etc/installer.conf |
5 |
|
source ${INSTALLER_DIR}/include/hwdetection.sh |
6 |
|
|
7 |
# use C locale |
# use C locale |
8 |
export LC_ALL=C |
export LC_ALL=C |
20 |
return 0 |
return 0 |
21 |
} |
} |
22 |
|
|
|
# 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" |
|
|
} |
|
|
|
|
23 |
query_partition_disk_setup() |
query_partition_disk_setup() |
24 |
{ |
{ |
25 |
local i |
local i |
29 |
local command="$1" |
local command="$1" |
30 |
local given_partition="$2" |
local given_partition="$2" |
31 |
|
|
|
# |
|
|
#--overwrite |
|
|
|
|
32 |
for i in ${PARTITION_DISK_SETUP} |
for i in ${PARTITION_DISK_SETUP} |
33 |
do |
do |
34 |
partition=$(echo ${i} | cut -d: -f1) |
partition=$(echo ${i} | cut -d: -f1) |
46 |
done |
done |
47 |
} |
} |
48 |
|
|
49 |
#ALL_DISKS="$(get_hwinfo disk)" |
# all disks, but exclude all ramdisks |
|
# exclude all ramdisks |
|
50 |
ALL_DISKS="$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d' )" |
ALL_DISKS="$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d' )" |
51 |
ALL_CDROMS="$(get_hwinfo cdrom)" |
ALL_CDROMS="$(get_hwinfo cdrom)" |
52 |
|
|
55 |
# exclude cdroms |
# exclude cdroms |
56 |
nocdrom ${disk} || continue |
nocdrom ${disk} || continue |
57 |
|
|
|
OLDIFS="$IFS" |
|
|
IFS=, |
|
|
|
|
58 |
echo "${disk}|${disk}" |
echo "${disk}|${disk}" |
59 |
while read partition size id boot |
|
60 |
|
while read partition blurb |
61 |
do |
do |
|
# partition name |
|
|
partition="$(echo ${partition} | cut -d: -f1 | sed -e s:$'\t'::g -e s:\ ::g)" |
|
62 |
# size |
# size |
63 |
size="$(echo ${size} | sed -e s:size=::g -e s:\ ::g)" |
size="$(sfdisk -s ${partition})" |
64 |
# id but converted |
# fstype |
65 |
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})" |
|
66 |
# bootable flag |
# bootable flag |
67 |
boot="$(echo ${boot} | sed -e s:\ ::g -e s:bootable:b:g)" |
boot="$(fdisk -l ${disk} | grep ${partition} | grep \* | sed 's/.*\(*\).*/b/')" |
68 |
|
# mountpoint, but detect any swap |
69 |
# # swap |
mountpoint="$(query_partition_disk_setup --mountpoint ${partition})" |
70 |
# if [[ ${id} = 82 ]] |
# filesystem to format |
71 |
# then |
format="$(query_partition_disk_setup --filesystem ${partition})" |
72 |
# mountpoint="swap" |
|
73 |
# format="swap" |
# do not print unkown disk with a size of 1 |
74 |
# export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP} ${disk}:swap:swap" |
# these disks are containers for secondary partition types |
75 |
# else |
if [[ ${fstype} = unknown ]] && [ ${size} -eq 1 ] |
76 |
# mountpoint, but detect any swap |
then |
77 |
mountpoint="$(IFS=${OLDIFS} query_partition_disk_setup --mountpoint ${partition})" |
continue |
78 |
# filesystem to format |
fi |
|
format="$(IFS=${OLDIFS} query_partition_disk_setup --filesystem ${partition})" |
|
|
# fi |
|
79 |
|
|
80 |
echo -n "|${partition}" |
echo -n "|${partition}" |
81 |
echo -n "|${size}" |
echo -n "|${size}" |
82 |
echo -n "|${idname}" |
echo -n "|${fstype}" |
83 |
echo -n "|${boot}" |
echo -n "|${boot}" |
84 |
echo -n "|${mountpoint}" |
echo -n "|${mountpoint}" |
85 |
echo -n "|${format}" |
echo -n "|${format}" |
86 |
echo |
echo |
87 |
|
|
88 |
done << EOF |
done << EOF |
89 |
$(${sudo} /sbin/sfdisk --dump ${disk} | sed '1,3d') |
$(get_hwinfo partition | grep ${disk}) |
90 |
EOF |
EOF |
|
IFS="${OLDIFS}" |
|
91 |
done |
done |