bsd.upgrade fails and shows following messages with a single partition disk.
```
Force checking of clean non-root filesystems? [no] no
umount: /mnt: Device busy
Can't umount sd0a!
```
sd0 has following partitions.
```
# size offset fstype [fsize bsize cpg]
a: 37752672 64 4.2bsd 2048 16384 12959 # /
b: 4176900 37752750 swap # none
c: 41943040 0 unused
```
I don't want to say any thing about disk partitioning policy.
I just want to improve bsd.upgrade more stable.
This error happens in a specific environment.
In my cases, OpenBSD on FreeBSD bhyve in Intel Core i7-6700 box caused
this error. No other environments (that I have) reproduce it.
In my investigation, the following patch caused panic in the bhyve
environment.
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 43a7cbd4ae9..4f4176a77ac 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -966,6 +966,7 @@ vflush_vnode(struct vnode *vp, void *arg)
vprint("vflush: busy vnode", vp);
#endif
va->busy++;
+ panic("vflush_vnode: mark busy");
return (0);
}
I think some vnodes are still remaining while `umount /mnt`.
So, the kernel returns EBUSY.
It's right to kernel behavior and user land should handle this case.
Doing `umount /mnt` just after `fsck -p` in disrib/miniroot/install.sub.
```
3264 # Create a skeletal /etc/fstab which is usable for the upgrade process.
3265 munge_fstab
3266
3267 # fsck -p non-root filesystems in /etc/fstab.
3268 check_fs
3269
3270 # Mount filesystems in /etc/fstab.
3272 umount /mnt || { echo "Can't umount $ROOTDEV!"; exit; }
3273 mount_fs
```
Is it necessary that /mnt is mounted while `check_fs` function?
The target disk information is already read from /mnt/etc/fstab in
`munge_fstab` function. `check_fs` uses the merged fstab in /tmp.
Just `umount /mnt` before `check_fs` can get avoid this error.
Is the following patch OK?
```
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
old mode 100644
new mode 100755
index 16d3b6e3420..cf7e15c9754
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -3243,11 +3243,12 @@ do_upgrade() {
# Create a skeletal /etc/fstab which is usable for the upgrade process.
munge_fstab
+ umount /mnt || { echo "Can't umount $ROOTDEV!"; exit; }
+
# fsck -p non-root filesystems in /etc/fstab.
check_fs
# Mount filesystems in /etc/fstab.
- umount /mnt || { echo "Can't umount $ROOTDEV!"; exit; }
mount_fs
rm -f /mnt/bsd.upgrade /mnt/auto_upgrade.conf
```
--
Yuichiro NAITO (naito.yuich...@gmail.com)