From 431bc87f85ba9885113d946c32840e32b7cca2cd Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Thu, 11 Jul 2019 15:06:30 +0200 Subject: [PATCH] Add LUKS2 error message hint when device too small. If we format LUKS2 device with parameters unsuitable for current metadata device size we usually fail during header areas wipe. It was not clear what the reason actually was. --- lib/setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/setup.c b/lib/setup.c index fa89134e..08160d29 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -1809,6 +1809,8 @@ static int _crypt_format_luks2(struct crypt_device *cd, if (r < 0) { log_err(cd, _("Cannot wipe header on device %s."), mdata_device_path(cd)); + if (dev_size < LUKS2_hdr_and_areas_size(cd->u.luks2.hdr.jobj)) + log_err(cd, _("Device %s is too small."), device_path(crypt_metadata_device(cd))); goto out; }