# Unable to format a secondary drive



## knightjp (Aug 25, 2022)

I'm trying to format a secondary drive to UFS. I moved the important files from it to another location. I tried using `bsdinstall partedit` and got an error "device busy". 
I tried to `umount` the drive and it would not do it. The error is "One or More files on this device are open..."
I even restarted the system and tried it again. It won't do it. 
Now sure what I need to be doing.


----------



## msplsh (Aug 25, 2022)

try `lsof` to figure out what's open.


----------



## knightjp (Aug 25, 2022)

msplsh said:


> try `lsof` to figure out what's open.


I tried that.. all it said was /bin/sh: lsof: not found

OK.. I had to install the package. 
I tried it again and it gives me a huge readout with all the applications currently running. 
Not sure what I need to do here. Sorry... I'm quite new to this.


----------



## msplsh (Aug 25, 2022)

Check the last column for any path that is on your drive, then check the first column to tell what app is using it.


----------



## mer (Aug 25, 2022)

If you are "cd'd" to a directory on the drive you get that error.
If you have a graphical tool open showing a directory on the drive you get that error.


----------



## gpw928 (Aug 26, 2022)

It would help if you identified the "drive", or file systems involved, with more details.

e.g. the output of the mount(8) command might help.

However, since it's still "mounted", try `fuser -c <mountpoint>` to identify any processes using it.


----------



## knightjp (Aug 26, 2022)

Thanks for all the input guys. I managed to do it. 
I don't know if it was the "correct" way or whether there is an easier way to do it. I figured that my DE was probably the thing that was halting me and being on KDE and I didn't know how to get into the console without "starting X" 
So I logged out and at SDDM login manager, I chose the Userland option instead of Plasma X11. And then logged in using my credentials. 
It opened me up to an X Window session where I was able to use the "bsdinstall partedit" command to format the drive. After that a simple addition to the my "/etc/fstab" and then reboot it. 
All done.


----------



## msplsh (Aug 26, 2022)

Probably right about KDE taking over.


----------



## mer (Aug 26, 2022)

msplsh said:


> Probably right about KDE taking over.


Yep, probably whatever the file manager is called.  I think default settings automount especially external drives.


----------



## chrbr (Aug 26, 2022)

Dear knightjp,
the best approach is to avoid any GUI stuff. Please see http://www.wonkity.com/~wblock/docs/html/disksetup.html.
This should give some guidance.


----------



## Andriy (Aug 26, 2022)

msplsh said:


> try `lsof` to figure out what's open.


Or simply fstat(1) which is in base.


----------

