Ensure partition presence using partprobe
This commit is contained in:
parent
ef271779d0
commit
0a5dc5deaa
1 changed files with 7 additions and 16 deletions
|
@ -8,6 +8,7 @@
|
|||
fs = import ./fs.nix;
|
||||
|
||||
diskListVarName = "myDisks";
|
||||
probeScript = "partprobe 2> /dev/null || true";
|
||||
isSwap = partition: builtins.elem partition.type [fs.swap 19];
|
||||
|
||||
mkDiskType = osDisk: types.submodule (
|
||||
|
@ -136,14 +137,7 @@
|
|||
|
||||
create = lib.strings.concatLines [
|
||||
(appendScript "${toString index}: \"$(${sizeOption})\" type=${mkType type}")
|
||||
# Wait for partition to be detected
|
||||
''echo "Waiting for ${partVar} to appear..."''
|
||||
''
|
||||
while true;
|
||||
do
|
||||
[ -b ${partVar} ] && break;
|
||||
done;
|
||||
''
|
||||
probeScript
|
||||
"sudo ${formatScripts.${format}}"
|
||||
];
|
||||
|
||||
|
@ -329,13 +323,7 @@
|
|||
mountScript = lib.strings.concatLines (
|
||||
builtins.concatMap
|
||||
(_: [
|
||||
''echo "Waiting for "${lib.strings.escapeShellArg (partPath _)}" to appear..."''
|
||||
''
|
||||
while true;
|
||||
do
|
||||
[ -b ${lib.strings.escapeShellArg (partPath _)} ] && break
|
||||
done
|
||||
''
|
||||
probeScript
|
||||
(builtins.concatStringsSep " " [
|
||||
"sudo"
|
||||
"mount"
|
||||
|
@ -351,7 +339,10 @@
|
|||
|
||||
swapScript = lib.strings.concatLines (
|
||||
builtins.map
|
||||
(_: "sudo swapon ${partPath _}")
|
||||
(_: ''
|
||||
${probeScript}
|
||||
sudo swapon ${partPath _}
|
||||
'')
|
||||
(builtins.filter (_: _.useSwap) partitions));
|
||||
in lib.strings.concatLines (
|
||||
(builtins.map (_: _.deviceScript) disks) ++ lib.optionals ((builtins.length disks) > 0) [
|
||||
|
|
Loading…
Reference in a new issue