Commit a461eafa authored by Martin Roukala's avatar Martin Roukala
Browse files

initscript: factor out the partition-formating code

It will be used in a third place soon :)
parent ac819e46
...@@ -95,13 +95,18 @@ function find_container_partition { ...@@ -95,13 +95,18 @@ function find_container_partition {
fi fi
} }
function format_cache_partition {
log "Formating the partition $CONTAINER_PART_DEV"
mkfs.ext4 -F -L "$CACHE_PARTITION_LABEL" "$CONTAINER_PART_DEV"
}
function format_disk { function format_disk {
if [ -n "$1" ]; then if [ -n "$1" ]; then
parted --script $1 mklabel gpt parted --script $1 mklabel gpt
parted --script $1 mkpart primary ext4 2048s 100% parted --script $1 mkpart primary ext4 2048s 100%
CONTAINER_PART_DEV=`lsblk -no PATH $1 | tail -n -1` CONTAINER_PART_DEV=`lsblk -no PATH $1 | tail -n -1`
mkfs.ext4 -F -L "$CACHE_PARTITION_LABEL" "$CONTAINER_PART_DEV" format_cache_partition
return $? return $?
fi fi
...@@ -149,8 +154,7 @@ function try_to_use_cache_device { ...@@ -149,8 +154,7 @@ function try_to_use_cache_device {
part) part)
CONTAINER_PART_DEV="$path" CONTAINER_PART_DEV="$path"
if [ -z "$label" ]; then if [ -z "$label" ]; then
log "Formating the partition $CONTAINER_PART_DEV" format_cache_partition
mkfs.ext4 -F -L "$CACHE_PARTITION_LABEL" "$CONTAINER_PART_DEV"
return $? return $?
fi fi
;; ;;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment