summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2013-09-17 16:29:19 -0400
committerjim-p <jimp@pfsense.org>2013-09-17 16:29:19 -0400
commitc4eeb1c472b978a3669a2564f9a1e3733965be99 (patch)
tree6af9865c79075a2e2304ac833b7fbe99458e0e97 /usr
parent78db4f1a622d97df6420ee53f2b8224ab2e3a794 (diff)
downloadpfsense-c4eeb1c472b978a3669a2564f9a1e3733965be99.zip
pfsense-c4eeb1c472b978a3669a2564f9a1e3733965be99.tar.gz
Fix ufslabels.sh logic to avoid trying to convert slices which are already using appropriate labels. Fixes #3207
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/sbin/ufslabels.sh41
1 files changed, 34 insertions, 7 deletions
diff --git a/usr/local/sbin/ufslabels.sh b/usr/local/sbin/ufslabels.sh
index aeefe76..8a6c211 100755
--- a/usr/local/sbin/ufslabels.sh
+++ b/usr/local/sbin/ufslabels.sh
@@ -53,9 +53,10 @@ find_fs_device(){
}
FSTAB=/etc/fstab
+NEED_CHANGES=false
cp ${FSTAB} ${FSTAB}.tmp
-ALL_FILESYSTEMS=`/bin/cat /etc/fstab | /usr/bin/grep ufs | /usr/bin/awk '{print $2;}'`
+ALL_FILESYSTEMS=`/bin/cat /etc/fstab | /usr/bin/awk '/ufs/ && !(/dev\/mirror\// || /dev\/ufsid\// || /dev\/label\// || /dev\/geom\//) {print $2;}'`
for FS in ${ALL_FILESYSTEMS}
do
@@ -67,6 +68,7 @@ do
echo "Invalid UFS ID for FS ${FS} ($UFSID), skipping"
else
/usr/bin/sed -i'' -e "s/${DEV}/ufsid\/${UFSID}/g" ${FSTAB}.tmp
+ NEED_CHANGES=true
fi
else
echo "Unable to find device for ${FS}"
@@ -75,12 +77,25 @@ do
echo "FS: ${FS} on device ${DEV} with ufsid ${UFSID}"
done
-find_fs_device swap
-SWAPDEV=${DEV}
-echo "FS: Swap on device ${SWAPDEV}"
+ALL_SWAPFS=`/bin/cat /etc/fstab | /usr/bin/awk '/swap/ && !(/dev\/mirror\// || /dev\/ufsid\// || /dev\/label\// || /dev\/geom\//) {print $1;}'`
+SWAPNUM=0
+for SFS in ${ALL_SWAPFS}
+do
+ DEV=${SFS##/dev/}
+ if [ "${DEV}" != "" ]; then
+ SWAPDEV=${DEV}
+ echo "FS: Swap slice ${SWAPNUM} on device ${SWAPDEV}"
+ if [ "${SWAPDEV}" != "" ]; then
+ /usr/bin/sed -i'' -e "s/${SWAPDEV}/label\/swap${SWAPNUM}/g" ${FSTAB}.tmp
+ NEED_CHANGES=true
+ fi
+ SWAPNUM=`expr ${SWAPNUM} + 1`
+ fi
+done
-if [ "${SWAPDEV}" != "" ]; then
- /usr/bin/sed -i'' -e "s/${SWAPDEV}/label\/swap/g" ${FSTAB}.tmp
+if [ "${NEED_CHANGES}" = "false" ]; then
+ echo Nothing to do, all filesystems and swap already use some form of device-independent labels
+ exit
fi
echo "===================="
@@ -101,8 +116,20 @@ fi
if [ "${COMMIT}" = "y" ] || [ "${COMMIT}" = "Y" ]; then
echo "Disabling swap to apply label"
/sbin/swapoff /dev/${SWAPDEV}
+
echo "Applying label to swap parition"
- /sbin/glabel label swap /dev/${SWAPDEV}
+ SWAPNUM=0
+ for SFS in ${ALL_SWAPFS}
+ do
+ find_fs_device ${SFS}
+ if [ "${DEV}" != "" ]; then
+ SWAPDEV=${DEV}
+ if [ "${SWAPDEV}" != "" ]; then
+ /sbin/glabel label swap${SWAPNUM} /dev/${SWAPDEV}
+ fi
+ SWAPNUM=`expr ${SWAPNUM} + 1`
+ fi
+ done
echo "Activating new fstab"
/bin/mv -f ${FSTAB} ${FSTAB}.old
OpenPOWER on IntegriCloud