Solved var/empty

What is stopping me deleting var/empty ?

This is not /var/empty but part of an old backup filesystem which I want to delete.

I'm not aware about any flags that this file may have, BICBW.

How do I delete it?
 
What is stopping me deleting var/empty ?

This is not /var/empty but part of an old backup filesystem which I want to delete.

I'm not aware about any flags that this file may have, BICBW.

How do I delete it?
Don't do it!

Why it cannot be deleted with usual rm operation is because it is created with schg flag (system immutable) on creation.
You can see it In /etc/mtree/BSD.var.dist.

And in /etc/rc.d/var, the existence of it is assumed to determine whether or not /var is populated or not on default case.

Code:
# If we have an empty looking /var, populate it, but only if we have
# /usr available.  Hopefully, we'll eventually find a workaround, but
# in realistic diskless setups, we're probably ok.
case "${populate_var}" in
[Yy][Ee][Ss])
    populate_var
    ;;
[Nn][Oo])
    exit 0
    ;;
*)
    if [ -d /var/run -a -d /var/db -a -d /var/empty ] ; then
        true
    elif [ -x /usr/sbin/mtree ] ; then
        populate_var
    else
        # We need mtree to populate /var so try mounting /usr.
        # If this does not work, we can not boot so it is OK to
        # try to mount out of order.
        mount /usr
        if [ ! -x /usr/sbin/mtree ] ; then
            exit 1
        else
            populate_var
        fi
    fi
    ;;
esac
 
I am not talking about /var/empty as I mentioned.

This what I want to get rid of:-

/media/da0s3/media/FreeBSD-ARM/var/empty

I can't identify any flags associated with this file.
 
I am not talking about /var/empty as I mentioned.

This what I want to get rid of:-

/media/da0s3/media/FreeBSD-ARM/var/empty

I can't identify any flags associated with this file.
You've done ls -lo /media/da0s3/media/FreeBSD-ARM/var/ and confirmed it doesn't have schg flag at 5th column, right?

If it was created with schg flag at the first place, it wouldn't allow you to delete it. If so, you need to do chflags -R noschg /media/da0s3/media/FreeBSD-ARM/var/empty as root before deletion.

See manpage chflags(1) for detail.

For me with /var/, /var/empty has schg flag.
Code:
% ls -lo /var/     
total 167
drwxr-x---   2 root    wheel   uarch    2  6月 23  2019 account
drwxr-xr-x   4 root    wheel   uarch    4  6月 23  2019 at
drwxr-x---   4 root    audit   uarch    4  6月 23  2019 audit
drwxrwx---   2 root    authpf  uarch    2  6月 23  2019 authpf
drwxr-x---   2 root    wheel   uarch   41  4月 19 04:10 backups
drwxr-xr-x   6 root    wheel   uarch    6 11月  3  2023 cache
drwxr-x---   2 root    wheel   uarch    3  6月 23  2019 crash
drwxr-x---   3 root    wheel   uarch    3 10月 13  2023 cron
drwxr-xr-x  24 root    wheel   uarch   40  3月 26 09:16 db
dr-xr-xr-x   2 root    wheel   schg     2  6月 23  2019 empty
drwxrwxr-x   2 root    games   uarch    2  6月 23  2019 games
drwx------   2 root    wheel   uarch    2  6月 23  2019 heimdal
drwxr-xr-x   9 root    wheel   uarch    9  9月  9  2025 lib
drwxr-xr-x   6 root    wheel   uarch   62  4月 19 04:02 log
drwxrwxr-x   2 root    mail    uarch    5  4月 13 04:03 mail
drwxr-xr-x   2 daemon  wheel   uarch    3  6月 29  2019 msgs
drwxr-xr-x   2 root    wheel   uarch    2  6月 23  2019 preserve
drwxr-xr-x  18 root    wheel   -     2880  4月 19 18:15 run
drwxr-xr-x  22 root    wheel   uarch   36  3月  4  2024 run2
drwxrwxr-x   2 root    daemon  uarch    2  6月 23  2019 rwho
drwxr-xr-x  10 root    wheel   uarch   10  8月 29  2019 spool
drwxrwxrwt  25 root    wheel   uarch  465  4月 19 18:15 tmp
drwxr-xr-x   3 unbound unbound uarch   14  4月 19 18:06 unbound
-r--r--r--   1 root    wheel   uarch   13 11月 15  2023 unbound.$$$
drwxr-xr-x   3 unbound unbound uarch   14 11月 15  2023 unbound.backup
drwxr-xr-x   2 root    wheel   uarch    4  8月 25  2023 yp

Note that these include some directories I've created for backups or testing.
 
When in doubt about something then don't forget about the -o option for ls: ls -lo:

Code:
peter@zefiris:/var $ ls -lod e*
dr-xr-xr-x  2 root wheel schg 2 Nov 29  2024 empty/
See?
 
Back
Top