i bought a new hard drive, and am trying to setup geli with ZFS on it. geli refuses to write the metadata, when the first partition is too big. so i am trying to delete the first partition, to recreate a smaller one. yet gpart claims my drive is "busy". here's the relevant output: root@mango:/etc/ > gpart delete -i0 da0 gpart: index '0': No such file or directory root@mango:/etc/ > gpart delete -i1 da0 gpart: Device busy root@mango:/etc/ > gpart destroy -F da0 gpart: Device busy root@mango:/etc/ > sysctl kern.geom.debugflags=16 kern.geom.debugflags: 16 -> 16 root@mango:/etc/ > gpart show da0 => 40 7814037088 da0 GPT (3.6T) 40 7814037080 1 freebsd-zfs (3.6T) 7814037120 8 - free - (4.0K) root@mango:/etc/ > dd if=/dev/zero of=/dev/da0 bs=1M count=100 100+0 records in 100+0 records out 104857600 bytes transferred in 2.630170 secs (39867229 bytes/sec) root@mango:/etc/ > gpart show da0 => 40 7814037088 da0 GPT (3.6T) 40 7814037080 1 freebsd-zfs (3.6T) 7814037120 8 - free - (4.0K) root@mango:/etc/ > gpart destroy -F da0 gpart: Device busy root@mango:/etc/ > mount sys/ROOT/default on / (zfs, local, noatime, nfsv4acls) devfs on /dev (devfs, local, multilabel) data on /data (zfs, local, noatime, nfsv4acls) backup/default on /mnt (zfs, local, noatime, nfsv4acls) sys/ports on /usr/ports (zfs, local, noatime, nfsv4acls) sys/src on /usr/src (zfs, local, noatime, nfsv4acls) root@mango:/etc/ > umount /dev/da0 umount: /dev/da0: unknown file system root@mango:/etc/ > fuser /dev/da0 /dev/da0: root@mango:/etc/ > uname -a FreeBSD mango 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r275830: Wed Dec 17 13:33:45 CET 2014 root@mango:/usr/obj/usr/src/sys/GENERIC-NODEBUG amd64
FYI: after i rebooted the device is working just fine.
Just installed FreeBSD 11 RC1 on da1, da2, da3 (mirrored zpool) without swap, intending to add swap space on da0 after installation. At the end of the installer I went to the console to add swap space, starting with "gpart destroy da0" (it contained an NTFS partition). gpart says "Device busy". So I rebooted and after the first bootup I retried. Still "Device busy". Rebooted a third time. Device still "busy". Then I zeroed the first gigabyte of da0 using dd. After this, "gpart show" did not list da0 anymore. Now "gpart destroy da0" resulted in "gpart: arg0 'da0': Invalid argument". However, "gpart create -s GPT da0" now succeeded "da0 created". I guess this bug only occurs if the system is being installed not on da0 but on da1 or higher. So it could probably be reproduced by installing FreeBSD onto da1+ and then attempting to manually repartition da0. Hope this helps.
(In reply to Stefan from comment #2) > Just installed FreeBSD 11 RC1 on da1, da2, da3 (mirrored zpool) without > swap, intending to add swap space on da0 after installation. > At the end of the installer I went to the console to add swap space, > starting with "gpart destroy da0" (it contained an NTFS partition). gpart > says "Device busy". It is busy, because before destroying a partition table you must to delete all its partitions or use -F flag. > I guess this bug only occurs if the system is being installed not on da0 but > on da1 or higher. So it could probably be reproduced by installing FreeBSD > onto da1+ and then attempting to manually repartition da0. This isn't bug. It works as expected.
Thank you for the quick reply, Andrey. Sounds plausible, but then the message "Device busy" is very misleading imho. Suggestion: Could the message maybe changed to something more informative and less confusing like "Please delete the partitions first or force destroying the partition table using the -F flag"?
I agree, this is pretty annoying. I've filed a DR (https://reviews.freebsd.org/D12336) to include more elaborate example of how to properly delete partitions and partition table in the gpart(8) manual page.
gpart(8) manual page was updated to include example of how to properly delete partitions and partitioning scheme as of base r323764, hence I'm closing this PR.