2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
15 # usage() - Prints the usage of the program
18 usage: $0 [-v volumes]
20 -v List of key pair values for volumes and mount points ( e. g. sda=/var/lib/docker/,sdb=/var/lib/libvirt/ )
24 # mount_external_partition() - Create partition and mount the external volume
25 function mount_external_partition {
26 local dev_name="/dev/$1"
29 sfdisk $dev_name --no-reread << EOF
32 mkfs -t ext4 ${dev_name}1
34 mount ${dev_name}1 $mount_dir
35 echo "${dev_name}1 $mount_dir ext4 errors=remount-ro,noatime,barrier=0 0 1" >> /etc/fstab
38 while getopts "h?v:" opt; do
41 dict_volumes="$OPTARG"
51 if [[ -n "${dict_volumes+x}" ]]; then
52 for kv in ${dict_volumes//,/ } ;do
53 mount_external_partition ${kv%=*} ${kv#*=}