Solved Device busy...

So, I have built a FreeBSD 13.2-RELEASE today on my shop computer. That has 3 HDDs in it, and an installation of Windoze10 on one of those. 2 of the others are 2TB drives, one of which now has my new installation of FreeBSD on it. The other one HAD a complete installation of FreeBSD on it, but yesterday that took a long hike. But no matter.

I have also enabled USB-drive use from the Handbook's info. Good deal.

So, now I want to use the other 2TB drive for....something, but cannot delete the partitions on it.

That drive is /dev/ada1. For some reason it was automatically being mounted in /etc/fstab. When I do mount, I see that it is mounted as /dev/ada1a. So, I do umount -a -f UFS, then do mount again and it is still shown. So, I do umount -a -f , and mount again and it is still there.

OK. Let's see what gpart show /dev/ada1 has to say for itself. It shows the drive with its two partitions, 1 with "freebsd-ufs" and 2 with "freebsd-swap"

OK so I decide to do gpart delete -i swap /dev/ada1b and I get a "Device busy" message, which says to me that it is still mounted. (Duh)

I really don't want to yank the drive, haul it to my office, and wipe it on that computer, then haul it back to the shop.

So what am I doing wrong? According to everything I have read on this subject today, from the Handbook and from the Forum, it should have worked.

Ken Gordon
 
Yes. I read that/those at least once. So far, everything I tried hasn't worked. I'll read again. Later.

Thanks.

Ken Gordon
 
There are several things that are odd about this: for one thing, the active drive, that drive on which my FreeBSD install is running, is actually ada2, while the fstab requests ada1's swap space. I have suspected for some time that which drive is ada1 and which is ada2 get, literally, reversed in the two systems at times. By two systems I mean, 1) the computer's listing of drives at boot up, and 2) what FreeBSD calls them.

And I have run into this problem in the past.

For instance, I have 4 HDDs in the computer, an AS Rock motherboard, with 16 GB RAM, in a computer I have built. In the EUFI (whatever) "bios", it shows the HDDs in order as 1) 500 GB (Win10), 2) 160 GB (WinXP), 3) and 4) two identical 2TB drives. When booting the computer, and hitting F-11 to get the choice of boot drives, I see my Win10 drive as the first in the list, the two 2TB drives as next in the list, and the WinXP drive as being the last in the list of HDDs, followed by any USB drives I have plugged in. As I remember it, the CD drive is listed first.

The issue comes in that the two 2TB drives will swap "places" in the lineup of drives, depending on which FreeBSD install is complete and active.

For instance, I built a previous install of FreeBSD 13.2-Release on the 2TB drive which was first in any list of them. When I boot using F-11, that particular drive was always listed the 2nd one down in that list, while the unused 2TB drive was always listed third.

