forked from plus3it/AMIgen6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrowSetup.sh
executable file
·52 lines (46 loc) · 1.56 KB
/
GrowSetup.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
#
# Add contents necessary to make AMI grow to up-sized root-EBS
#
# Solution inspired by article found at BackSlasher.Net:
# http://blog.backslasher.net/growroot-centos.html
#
# This script modifies the dracut contents to be LVM-compatible.
#
#################################################################
SCRIPTROOT="$(dirname ${0})"
CHROOT="${CHROOT:-/mnt/ec2-root}"
GROWDIR="usr/share/dracut/modules.d/50growroot"
EPELREPO="${1:-epel}"
# Install the grow modules from EPEL
yum --installroot=$CHROOT --enablerepo="${EPELREPO}" install -y dracut-modules-growroot
if [[ $? -ne 0 ]]
then
echo "Failed to install grow dracut-modules" > /dev/null
exit 1
fi
# Use a patched version of the EPEL-hosted grow-script
# - this should be unnecessary if/when BZ #1343571 is resolved
if [[ -d ${CHROOT}/${GROWDIR} ]]
then
cp ${SCRIPTROOT}/growroot.sh ${CHROOT}/${GROWDIR}
if [[ $? -ne 0 ]]
then
printf "Failed to copy patched growroot.sh to " > /dev/stderr
echo "${CHROOT}/${GROWDIR}." > /dev/stderr
exit 1
fi
# Ensure LVM-related binaries are in initramfs
rpm -qlf /sbin/pvs | grep "/sbin/" | sed 's/^\/sbin\//dracut_install /' >> ${CHROOT}/${GROWDIR}/install
if [[ $? -ne 0 ]]
then
echo "Failed to patch dracut 'install' file. Aborting..." > /dev/stderr
exit 1
fi
fi
# Recompile the new AMI's kernel to use the modules
chroot $CHROOT su - root -c \
"rpm -q kernel | sed 's/^kernel-//' | \
xargs -I {} dracut -f -v /boot/initramfs-{}.img {}"
# Clean out the dracut log-file
cat /dev/null > $CHROOT/var/log/dracut.log