boot-stage-1: Don't run `fsck' when on battery power.
svn path=/nixos/trunk/; revision=13484
This commit is contained in:
parent
7ebc1821f9
commit
477ea7015c
|
@ -138,6 +138,26 @@ fi
|
||||||
if test -n "$debug1devices"; then fail; fi
|
if test -n "$debug1devices"; then fail; fi
|
||||||
|
|
||||||
|
|
||||||
|
# Return true if the machine is on AC power, or if we can't determine
|
||||||
|
# whether it's on AC power.
|
||||||
|
onACPower () {
|
||||||
|
if test -d "/proc/acpi/battery"; then
|
||||||
|
if ls /proc/acpi/battery/BAT[0-9]* > /dev/null 2>&1; then
|
||||||
|
if cat /proc/acpi/battery/BAT*/state \
|
||||||
|
| grep "^charging state" \
|
||||||
|
| grep -q "discharg" ; then
|
||||||
|
false
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function for mounting a file system.
|
# Function for mounting a file system.
|
||||||
mountFS() {
|
mountFS() {
|
||||||
local device="$1"
|
local device="$1"
|
||||||
|
@ -158,6 +178,7 @@ mountFS() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "$mustCheck"; then
|
if test -n "$mustCheck"; then
|
||||||
|
if onACPower; then
|
||||||
FSTAB_FILE="/etc/mtab" fsck -V -v -C -a "$device"
|
FSTAB_FILE="/etc/mtab" fsck -V -v -C -a "$device"
|
||||||
fsckResult=$?
|
fsckResult=$?
|
||||||
|
|
||||||
|
@ -176,6 +197,10 @@ mountFS() {
|
||||||
echo "fsck on $device failed."
|
echo "fsck on $device failed."
|
||||||
fail
|
fail
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
# Don't run `fsck' if the machine is on battery power.
|
||||||
|
echo "on battery power, so \`fsck' not run on \`$device'"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Mount read-writable.
|
# Mount read-writable.
|
||||||
|
|
Loading…
Reference in New Issue