After that install of FreeBSD took a hike (and I still don't know why it did this), I then built a full install of FreeBSD 13.2-RELEASE on the second 2TB drive. But now THAT one is first in the list of bootable drives, and the old failed install's drive is now listed third. Their places have been swapped.

However, gpart show has always shown the drives in what I believe to be the correct order. I.e., it now shows my active drive as being ADA2, and my failed install of FreeBSD being on ADA1, which to my mind is correct. Yet my fstab still requests the swap drive as being ADA1. ADA2 IS my present bootable and complete FreeBSD install, while ADA1 IS my old failed install.

Now.....I was working with my old install on ADA1 the other day. I went into the fstab and commented out the two lines in that file dealing with the swap drive. When I rebooted the system, THAT was when it crashed. While booting, I got the message that it couldn't find the boot partition. I couldn;t even drop to Single User mode. I thought that the two entries in fstab were not totally necessary for the system to work, but apparently I was wrong.

What I am going to do now is to edit my fstab and change the two drives listed there to ADA2. I am afraid that doing this will cause my system to crash, but if it does, I will be given the opportunity to practice building another install. After all, practice makes perfect! Right?

Ken Gordon
 
As you are finding out, making speculative changes to critical files is not a good idea (unless you are doing as part of a learning experience.)
 
Are you using something depends on devel/gvfs?
If so, /usr/local/libexec/gvfsd-trash is causing the issue.
This case, killall -STOP gvfsd-trash JUST BEFORE UNMOUNTING and try unmounting immediately. If it is terminated, it would re-run immediately and unmount would fail, with my experience.
 
Boy! You're telling me!

OK. I got it back. I'm not going to go into details, but doing that wasn't particularly intuitive.

So, first I edited /etc/fstab to change the file type to look for from GPT back to UFS, and to look in ada1a and ada1b.

Then rebooted. Everything appeared to work correctly. There was one error which told me that line 7 in auto_master had too many entries.

Then I did gpart show ada2, which showed me that there were three partitions on that drive, boot, system and swap.

So, since I have now remembered how to recover, I changed ada1a to ada2b, and ada1b to ada2c, which should be the swap area.

The system booted right up, except that the Realtek driver, re0, would not load, and DHCP for re0 did not activate.

An error message told me that ada2c did not exist. So, I'll change that back to ada1b and see what happens

To handle the NIC problem, I loaded the driver manually by kldload /boot/modules/if_re.ko, then /sbin/dhclient re0, then ifconfig re0 media autoselect

Gee...what fun...kinda like hitting oneself in the head with a hammer: it feels so good when you stop.

I think that instead of trying to use gpart delete, I am going to physically disconnect the drive which the system calls ada1

Ken Gordon
 
Doing freebsd-version -ku, I get 2 lines: FreeBSD-13.2-RELEASE-P8, followed by FreeBSD-13.2-RELEASE-P9. Isn't this telling me that I am running two versions simultaneously, or a "mixed" version?

Possibly this explains why if_re.ko is not being loaded at boot now, despite having all the necessary commands written into both the /etc/rc.conf and into /boot/loader.conf.

Tomorrow I am going to physically unplug the data-cable from the 2TB HDD which gpart show is telling me is ada1.

Then, if things are still messed up, I will, again, build a FreeBSD-13.2-RELEASE system.

Ken Gordon
 
Doing freebsd-version -ku, I get 2 lines: FreeBSD-13.2-RELEASE-P8, followed by FreeBSD-13.2-RELEASE-P9. Isn't this telling me that I am running two versions simultaneously, or a "mixed" version?
That means your kernel shows -P8 and your userland is -P9. It should be fine.

Possibly this explains why if_re.ko is not being loaded at boot now, despite having all the necessary commands written into both the /etc/rc.conf and into /boot/loader.conf.
Note that you can manually install this by doing "kldload if_re" as superuser. Make sure it is in /boot/modules/ directory (and IIRC you should run "kldxref /boot/modules"). If the load succeeds, "ifconfig -l" should show you an re device.

Then, if things are still messed up, I will, again, build a FreeBSD-13.2-RELEASE system.
Rather that reinstalling, I recommend diagnosing what is going on.
 
Note that you can manually install this by doing "kldload if_re" as superuser.
kldload(8)
Code:
     If a bare filename is requested it will only be loaded if it is found
     within the module path as defined by the sysctl kern.module_path.
Code:
$ sysctl kern.module_path
kern.module_path: /boot/kernel;/boot/modules;/boot/dtb;/boot/dtb/overlays
There if_re.ko in /boot/kernel/

pkg info -D realtek-re-kmod
Code:
Add the following lines to your /boot/loader.conf
to override the built-in FreeBSD re(4) driver.

if_re_load="YES"
if_re_name="/boot/modules/if_re.ko"
Edit:He use realtek-re-kmod. Thread realtek-rtl8125-on-board-not-discovered.91517
 
OK. I can fire up the Reaktek NIC manually just fine. What is bothering me is that the driver used to load as it was booting. Now, it doesn't.

It IS looking as though the DHCP client for the NIC is loading, though. When I invoke dhclient, the system says it is already there.

Since I was working so hard today to figure out my HDD issues, I set other issues aside.

The problem with the system suddenly no longer loading the Realtek driver probably popped up after I updated FreeBSD today.

I'll take a look at the kernel tomorrow.

I AM going to manually disconnect that other 2TB drive, though.

Thank you for the help

Ken Gordon
 
OK. I can fire up the Reaktek NIC manually just fine. What is bothering me is that the driver used to load as it was booting. Now, it doesn't.
Please provide the following:
- output of cat /boot/loader.conf | grep if_re
- output of ls -l /boot/modules/if_re.ko
- output of kldstat -v -n if_re.ko
 
I have been very busy with family matters today and have not yet had time to deal with the suggestions given here. I will do so as soon as I can. And thank you all for the help.

Ken Gordon.
 
OK. Although my dear wife is frantic trying to get ready for the influx of guests for Christmas dinner on Monday, I just started a loaf of bread, so I can take a few minutes to answer some of the excellent suggestions posted here. I will forego doing the hardware operations I mentioned above until I have a bit more time. In the meantime, I'll now shutdown Windoze and will boot into FreeBSD, manually load the necessary Realtek NIC software, and attempt to answer some of the questions above. Standby for a few minutes.

Ken Gordon
 
OK. I am now on FreeBSD, running the MATE desktop and Firefox.

cat /boot/loader.conf | grep if_re returns
if_re_name="/boot/modules/if_re.ko"
if_re_load="YES"


Ken Gordon
 
ls -l /boot/modules/if_re.ko returns
-r-xr-xr 1 root wheel 1046776 DEC 17 10:17 /boot/modules/if_re.ko

and kldstat -v -n if_re.ko returns
Id Refs Address Size Name
26 1 0xffffffff8252600 8e528 if_re.ko (/boot/modules/if_re.ko)
Id Name
535 pci/if_re


Now this is AFTER I have manually loaded all that is required to activate my Realtek NIC.

What is baffling me is that although it all loaded at boot when I first wrote the necessary entries, some time after I updated FreeBSD-13.2, all that stuff no longer loads at boot, and I have to load it all manually.

Ken Gordon
 
Do you really need if_re.ko before kernel is loades (for example, network booting)?
If not, what happenes if you load it by adding it to kld_list in /etc/rc.cof[.local] instead of in /boot/loader.conf?
 
Back
Top