You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.5 KiB

# Copyright 2014 Hewlett-Packard Development Company, L.P.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Because images may not have all the things we need.
if which apt-get ; then
apt-get update && apt-get install -y lvm2
elif which yum ; then
yum -y install lvm2
# Sanity check that we don't break anything that already has an fs.
if ! blkid | grep $DEVICE ; then
set -e
parted --script $DEVICE mklabel msdos mkpart primary 0% 100% set 1 lvm on
partprobe -s $DEVICE
pvcreate ${DEVICE}1
vgcreate main ${DEVICE}1
lvcreate -l 100%FREE -n $FS_LABEL main
mkfs.ext4 -m 0 -j -L $FS_LABEL /dev/main/$FS_LABEL
tune2fs -i 0 -c 0 /dev/main/$FS_LABEL
# Remove existing fstab entries for this device.
perl -nle "m,/dev/main/$FS_LABEL, || print" -i /etc/fstab
if [ ! -d $MOUNT_PATH ] ; then
mkdir -p $MOUNT_PATH
echo "/dev/main/$FS_LABEL $MOUNT_PATH ext4 errors=remount-ro,barrier=0 0 2" >> /etc/fstab
mount -a
exit 1