mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-20 16:39:31 +03:00
* 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
3 changed files with 21 additions and 11 deletions
|
@ -4,6 +4,10 @@ export PATH=/empty
|
||||||
for i in @path@; do PATH=$PATH:$i/bin:$i/sbin; done
|
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.
|
# Set up the statically computed bits of /etc.
|
||||||
staticEtc=/etc/static
|
staticEtc=/etc/static
|
||||||
rm -f $staticEtc
|
rm -f $staticEtc
|
||||||
|
|
|
@ -149,8 +149,7 @@
|
||||||
}
|
}
|
||||||
{ mountPoint = "/data";
|
{ mountPoint = "/data";
|
||||||
device = "/dev/hda2";
|
device = "/dev/hda2";
|
||||||
filesystem = "ext3";
|
fsType = "ext3";
|
||||||
autoMount = true;
|
|
||||||
options = "data=journal";
|
options = "data=journal";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -160,14 +159,11 @@
|
||||||
<literal>boot.autoDetectRootDevice</literal> is not set. Each
|
<literal>boot.autoDetectRootDevice</literal> is not set. Each
|
||||||
entry in the list is an attribute set with the following fields:
|
entry in the list is an attribute set with the following fields:
|
||||||
<literal>mountPoint</literal>, <literal>device</literal>,
|
<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
|
<command>mount</command>; defaults to
|
||||||
<literal>\"auto\"</literal>), <literal>autoMount</literal> (a
|
<literal>\"auto\"</literal>), and <literal>options</literal>
|
||||||
boolean indicating whether the file system is mounted
|
(the mount options passed to <command>mount</command> using the
|
||||||
automatically; defaults to <literal>true</literal>) and
|
<option>-o</option> flag; defaults to <literal>\"defaults\"</literal>).
|
||||||
<literal>options</literal> (the mount options passed to
|
|
||||||
<command>mount</command> using the <option>-o</option> flag;
|
|
||||||
defaults to <literal>\"\"</literal>).
|
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ let
|
||||||
# !!! use XML
|
# !!! use XML
|
||||||
mountPoints = map (fs: fs.mountPoint) fileSystems;
|
mountPoints = map (fs: fs.mountPoint) fileSystems;
|
||||||
devices = map (fs: fs.device) 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
|
in
|
||||||
|
|
||||||
|
@ -18,15 +20,23 @@ start on new-devices
|
||||||
script
|
script
|
||||||
mountPoints=(${toString mountPoints})
|
mountPoints=(${toString mountPoints})
|
||||||
devices=(${toString devices})
|
devices=(${toString devices})
|
||||||
|
fsTypes=(${toString fsTypes})
|
||||||
|
optionss=(${toString optionss})
|
||||||
|
|
||||||
for ((n = 0; n < \${#mountPoints[*]}; n++)); do
|
for ((n = 0; n < \${#mountPoints[*]}; n++)); do
|
||||||
mountPoint=\${mountPoints[$n]}
|
mountPoint=\${mountPoints[$n]}
|
||||||
device=\${devices[$n]}
|
device=\${devices[$n]}
|
||||||
|
fsType=\${fsTypes[$n]}
|
||||||
|
options=\${optionss[$n]}
|
||||||
|
|
||||||
# If $device is already mounted somewhere else, unmount it first.
|
# If $device is already mounted somewhere else, unmount it first.
|
||||||
prevMountPoint=$(cat /proc/mounts | grep \"^$device \" | sed 's|^[^ ]\\+ \\+\\([^ ]\\+\\).*|\\1|')
|
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
|
if test -n \"$prevMountPoint\"; then
|
||||||
echo \"unmount $device from $prevMountPoint\"
|
echo \"unmount $device from $prevMountPoint\"
|
||||||
|
@ -36,7 +46,7 @@ script
|
||||||
echo \"mounting $device on $mountPoint\"
|
echo \"mounting $device on $mountPoint\"
|
||||||
|
|
||||||
mkdir -p \"$mountPoint\" || true
|
mkdir -p \"$mountPoint\" || true
|
||||||
${utillinux}/bin/mount \"$device\" \"$mountPoint\" || true
|
${utillinux}/bin/mount -t \"$fsType\" -o \"$options\" \"$device\" \"$mountPoint\" || true
|
||||||
done
|
done
|
||||||
|
|
||||||
end script
|
end script
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue