aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2012-07-15 21:13:58 +0200
committerTom Gundersen <teg@jklm.no>2012-07-15 21:13:58 +0200
commit77dfb326d54bb5b66ab23b841c40f4ff1df8f495 (patch)
treef1ba7f7220ccad9389316595c13fd49be05b8116 /functions
parent046d35bac04022eab343e9e6e40a3056c5e653ad (diff)
downloadinitscripts-77dfb326d54bb5b66ab23b841c40f4ff1df8f495.tar.xz
cryptsetup: add blkid check for safety
Before we create a swap partition or a filesystm, check that nothing exists on the underlying block device. Signed-off-by: Tom Gundersen <teg@jklm.no>
Diffstat (limited to 'functions')
-rw-r--r--functions8
1 files changed, 6 insertions, 2 deletions
diff --git a/functions b/functions
index a0cea12..5be90c7 100644
--- a/functions
+++ b/functions
@@ -468,11 +468,15 @@ do_unlock_systemd() {
else
IFS=,
if in_array swap ${options[@]}; then
- if ! mkswap /dev/mapper/$name >/dev/null; then
+ # create swap on the device only if no fs signature exists
+ blkid -p "$2" &>/dev/null
+ if (( $? == 2 )) || ! mkswap /dev/mapper/$name >/dev/null; then
failed=1
fi
elif in_array tmp ${options[@]}; then
- if ! mke2fs /dev/mapper/$name >/dev/null; then
+ # create fs on the device only if no fs signature exists
+ blkid -p "$2" &>/dev/null
+ if (( $? == 2 )) || ! mke2fs /dev/mapper/$name >/dev/null; then
failed=1
fi
fi