Added -e option.
This commit is contained in:
parent
943863d50c
commit
3637a7c0ee
18
pishrink.sh
18
pishrink.sh
|
@ -170,8 +170,9 @@ print_usage() {
|
||||||
Shrink and/or compress the given Linux image.
|
Shrink and/or compress the given Linux image.
|
||||||
Options:
|
Options:
|
||||||
-d Write debug messages in a debug log file
|
-d Write debug messages in a debug log file
|
||||||
-l n Limit size to expand the rootfs during first boot. See "size"
|
-e n Add an extra n (default 100) megabytes to the shrunk image.
|
||||||
-p Purge redudant files (logs, apt archives, dhcp leases...). See argument of the size2fs command. Ex: "-l 4.5G".
|
-l n Limit size to expand the rootfs during first boot. See argument of the size2fs command. Ex: "-l 4.5G".
|
||||||
|
-p Purge redudant files (logs, apt archives, dhcp leases...).
|
||||||
-r Use advanced filesystem repair option if the normal one fails
|
-r Use advanced filesystem repair option if the normal one fails
|
||||||
-n Don't expand filesystem when image is booted the first time
|
-n Don't expand filesystem when image is booted the first time
|
||||||
-z Compress image after shrinking with gzip
|
-z Compress image after shrinking with gzip
|
||||||
|
@ -183,6 +184,7 @@ print_usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
newsize=
|
newsize=
|
||||||
|
extraspace=100
|
||||||
noexpand=false
|
noexpand=false
|
||||||
debug=false
|
debug=false
|
||||||
repair=false
|
repair=false
|
||||||
|
@ -191,8 +193,9 @@ verbose=false
|
||||||
purge=false
|
purge=false
|
||||||
ziptool=""
|
ziptool=""
|
||||||
|
|
||||||
while getopts "adhl:nprvzZ" opt; do
|
while getopts "e:adhl:nprvzZ" opt; do
|
||||||
case "${opt}" in
|
case "${opt}" in
|
||||||
|
e) extraspace=$OPTARG;;
|
||||||
a) parallel=true;;
|
a) parallel=true;;
|
||||||
d) debug=true;;
|
d) debug=true;;
|
||||||
h) print_usage;;
|
h) print_usage;;
|
||||||
|
@ -360,14 +363,7 @@ if [[ $currentsize -eq $minsize ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Add some free space to the end of the filesystem
|
#Add some free space to the end of the filesystem
|
||||||
extra_space=$(($currentsize - $minsize))
|
minsize=$(($minsize + $extraspace * 1024**2 / $blocksize))
|
||||||
logVariables $LINENO extra_space
|
|
||||||
for space in 5000 1000 100; do
|
|
||||||
if [[ $extra_space -gt $space ]]; then
|
|
||||||
minsize=$(($minsize + $space))
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
logVariables $LINENO minsize
|
logVariables $LINENO minsize
|
||||||
|
|
||||||
#Shrink filesystem
|
#Shrink filesystem
|
||||||
|
|
Loading…
Reference in New Issue