summaryrefslogtreecommitdiff
path: root/src/core/libs/lib-blockdevices-filesystems.sh
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2008-11-21 22:06:44 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2008-11-21 22:06:44 +0100
commit07a3d23197d60b357f3b42e0cc2e490d07702982 (patch)
tree6b92b60c76770091f6f971126d16db8500296e50 /src/core/libs/lib-blockdevices-filesystems.sh
parent6b367253b892737547049e8b7791095e957c4490 (diff)
porting of interactive_filesystems WIP
Diffstat (limited to 'src/core/libs/lib-blockdevices-filesystems.sh')
-rw-r--r--src/core/libs/lib-blockdevices-filesystems.sh115
1 files changed, 43 insertions, 72 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 81816e2..7624b2c 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -275,10 +275,10 @@ target_configure_fstab()
}
-# partitions a disk , creates filesystems and mounts them
+# partitions a disk. heavily altered
# $1 device to partition
-# $2 a string of the form: <mountpoint>:<partsize>:<fstype>[:+] (the + is bootable flag)
-partition_deprecated ()
+# $2 a string of the form: <partsize>:<fstype>[:+] (the + is bootable flag)
+partition()
{
debug "Partition called like: partition '$1' '$2'"
[ -z "$1" ] && die_error "partition() requires a device file and a partition string"
@@ -287,56 +287,38 @@ partition_deprecated ()
DEVICE=$1
STRING=$2
- # validate DEVICE
- if [ ! -b "$DEVICE" ]; then
- notify "Device '$DEVICE' is not valid"
- return 1
- fi
+ # validate DEVICE
+ if [ ! -b "$DEVICE" ]; then
+ notify "Device '$DEVICE' is not valid"
+ return 1
+ fi
- # validate DEST
- if [ ! -d "$var_TARGET_DIR" ]; then
- notify "Destination directory '$var_TARGET_DIR' is not valid"
- return 1
- fi
+ target_umountall
- # / required
- if [ $(grep -c '/:' <<< $STRING) -ne 1 ]; then
- notify "Need exactly one root partition"
- return 1
- fi
+ # setup input var for sfdisk
+ for fsspec in $STRING; do
+ fssize=$(echo $fsspec | tr -d ' ' | cut -f1 -d:)
+ fssize_spec=",$fssize"
+ [ "$fssize" = "*" ] && fssize_spec=';'
- rm -f $TMP_FSTAB
+ fstype=$(echo $fsspec | tr -d ' ' | cut -f2 -d:)
+ fstype_spec=","
+ [ "$fstype" = "swap" ] && fstype_spec=",S"
- target_umountall
- # setup input var for sfdisk #TODO: even though $STRING Contains a '/home' part it doesn't go through in the loops.. is this only in vbox?
- for fsspec in $STRING; do
- fssize=$(echo $fsspec | tr -d ' ' | cut -f2 -d:)
- if [ "$fssize" = "*" ]; then
- fssize_spec=';'
- else
- fssize_spec=",$fssize"
- fi
- fstype=$(echo $fsspec | tr -d ' ' | cut -f3 -d:)
- if [ "$fstype" = "swap" ]; then
- fstype_spec=",S"
- else
- fstype_spec=","
- fi
- bootflag=$(echo $fsspec | tr -d ' ' | cut -f4 -d:)
- if [ "$bootflag" = "+" ]; then
- bootflag_spec=",*"
- else
- bootflag_spec=""
- fi
- sfdisk_input="${sfdisk_input}${fssize_spec}${fstype_spec}${bootflag_spec}\n"
- done
- sfdisk_input=$(printf "$sfdisk_input")
+ bootflag=$(echo $fsspec | tr -d ' ' | cut -f3 -d:)
+ bootflag_spec=""
+ [ "$bootflag" = "+" ] && bootflag_spec=",*"
- # invoke sfdisk
- debug "Partition calls: sfdisk $DEVICE -uM >$LOG 2>&1 <<< $sfdisk_input"
- printk off
- infofy "Partitioning $DEVICE"
- sfdisk $DEVICE -uM >$LOG 2>&1 <<EOF
+ sfdisk_input="${sfdisk_input}${fssize_spec}${fstype_spec}${bootflag_spec}\n"
+ done
+
+ sfdisk_input=$(printf "$sfdisk_input")
+
+ # invoke sfdisk
+ debug "Partition calls: sfdisk $DEVICE -uM >$LOG 2>&1 <<< $sfdisk_input"
+ printk off
+ infofy "Partitioning $DEVICE"
+ sfdisk $DEVICE -uM >$LOG 2>&1 <<EOF
$sfdisk_input
EOF
if [ $? -gt 0 ]; then
@@ -346,28 +328,6 @@ EOF
fi
printk on
- # need to mount root first, then do it again for the others
- part=1
- for fsspec in $STRING; do
- mountpoint=$(echo $fsspec | tr -d ' ' | cut -f1 -d:)
- fstype=$(echo $fsspec | tr -d ' ' | cut -f3 -d:)
- if echo $mountpoint | tr -d ' ' | grep '^/$' 2>&1 > /dev/null; then
- _mkfs yes ${DEVICE}${part} "$fstype" "$var_TARGET_DIR" "$mountpoint" || return 1
- fi
- part=$(($part + 1))
- done
-
- # make other filesystems
- part=1
- for fsspec in $STRING; do
- mountpoint=$(echo $fsspec | tr -d ' ' | cut -f1 -d:)
- fstype=$(echo $fsspec | tr -d ' ' | cut -f3 -d:)
- if [ $(echo $mountpoint | tr -d ' ' | grep -c '^/$') -eq 0 ]; then
- _mkfs yes ${DEVICE}${part} "$fstype" "$var_TARGET_DIR" "$mountpoint" || return 1
- fi
- part=$(($part + 1))
- done
-
return 0
}
@@ -414,13 +374,23 @@ fix_filesystems_deprecated ()
# file layout:
#TMP_PARTITIONS
-# disk something-sfdisk-compliant
+# disk partition-scheme
# go over each disk in $TMP_PARTITIONS and partition it
-process_partitions ()
+process_disks ()
+{
+ while read disk scheme
+ do
+ process_disk $disk "$scheme"
+ done < $TMP_PARTITIONS
+}
+
+
+process_disk ()
{
+ partition $1 $2
}
@@ -431,6 +401,7 @@ process_filesystems ()
#TODO: we must make sure we have created all PV's, then reate a vg and the lv's.
#TODO: 'deconstruct' the mounted filesystems, pv's, lv's,vg's,dm_crypt's.. in the right order before doing this (opposite order of construct) and swapoff.
debug "process_filesystems Called. checking all entries in $TMP_FILESYSTEMS"
+ rm -f $TMP_FSTAB
devs_avail=1
while [ $devs_avail = 1 ]
do