Merge pull request #234223 from alyssais/stage-1-bind-file
This commit is contained in:
commit
230a3705fc
2 changed files with 48 additions and 1 deletions
|
@ -114,6 +114,28 @@ waitDevice() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create the mount point if required.
|
||||||
|
makeMountPoint() {
|
||||||
|
local device="$1"
|
||||||
|
local mountPoint="$2"
|
||||||
|
local options="$3"
|
||||||
|
|
||||||
|
local IFS=,
|
||||||
|
|
||||||
|
# If we're bind mounting a file, the mount point should also be a file.
|
||||||
|
if ! [ -d "$device" ]; then
|
||||||
|
for opt in $options; do
|
||||||
|
if [ "$opt" = bind ] || [ "$opt" = rbind ]; then
|
||||||
|
mkdir -p "$(dirname "/mnt-root$mountPoint")"
|
||||||
|
touch "/mnt-root$mountPoint"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -m 0755 -p "/mnt-root$mountPoint"
|
||||||
|
}
|
||||||
|
|
||||||
# Mount special file systems.
|
# Mount special file systems.
|
||||||
specialMount() {
|
specialMount() {
|
||||||
local device="$1"
|
local device="$1"
|
||||||
|
@ -384,7 +406,7 @@ mountFS() {
|
||||||
|
|
||||||
info "mounting $device on $mountPoint..."
|
info "mounting $device on $mountPoint..."
|
||||||
|
|
||||||
mkdir -p "/mnt-root$mountPoint"
|
makeMountPoint "$device" "$mountPoint" "$optionsPrefixed"
|
||||||
|
|
||||||
# For ZFS and CIFS mounts, retry a few times before giving up.
|
# For ZFS and CIFS mounts, retry a few times before giving up.
|
||||||
# We do this for ZFS as a workaround for issue NixOS/nixpkgs#25383.
|
# We do this for ZFS as a workaround for issue NixOS/nixpkgs#25383.
|
||||||
|
|
|
@ -6,6 +6,31 @@
|
||||||
with import ../lib/testing-python.nix { inherit system pkgs; };
|
with import ../lib/testing-python.nix { inherit system pkgs; };
|
||||||
with pkgs.lib;
|
with pkgs.lib;
|
||||||
{
|
{
|
||||||
|
bind = makeTest {
|
||||||
|
name = "non-default-filesystem-bind";
|
||||||
|
|
||||||
|
nodes.machine = { ... }: {
|
||||||
|
virtualisation.writableStore = false;
|
||||||
|
|
||||||
|
virtualisation.fileSystems."/test-bind-dir/bind" = {
|
||||||
|
device = "/";
|
||||||
|
neededForBoot = true;
|
||||||
|
options = [ "bind" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualisation.fileSystems."/test-bind-file/bind" = {
|
||||||
|
depends = [ "/nix/store" ];
|
||||||
|
device = builtins.toFile "empty" "";
|
||||||
|
neededForBoot = true;
|
||||||
|
options = [ "bind" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
btrfs = makeTest
|
btrfs = makeTest
|
||||||
{
|
{
|
||||||
name = "non-default-filesystems-btrfs";
|
name = "non-default-filesystems-btrfs";
|
||||||
|
|
Loading…
Reference in a new issue