gpart: Permission denied when trying to erase and format external USB hard drive

I have an extra SATA drive connected by a USB adapter to my PC. I'm simply trying to erase and re-format the drive for use, but gpart is getting stick on something

# lsblk -d
DEVICE SIZE MODEL
cd0 0B hp HLDS DVDRW GUD1N
da0 3.7G PNY USB 2.0 FD
da1 7.3T HGST HUH 728080ALE600
da2 231G PNY USB 3.2.1 FD
nda0 932G CT1000T710SSD8
- 8T TOTAL SYSTEM STORAGE

# mount | grep da*
zroot/ROOT/default on / (zfs, local, noatime, nfsv4acls)
devfs on /dev (devfs)
/dev/gpt/efiboot0 on /boot/efi (msdosfs, local)
zroot/var/log on /var/log (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/audit on /var/audit (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/tmp on /tmp (zfs, local, noatime, nosuid, nfsv4acls)
zroot/usr/ports on /usr/ports (zfs, local, noatime, nosuid, nfsv4acls)
zroot/var/crash on /var/crash (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/tmp on /var/tmp (zfs, local, noatime, nosuid, nfsv4acls)
devfs on /compat/linux/dev (devfs)
fdescfs on /compat/linux/dev/fd (fdescfs)
tmpfs on /compat/linux/dev/shm (tmpfs, local)
/dev/da0 on /media/da0 (cd9660, local, read-only)
/dev/da0s1 on /media/da0s1 (cd9660, local, read-only)
/dev/da2p1 on /media/da2p1 (fusefs)

root@freebsd:/home/ed # gpart destroy -F da1
gpart: Permission denied

# ls -al /dev/da1
crw-r----- 1 root operator 0x1e0 Nov 13 07:36 /dev/da1


What am I missing?

Thank you,
Ed
 
Show the output of

gpart list | egrep "label:|Name:"
zpool status
root@freebsd:/home/ed # gpart list | egrep "label:|Name:"
1. Name: nda0p1
label: efiboot0
2. Name: nda0p2
label: gptboot0
3. Name: nda0p3
label: swap0
4. Name: nda0p4
label: zfs0
1. Name: nda0
1. Name: da0s1
1. Name: da0
1. Name: iso9660/3.3.1-35-amd64s1
1. Name: iso9660/3.3.1-35-amd64
1. Name: da2p1
label: PNY256G
1. Name: da2
root@freebsd:/home/ed # zpool status
pool: zroot
state: ONLINE
config:

NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
nda0p4 ONLINE 0 0 0

errors: No known data errors
root@freebsd:/home/ed #

Thank you,
Ed
 
I don't see a da1 in the output of "gpart list". This means gpart hasn't detected any partitions on it. Nothing to destroy!
OK, with that in mind and before I can even create a partition, I did this:

# gpart create -s GPT /dev/da1
gpart: Permission denied

# ls -al /dev/da1
crw-r----- 1 root operator 0x1e0 Nov 13 07:36 /dev/da1

Why would I get a permission denied error as root? I don't understand that at all!

Ed
 
Not a darn thing!

# dmesg | grep da1

:-)

Ed
That probably means there was no da1 detected at boot time or at a later time. Try disconnecting the usb disk and reconnecting and see if dmesg reports anything useful. [That is, show us the dmesg output relating to the usb connect event]
 
That probably means there was no da1 detected at boot time or at a later time. Try disconnecting the usb disk and reconnecting and see if dmesg reports anything useful. [That is, show us the dmesg output relating to the usb connect event]
I unplugged the drive and plugged it back in. Here's what dmesg says...

# dmesg | grep da1
da1 at umass-sim1 bus 1 scbus7 target 0 lun 0
da1: <HGST HUH 728080ALE600 4101> Fixed Direct Access SPC-4 SCSI device
da1: Serial Number 032206160845
da1: 400.000MB/s transfers
da1: 7630885MB (15628053168 512 byte sectors)
da1: quirks=0x2<NO_6_BYTE>
(da1:umass-sim1:1:0:0): READ(10). CDB: 28 00 00 00 00 00 00 00 01 00
(da1:umass-sim1:1:0:0): CAM status: SCSI Status Error
(da1:umass-sim1:1:0:0): SCSI status: Check Condition
(da1:umass-sim1:1:0:0): SCSI sense: DATA PROTECT asc:74,71 (Logical unit access not authorized)
(da1:umass-sim1:1:0:0): Error 13, Unretryable error
(da1:umass-sim1:1:0:0): READ(16). CDB: 88 00 00 00 00 03 a3 81 2a af 00 00 00 01 00 00
(da1:umass-sim1:1:0:0): CAM status: SCSI Status Error
(da1:umass-sim1:1:0:0): SCSI status: Check Condition
(da1:umass-sim1:1:0:0): SCSI sense: DATA PROTECT asc:74,71 (Logical unit access not authorized)
(da1:umass-sim1:1:0:0): Error 13, Unretryable error
(da1:umass-sim1:1:0:0): READ(16). CDB: 88 00 00 00 00 03 a3 81 2a af 00 00 00 01 00 00
(da1:umass-sim1:1:0:0): CAM status: SCSI Status Error
(da1:umass-sim1:1:0:0): SCSI status: Check Condition
...


Ed
 
camcontrol security da1 ?
# camcontrol security da1
pass4: <HGST HUH728080ALE600 A4GNT907> ACS-2 ATA SATA 3.x device
pass4: 400.000MB/s transfers

Security Option Value
supported yes
enabled yes
drive locked yes
security config frozen no
count expired no
security level high
enhanced erase supported no
erase time > 508 min
enhanced erase time unspecified
master password rev fffe


Thank you,
Ed
 
Since you also tried as root, IMO there can be only three possibilities left:
1. This drive is part of a zpool and yet not released from it:
  • a) first remove it from the zpool it belongs to
  • b) use brute force and write over it with dd
