When auto-formatting ext devices, use the -F flag to make it work with unpartioned disks

This commit is contained in:
Rickard Nilsson 2014-05-09 14:32:12 +02:00
parent ea36f3b868
commit b87b6870f8

View File

@ -187,6 +187,8 @@ in
let let
mountPoint' = escapeSystemdPath fs.mountPoint; mountPoint' = escapeSystemdPath fs.mountPoint;
device' = escapeSystemdPath fs.device; device' = escapeSystemdPath fs.device;
# -F needed to allow bare block device without partitions
mkfsOpts = optional ((builtins.substring 0 3 fs.fsType) == "ext") "-F";
in nameValuePair "mkfs-${device'}" in nameValuePair "mkfs-${device'}"
{ description = "Initialisation of Filesystem ${fs.device}"; { description = "Initialisation of Filesystem ${fs.device}";
wantedBy = [ "${mountPoint'}.mount" ]; wantedBy = [ "${mountPoint'}.mount" ];
@ -201,7 +203,7 @@ in
type=$(blkid -p -s TYPE -o value "${fs.device}" || true) type=$(blkid -p -s TYPE -o value "${fs.device}" || true)
if [ -z "$type" ]; then if [ -z "$type" ]; then
echo "creating ${fs.fsType} filesystem on ${fs.device}..." echo "creating ${fs.fsType} filesystem on ${fs.device}..."
mkfs.${fs.fsType} "${fs.device}" mkfs.${fs.fsType} ${concatStringsSep " " mkfsOpts} "${fs.device}"
fi fi
''; '';
unitConfig.RequiresMountsFor = [ "${dirOf fs.device}" ]; unitConfig.RequiresMountsFor = [ "${dirOf fs.device}" ];