Commit ac819e46 authored by Martin Peres's avatar Martin Peres
Browse files

initscript: make $container_partition a global variable

To show it is now a global variable, rename it to $CONTAINER_PART_DEV.

This will make it easier to dump the cache in case of corruption, or if
the disk is full.
parent 0b9cfed7
......@@ -100,8 +100,8 @@ function format_disk {
parted --script $1 mklabel gpt
parted --script $1 mkpart primary ext4 2048s 100%
container_partition=`lsblk -no PATH $1 | tail -n -1`
mkfs.ext4 -F -L "$CACHE_PARTITION_LABEL" "$container_partition"
CONTAINER_PART_DEV=`lsblk -no PATH $1 | tail -n -1`
mkfs.ext4 -F -L "$CACHE_PARTITION_LABEL" "$CONTAINER_PART_DEV"
return $?
fi
......@@ -111,7 +111,7 @@ function format_disk {
function find_or_create_cache_partition {
# See if we have an existing block device that would work
container_partition=`find_container_partition` && return 0
CONTAINER_PART_DEV=`find_container_partition` && return 0
# Find a suitable disk
sr_disks_majors=`grep ' sr' /proc/devices | sed "s/^[ \t]*//" | cut -d ' ' -f 1 | tr '\n' ',' | sed 's/,$//'`
......@@ -147,18 +147,18 @@ function try_to_use_cache_device {
label=$(echo "$blk_dev" | cut -d ' ' -f 3)
case $type in
part)
container_partition="$path"
CONTAINER_PART_DEV="$path"
if [ -z "$label" ]; then
log "Formating the partition $container_partition"
mkfs.ext4 -F -L "$CACHE_PARTITION_LABEL" "$container_partition"
log "Formating the partition $CONTAINER_PART_DEV"
mkfs.ext4 -F -L "$CACHE_PARTITION_LABEL" "$CONTAINER_PART_DEV"
return $?
fi
;;
disk)
# Look for the first partition from the drive $1, that has the right cache
container_partition=`lsblk -no PATH,LABEL $path | grep "$CACHE_PARTITION_LABEL" | cut -d ' ' -f 1 | head -n 1`
if [ -n "$container_partition" ]; then
CONTAINER_PART_DEV=`lsblk -no PATH,LABEL $path | grep "$CACHE_PARTITION_LABEL" | cut -d ' ' -f 1 | head -n 1`
if [ -n "$CONTAINER_PART_DEV" ]; then
return 0
else
log "No existing cache partition on the drive $path, recreate the partition table and format a partition"
......@@ -171,11 +171,11 @@ function try_to_use_cache_device {
return 0
}
CONTAINER_PART_DEV=""
function mount_cache_partition {
mkdir "$CONTAINER_MOUNTPOINT"
# Find a suitable cache partition
container_partition=""
case $ARG_CACHE_DEVICE in
none)
log "Do not use a partition cache"
......@@ -189,11 +189,11 @@ function mount_cache_partition {
;;
esac
log "Selected the partition $container_partition as a cache"
log "Selected the partition $CONTAINER_PART_DEV as a cache"
status="DONE"
mount "$container_partition" "$CONTAINER_MOUNTPOINT" || status="FAILED"
log "Mounting the partition $container_partition to $CONTAINER_MOUNTPOINT: $status"
mount "$CONTAINER_PART_DEV" "$CONTAINER_MOUNTPOINT" || status="FAILED"
log "Mounting the partition $CONTAINER_PART_DEV to $CONTAINER_MOUNTPOINT: $status"
return 0
}
......
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