Issue with gpart "Device Busy"
Paul Mather
paul at gromit.dlib.vt.edu
Thu Apr 16 19:53:21 UTC 2020
On Apr 15, 2020, at 2:35 PM, ian at dijix.com wrote:
> I have an issue with gpart, it will not let me delete partition ada0p2
> responding with “Device Busy”
> The man page gpart(8) says this may be shown if a partition exists but I
> cannot seem to delete partition 2 in my case via gpart delete or gpart
> destroy
>
> This is a used disk but new to the machine, I can modify the partition
> type and create partitions before and after partition 2 but I cannot
> delete it.
>
> Here’s what I have tried so far:
>
>
> root at beastie:~ # gpart show
> => 34 1250263661 ada0 GPT (596G)
> 34 409606 - free - (200M)
> 409640 1249591904 2 freebsd-ufs (596G)
> 1250001544 262151 - free - (128M)
>
> => 40 976773088 ada1 GPT (466G)
> 40 1024 1 freebsd-boot (512K)
> 1064 984 - free - (492K)
> 2048 4194304 2 freebsd-swap (2.0G)
> 4196352 972576768 3 freebsd-zfs (464G)
> 976773120 8 - free - (4.0K)
>
> root at beastie:~ # gpart delete -i2 ada0
> gpart: Device busy
>
> root at beastie:~ # gpart add -t freebsd-boot ada0
> ada0p1 added
>
> root at beastie:~ # gpart show
> => 34 1250263661 ada0 GPT (596G)
> 34 409606 1 freebsd-boot (200M)
> 409640 1249591904 2 freebsd-ufs (596G)
> 1250001544 262151 - free - (128M)
>
> => 40 976773088 ada1 GPT (466G)
> 40 1024 1 freebsd-boot (512K)
> 1064 984 - free - (492K)
> 2048 4194304 2 freebsd-swap (2.0G)
> 4196352 972576768 3 freebsd-zfs (464G)
> 976773120 8 - free - (4.0K)
>
> root at beastie:~ # gpart delete -i2 ada0
> gpart: Device busy
>
> root at beastie:~ # gpart delete -i1 ada0
> ada0p1 deleted
>
> root at beastie:~ # gpart show
> => 34 1250263661 ada0 GPT (596G)
> 34 409606 - free - (200M)
> 409640 1249591904 2 freebsd-ufs (596G)
> 1250001544 262151 - free - (128M)
>
> => 40 976773088 ada1 GPT (466G)
> 40 1024 1 freebsd-boot (512K)
> 1064 984 - free - (492K)
> 2048 4194304 2 freebsd-swap (2.0G)
> 4196352 972576768 3 freebsd-zfs (464G)
> 976773120 8 - free - (4.0K)
>
> root at beastie:~ # gpart destroy -F ada0
> gpart: Device busy
>
> root at beastie:~ # gpart modify -i2 -t freebsd-boot ada0
> ada0p2 modified
> root at beastie:~ # gpart show
> => 34 1250263661 ada0 GPT (596G)
> 34 409606 - free - (200M)
> 409640 1249591904 2 freebsd-boot (596G)
> 1250001544 262151 - free - (128M)
>
> => 40 976773088 ada1 GPT (466G)
> 40 1024 1 freebsd-boot (512K)
> 1064 984 - free - (492K)
> 2048 4194304 2 freebsd-swap (2.0G)
> 4196352 972576768 3 freebsd-zfs (464G)
> 976773120 8 - free - (4.0K)
>
>
> I’m not sure where to go from here, I’m tempted to pull the drive and
> reformat elsewhere
>
> I have all tried dd’ing the disk as root but dd /dev/ada0 errors with
> unauthorised.
>
> Am I missing something obvious?
I don't know whether it can be considered obvious, but, in my experience,
this sort of inability to delete a partition can happen because another
GEOM layer has that partition open under some other guise. Typical
culprits are the various "label" classes and other GEOM classes that
"autodetect" things belonging to them.
A case in point that happened to me recently: I was trying to install on
what I thought were two empty drives. Unfortunately, when it came to
actually partitioning ada0 and ada1 it failed. It turned out that the
drives were previously used in a "fake RAID" setup and GEOM_RAID was
detecting an old RAID volume on the drives because the RAID metadata/label
was being detected. This meant I couldn't directly access the underlying
devices, ada0 and ada1.
My solution was to use graid to destroy the errant RAID volume, after which
I was able to write/partition ada0 and ada1 directly.
Sometimes it is sufficient to disable autodetection of various label
classes in /boot/loader.conf to be able to access the lower devices.
Cheers,
Paul.
More information about the freebsd-stable
mailing list