forked from r0b0/debian-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_make_image_lib.sh
39 lines (36 loc) · 1.08 KB
/
_make_image_lib.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function notify {
echo $@
read -p "Enter to continue"
}
function shrink_btrfs_filesystem {
local filesystem=$1
notify balancing and shrinking the filesystem ${filesystem}
btrfs balance start -dusage=90 ${filesystem}
true
while [ $? -eq 0 ]; do
btrfs filesystem resize -1G ${filesystem}
done
true
while [ $? -eq 0 ]; do
btrfs filesystem resize -100M ${filesystem}
done
true
while [ $? -eq 0 ]; do
btrfs filesystem resize -10M ${filesystem}
done
btrfs filesystem usage -m ${filesystem} |grep slack | cut -f 3 | tr -d '[:space:]' > device_slack.txt
local DEVICE_SLACK=$(cat device_slack.txt)
echo device slack is ${DEVICE_SLACK}
}
function shrink_partition {
local slack=$1
local disk=$2
local partition_nr=$3
if [ ! -f "partition_${partition_nr}_shrunk.txt" ]; then
notify shrinking partition ${disk}${partition_nr} by ${slack}
echo ", -${slack}" | sfdisk ${disk} -N ${partition_nr}
notify checking the filesystem after partition shrink
btrfs check "${disk}${partition_nr}"
touch "partition_${partition_nr}_shrunk.txt"
fi
}