Add filesystem option to automatically grow to the maximum size
This is primarily for EC2 and other cloud environments, where the disk may be bigger than the original image.
This commit is contained in:
@@ -290,10 +290,23 @@ mountFS() {
|
||||
if [ -z "$fsType" ]; then fsType=auto; fi
|
||||
fi
|
||||
|
||||
echo "$device /mnt-root$mountPoint $fsType $options" >> /etc/fstab
|
||||
# Filter out x- options, which busybox doesn't do yet.
|
||||
local optionsFiltered="$(IFS=,; for i in $options; do if [ "${i:0:2}" != "x-" ]; then echo -n $i,; fi; done)"
|
||||
|
||||
echo "$device /mnt-root$mountPoint $fsType $optionsFiltered" >> /etc/fstab
|
||||
|
||||
checkFS "$device" "$fsType"
|
||||
|
||||
# Optionally resize the filesystem.
|
||||
case $options in
|
||||
*x-nixos.autoresize*)
|
||||
if [ "$fsType" = ext2 -o "$fsType" = ext3 -o "$fsType" = ext4 ]; then
|
||||
echo "resizing $device..."
|
||||
resize2fs "$device"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Create backing directories for unionfs-fuse.
|
||||
if [ "$fsType" = unionfs-fuse ]; then
|
||||
for i in $(IFS=:; echo ${options##*,dirs=}); do
|
||||
|
||||
@@ -70,6 +70,12 @@ let
|
||||
copy_bin_and_libs ${pkgs.kmod}/bin/kmod
|
||||
ln -sf kmod $out/bin/modprobe
|
||||
|
||||
# Copy resize2fs if needed.
|
||||
${optionalString (any (fs: fs.autoResize) (attrValues config.fileSystems)) ''
|
||||
# We need mke2fs in the initrd.
|
||||
copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/resize2fs
|
||||
''}
|
||||
|
||||
${config.boot.initrd.extraUtilsCommands}
|
||||
|
||||
# Copy ld manually since it isn't detected correctly
|
||||
@@ -393,7 +399,6 @@ in
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
system.build.bootStage1 = bootStage1;
|
||||
system.build.initialRamdisk = initialRamdisk;
|
||||
system.build.extraUtils = extraUtils;
|
||||
|
||||
Reference in New Issue
Block a user