2. It's security level is set up to a higher level. Use camcontrol (if it's a SSD) to reset the security level.
3. Check again if it's really da1.

Edit:
Seems to be, what covacat said. Follow his lead!
 
(da1:umass-sim1:1:0:0): READ(10). CDB: 28 00 00 00 00 00 00 00 01 00
(da1:umass-sim1:1:0:0): CAM status: SCSI Status Error
(da1:umass-sim1:1:0:0): SCSI status: Check Condition
(da1:umass-sim1:1:0:0): SCSI sense: DATA PROTECT asc:74,71 (Logical unit access not authorized)
(da1:umass-sim1:1:0:0): Error 13, Unretryable error
This could be the root of your problems.... In case suggestions offered by others here don't help, consider posting to freebsd-scsi mailing list.
 
Since you also tried as root, IMO there can be only three possibilities left:
1. This drive is part of a zpool and yet not released from it:
  • a) first remove it from the zpool it belongs to
  • b) use brute force and write over it with dd
2. It's security level is set up to a higher level. Use camcontrol (if it's a SSD) to reset the security level.
3. Check again if it's really da1.

Edit:
Seems to be, what covacat said. Follow his lead!
root@freebsd:/home/ed # zpool status
pool: zroot
state: ONLINE
config:

NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
nda0p4 ONLINE 0 0 0

errors: No known data errors
root@freebsd:/home/ed # lsblk -d
DEVICE SIZE MODEL
cd0 0B hp HLDS DVDRW GUD1N
da0 3.7G PNY USB 2.0 FD
da1 7.3T HGST HUH 728080ALE600
da2 231G PNY USB 3.2.1 FD
nda0 932G CT1000T710SSD8
- 8T TOTAL SYSTEM STORAGE
root@freebsd:/home/ed # dd if=/dev/random of=/dev/da1 bs=1M count=10 status=progress
dd: /dev/da1: Operation not permitted
root@freebsd:/home/ed # gpart destroy -F /dev/da1
gpart: Permission denied
root@freebsd:/home/ed #

Thank you,
Ed
 
*headscratch* If even "brute force" does not work, when neither root can dd to it, nor camcontrol can erase/reset the drive anymore - You are sure you did the right procedure? First activate the security with -s, user and password, then do the according camcontrol command (e.g. format, see man camcontrol(8)) on the drive also with user and password? - then I'm out of options and can only wildely guess, like it's a defect of the drive's controller, like the security bit cannot be changed anymore. But unless it was changed tenthousands of times that's pretty unlikely. Or it ain't the drive at all, but somehow root's permissions have been tinkered with... - I don't know, sorry. 😟
(da1:umass-sim1:1:0:0): SCSI sense: DATA PROTECT asc:74,71 (Logical unit access not authorized)
Can you read from it? Maybe it's the USB to SATA converter. Tried to attach the drive directly to a SATA port?
 
From https://lists.openwall.net/linux-kernel/2026/02/25/2132
SanDisk Extreme Portable SSD and similar hardware-encrypted USB drives
return Sense Key DATA_PROTECT (0x07) with ASC 0x74, ASCQ 0x71 ("Logical
unit access not authorized") when password-locked.

The SCSI error handler currently treats this as a generic DATA_PROTECT
error.
What does "camcontrol inquiry da1" reveal? You will likely need to unlock the drive using manufacturer's tool (WD or SanDisk Security) on Windows or MacOS and disable password protection.
 
Back
Top