@ -17,9 +17,40 @@ if [ "$IMAGEFORMAT" == "none" ]; then
/usr/sbin/oem-config-prepare --quiet
touch "/var/lib/oem-config/run"
# Make the writable partition grow
echo "LABEL=writable / ext4 defaults,x-systemd.growfs 0 0" >>/etc/fstab
# Update the fstab to include the "discard" option, and
# "x-systemd.growfs" to ensure the root partition is expanded on first
# boot
awk \
-v root_fs_label="writable" \
-v root_fs_options="discard,x-systemd.growfs" \
'
BEGIN { OFS="\t"; count=0; }
# Omit the "UNCONFIGURED" warning if it is still present
/^# UNCONFIGURED FSTAB/ { next; }
# Only modify the first non-comment line where the second field is the
# root and omit multiple root definitions
/^[^#]/ && $2 == "/" {
if (!count) {
$1="LABEL=" root_fs_label;
$4=root_fs_options;
$6="1";
}
count++;
if (count > 1) next;
}
{ print; }
# If we reach the end without seeing a root mount line, add one
END {
if (!count) {
print "LABEL=" root_fs_label, "/", "ext4", root_fs_options, "0", "1";
}
}
' /etc/fstab > /etc/fstab.new
mv /etc/fstab.new /etc/fstab
# Add units for a 1GiB swapfile, generated on first boot
cat << EOF > /lib/systemd/system/mkswap.service