summary refs log tree commit diff
path: root/nixos/modules/system/boot/stage-1-init.sh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-09-24 18:13:14 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-09-24 19:59:44 +0200
commit9d92bd7845a0fcf895a1e7c4ae95c908be673060 (patch)
treea5c0990def36969e3bc19d4aa9fc97f7dadcc846 /nixos/modules/system/boot/stage-1-init.sh
parentf40c7ed1435d9507868337ae7509fe6d0392498b (diff)
downloadnixlib-9d92bd7845a0fcf895a1e7c4ae95c908be673060.tar
nixlib-9d92bd7845a0fcf895a1e7c4ae95c908be673060.tar.gz
nixlib-9d92bd7845a0fcf895a1e7c4ae95c908be673060.tar.bz2
nixlib-9d92bd7845a0fcf895a1e7c4ae95c908be673060.tar.lz
nixlib-9d92bd7845a0fcf895a1e7c4ae95c908be673060.tar.xz
nixlib-9d92bd7845a0fcf895a1e7c4ae95c908be673060.tar.zst
nixlib-9d92bd7845a0fcf895a1e7c4ae95c908be673060.zip
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.
Diffstat (limited to 'nixos/modules/system/boot/stage-1-init.sh')
-rw-r--r--nixos/modules/system/boot/stage-1-init.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh
index 480bbfa2b07b..516cbb295fa4 100644
--- a/nixos/modules/system/boot/stage-1-init.sh
+++ b/nixos/modules/system/boot/stage-1-init.sh
@@ -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