Other Issue with gpart "Device Busy"

dijitaltrix

New Member


Messages: 4

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:


Code:
root@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@beastie:~ # gpart delete -i2 ada0
gpart: Device busy

root@beastie:~ # gpart add -t freebsd-boot ada0
ada0p1 added

root@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@beastie:~ # gpart delete -i2 ada0
gpart: Device busy

root@beastie:~ # gpart delete -i1 ada0
ada0p1 deleted

root@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@beastie:~ # gpart destroy -F ada0
gpart: Device busy

root@beastie:~ # gpart modify -i2 -t freebsd-boot ada0
ada0p2 modified
root@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?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 13,141
Messages: 39,753

The filesystem on ada0p2 is probably still mounted.
 
OP
dijitaltrix

dijitaltrix

New Member


Messages: 4

You're right!

I mounted the drive using hfsfuse (it was apple-hfs), checked a few files and then unmounted it to format it.

I had rebooted several times in between.

However it looks like an fstab entry was automatically created when I plugged the disk in.

I did not expect that!

Code:
root@beastie:~ # cat /etc/fstab
# Device        Mountpoint    FStype    Options        Dump    Pass#
/dev/ada0p2        none    swap    sw        0    0

Deleting/unmounting the swap allowed me to delete the partition.

Code:
swapoff /dev/ada0p2

Thanks!
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 13,141
Messages: 39,753

However it looks like an fstab entry was automatically created when I plugged the disk in.
No, I think your additional drive moved your original drive from ada0 to ada1. Your p2 on the original disk is a swap partition, that's what the fstab entry was referring to. Adding or removing disks can shuffle the designations around, disks can move from ada0 to ada1 for example. Change the fstab entry to /dev/gpt/swap0 instead of /dev/ada0p2. Then it will use the label and the disk can freely move to any designation without causing problems.
 
OP
dijitaltrix

dijitaltrix

New Member


Messages: 4

For anyone with the same issue it was caused by my new disk being assigned /dev/ada0 pushing my previous single disk up to /dev/ada1.

/etc/fstab was not automatically edited for the new disk, it was setup during the install when ada1 (now) was ada0 (during install) and was therefore mounted on the new drive when it was plugged in.
 
Top