-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-install.sh
executable file
·36 lines (31 loc) · 1.15 KB
/
pre-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c)
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
set -o pipefail
set -o errexit
set -o nounset
if [[ ${RELENG_DEBUG:-false} == "true" ]]; then
set -o xtrace
fi
# mount_dev() - Formats and mounts storage devices
function mount_dev {
dev_name="/dev/$1"
mount_dir="$2"
sudo mkdir -p "$mount_dir"
# Format registry volume
if lsblk --list | grep -q "^${dev_name##*/} .*disk" && ! mount | grep -q "${dev_name}1 on $mount_dir"; then
sudo sfdisk "$dev_name" --no-reread <<EOF
;
EOF
sudo mkfs -t ext4 "${dev_name}1"
sudo mount "${dev_name}1" "$mount_dir"
echo "${dev_name}1 $mount_dir ext4 errors=remount-ro,noatime,barrier=0 0 1" | sudo tee --append /etc/fstab
fi
}
mount_dev "$1" "$2"