File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 245
245
case " $1 " in
246
246
start)
247
247
echo " zram-config start $( date +%Y-%m-%d-%H:%M:%S) " >> ${ZLOG}
248
- rm -f ${ZSHARE} /zram-device-list >> ${ZLOG}
248
+ rm -f ${ZSHARE} /zram-device-list.new >> ${ZLOG}
249
249
file=/etc/ztab
250
250
ZTAB_EMPTY=true
251
251
while read -r line; do
@@ -268,6 +268,18 @@ case "$1" in
268
268
ALG=$2
269
269
MEM_SIZE=$3
270
270
DISK_SIZE=$4
271
+ if [ " $1 " = " swap" ]; then
272
+ entry=$( egrep " ^swap" ${ZSHARE} /zram-device-list)
273
+ else
274
+ entry=$( egrep " $1 .*$5 " ${ZSHARE} /zram-device-list)
275
+ fi
276
+ if [ -n " $entry " ]; then
277
+ echo " entry $entry already exists as zram."
278
+ echo $entry >> ${ZSHARE} /zram-device-list.new
279
+ continue
280
+ fi
281
+ mv ${ZSHARE} /zram-device-list.new ${ZSHARE} /zram-device-list
282
+
271
283
case " $1 " in
272
284
swap)
273
285
PRIORITY=$5
@@ -346,7 +358,7 @@ case "$1" in
346
358
;;
347
359
esac
348
360
done < " $file "
349
- rm -v ${ZSHARE} /zram-device-list.rev >> ${ZLOG}
361
+ rm -fv ${ZSHARE} /zram-device-list.rev ${ZSHARE} /zram-device-list >> ${ZLOG}
350
362
;;
351
363
352
364
enable-ephemeral)
You can’t perform that action at this time.
0 commit comments