-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractica5_parte3_lv.sh
28 lines (27 loc) · 1.04 KB
/
practica5_parte3_lv.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
#!/bin/bash
#798095, Toral Pallas, Hector, M, 3, B
#821259, Pizarro Martínez, Francisco Javier, M, 3, B
if [ $EUID -ne 0 ]; then
echo "Necesita ser admin"
exit 1
fi
while IFS= read -r linea
do
IFS=, ; read -r nombreG nombreV tam Ficheros Montaje <<< "$linea"
direccion=$(lvdisplay "${nombreG}/${nombreV}" -Co "lv_path" | grep "${nombreG}/${nombreV}" | tr -d ' ') &> /dev/null
if [ -z "$direccion" ]
then
echo "El volumen introducido ${nombreV} no existe, va a ser creado..."
lvcreate -n ${nombreV} -L ${tam} ${nombreG}
if [ $? -eq 0 ]
then
mkdir -p "${Montaje}"
direccion=$(lvdisplay "${nombreG}/${nombreV}" -Co "lv_path" | grep "${nombreG}/${nombreV}" | tr -d '[[:space:]]')
echo -e "$direccion\t${Montaje}\t${Ficheros}\tdefaults 0 0" >> /etc/fstab
mkfs.${Ficheros} $direccion && mount $direccion ${Montaje}
fi
else
echo "Ya existe el volumen, se va a ampliar"
lvextend -L ${tam} $direccion && resize2fs $direccion
fi
done