]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: warn if disk in use
authorKarel Zak <kzak@redhat.com>
Thu, 15 Apr 2021 12:43:15 +0000 (14:43 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 15 Apr 2021 12:43:15 +0000 (14:43 +0200)
Fixes: https://github.com/karelzak/util-linux/issues/1278
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fdisk.c

index 4e790c1b3ec102ad321216d37c98649159ae3b3d..af2afed3e32cbd293722cb985dc9e338ab3ef56a 100644 (file)
@@ -1140,6 +1140,12 @@ int main(int argc, char **argv)
                if (rc)
                        err(EXIT_FAILURE, _("cannot open %s"), devname);
 
+               if (fdisk_device_is_used(cxt))
+                       fdisk_warnx(cxt, _(
+                       "This disk is currently in use - repartitioning is probably a bad idea.\n"
+                       "It's recommended to umount all file systems, and swapoff all swap\n"
+                       "partitions on this disk.\n"));
+
                fflush(stdout);
 
                if (!fdisk_is_readonly(cxt)