forked from mirrors/nixpkgs
* Respect the options and fsType attributes.
* Remount file systems to allow mount options to be changed dynamically. svn path=/nixos/trunk/; revision=7450
This commit is contained in:
parent
b363fc4c57
commit
42cf9a9050
|
@ -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
|
||||
|
|
|
@ -149,8 +149,7 @@
|
|||
}
|
||||
{ mountPoint = "/data";
|
||||
device = "/dev/hda2";
|
||||
filesystem = "ext3";
|
||||
autoMount = true;
|
||||
fsType = "ext3";
|
||||
options = "data=journal";
|
||||
}
|
||||
];
|
||||
|
@ -160,14 +159,11 @@
|
|||
<literal>boot.autoDetectRootDevice</literal> is not set. Each
|
||||
entry in the list is an attribute set with the following fields:
|
||||
<literal>mountPoint</literal>, <literal>device</literal>,
|
||||
<literal>filesystem</literal> (a file system type recognised by
|
||||
<literal>fsType</literal> (a file system type recognised by
|
||||
<command>mount</command>; defaults to
|
||||
<literal>\"auto\"</literal>), <literal>autoMount</literal> (a
|
||||
boolean indicating whether the file system is mounted
|
||||
automatically; defaults to <literal>true</literal>) and
|
||||
<literal>options</literal> (the mount options passed to
|
||||
<command>mount</command> using the <option>-o</option> flag;
|
||||
defaults to <literal>\"\"</literal>).
|
||||
<literal>\"auto\"</literal>), and <literal>options</literal>
|
||||
(the mount options passed to <command>mount</command> using the
|
||||
<option>-o</option> flag; defaults to <literal>\"defaults\"</literal>).
|
||||
";
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue