From 42cf9a9050b557ba15c3e77c055310b58cccb099 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 21 Dec 2006 14:44:22 +0000 Subject: [PATCH] * Respect the options and fsType attributes. * Remount file systems to allow mount options to be changed dynamically. svn path=/nixos/trunk/; revision=7450 --- configuration/activate-configuration.sh | 4 ++++ configuration/options.nix | 14 +++++--------- upstart-jobs/filesystems.nix | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/configuration/activate-configuration.sh b/configuration/activate-configuration.sh index ca2f6963d761..680af9570ec8 100644 --- a/configuration/activate-configuration.sh +++ b/configuration/activate-configuration.sh @@ -4,6 +4,10 @@ export PATH=/empty for i in @path@; do PATH=$PATH:$i/bin:$i/sbin; done +# Needed by some programs. +ln -sfn /proc/self/fd /dev/fd + + # Set up the statically computed bits of /etc. staticEtc=/etc/static rm -f $staticEtc diff --git a/configuration/options.nix b/configuration/options.nix index ffcd0b61f9e0..ead48d030aa1 100644 --- a/configuration/options.nix +++ b/configuration/options.nix @@ -149,8 +149,7 @@ } { mountPoint = "/data"; device = "/dev/hda2"; - filesystem = "ext3"; - autoMount = true; + fsType = "ext3"; options = "data=journal"; } ]; @@ -160,14 +159,11 @@ boot.autoDetectRootDevice is not set. Each entry in the list is an attribute set with the following fields: mountPoint, device, - filesystem (a file system type recognised by + fsType (a file system type recognised by mount; defaults to - \"auto\"), autoMount (a - boolean indicating whether the file system is mounted - automatically; defaults to true) and - options (the mount options passed to - mount using the flag; - defaults to \"\"). + \"auto\"), and options + (the mount options passed to mount using the + flag; defaults to \"defaults\"). "; } diff --git a/upstart-jobs/filesystems.nix b/upstart-jobs/filesystems.nix index 0c581db96347..7b3ffc4f4e4e 100644 --- a/upstart-jobs/filesystems.nix +++ b/upstart-jobs/filesystems.nix @@ -5,6 +5,8 @@ let # !!! use XML mountPoints = map (fs: fs.mountPoint) fileSystems; devices = map (fs: fs.device) fileSystems; + fsTypes = map (fs: if fs ? fsType then fs.fsType else "auto") fileSystems; + optionss = map (fs: if fs ? options then fs.options else "defaults") fileSystems; in @@ -18,15 +20,23 @@ start on new-devices script mountPoints=(${toString mountPoints}) devices=(${toString devices}) + fsTypes=(${toString fsTypes}) + optionss=(${toString optionss}) for ((n = 0; n < \${#mountPoints[*]}; n++)); do mountPoint=\${mountPoints[$n]} device=\${devices[$n]} + fsType=\${fsTypes[$n]} + options=\${optionss[$n]} # If $device is already mounted somewhere else, unmount it first. prevMountPoint=$(cat /proc/mounts | grep \"^$device \" | sed 's|^[^ ]\\+ \\+\\([^ ]\\+\\).*|\\1|') - if test \"$prevMountPoint\" = \"$mountPoint\"; then continue; fi + if test \"$prevMountPoint\" = \"$mountPoint\"; then + echo \"remounting $device on $mountPoint\" + ${utillinux}/bin/mount -t \"$fsType\" -o remount,\"$options\" \"$device\" \"$mountPoint\" || true + continue + fi if test -n \"$prevMountPoint\"; then echo \"unmount $device from $prevMountPoint\" @@ -36,7 +46,7 @@ script echo \"mounting $device on $mountPoint\" mkdir -p \"$mountPoint\" || true - ${utillinux}/bin/mount \"$device\" \"$mountPoint\" || true + ${utillinux}/bin/mount -t \"$fsType\" -o \"$options\" \"$device\" \"$mountPoint\" || true done end script