# Issue with postfix after switch from ports to package



## circus78 (Apr 11, 2018)

Hi,
I manage a server with FreeBSD 11.1-RELEASE-p9.
Basically it is a mailserver with mail/postfix, mail/dovecot and mail/roundcube.

I decided to switch from ports to packages with these commands:

`pkg-static install -f pkg
pkg upgrade -f`

I got no errors, anyway it seems mail/postfix is broken now:


```
Apr 11 20:27:36 mail postfix/trivial-rewrite[9193]: warning: hash:/usr/local/etc/postfix/virtual/domain.com is unavailable. open database /usr/local/etc/postfix/virtual/domain.com.db: Invalid argument
Apr 11 20:27:36 mail postfix/trivial-rewrite[9193]: warning: virtual_alias_domains: hash:/usr/local/etc/postfix/virtual/domain.com: table lookup problem
```

This is `postconf -m`output:


```
btree
cidr
environ
fail
hash
inline
internal
memcache
pcre
pipemap
proxy
randmap
regexp
socketmap
static
tcp
texthash
unionmap
unix
```

Any suggestion?


----------



## Lamia (Apr 11, 2018)

You need run "postmap hash:/usr/local/etc/postfix/virtual/domain.com". Your table needs to be rehashed basically.


----------



## VladiBG (Apr 11, 2018)

It's better to use the ports if you need some custom options in postfix. For your problem first open /usr/local/etc/postfix/main.cf and correct your virtual_alias_domains. It's pointing to non-existing db at /usr/local/etc/postfix/virtual/domain.com. If the file location is correct, check its content. Then you can try to rebuild the domain.com.db with postmap(1).


----------



## ShelLuser (Apr 11, 2018)

Just running `pkg upgrade` is not the right way to move from ports to packages. What guarantee do you have that Postfix got reinstalled again? (edit) => Only applies without -f.

Upgrade only upgrades if there is a new version available. And fact of the matter is that the ports collection is always _ahead_ of everything. As such my theory: you reinstalled dependencies of Postfix without reinstalling Postfix itself and the result can be seen above.

The only solid way to move from ports to packages is to deinstall everything, and then re-install it:

```
# pkg info -aqo > packages
# pkg delete -a
# pkg install `cat packages`
```


----------



## SirDice (Apr 11, 2018)

ShelLuser said:


> Just running  pkg upgrade is not the right way to move from ports to packages. What guarantee do you have that Postfix got reinstalled again?


The fact that he did `pkg upgrade -f`, instead of just `pkg upgrade`. The `-f` option always reinstalls _everything_.


```
-f, --force
                 Force the reinstallation or upgrade of the whole set of
                 packages.
```
pkg-upgrade(8).


----------



## robroy (Apr 11, 2018)

ShelLuser said:


> ```
> # pkg info -aqo > packages
> # pkg delete -a
> # pkg install `cat packages`
> ```



ShelLuser, thank you for this.  You have no idea how many times I've tediously crawled through this procedure by hand hahahaha; I hadn't managed to brew up enough ambition to find a better way, so I find the elegance of your approach totally ironic.


----------



## ShelLuser (Apr 11, 2018)

SirDice said:


> The fact that he did `pkg upgrade -f`, instead of just `pkg upgrade`. The `-f` option always reinstalls _everything_.


Ayups, glossed over it and I stand corrected on that.


----------



## circus78 (Apr 12, 2018)

SirDice said:


> The fact that he did `pkg upgrade -f`, instead of just `pkg upgrade`. The `-f` option always reinstalls _everything_.
> 
> 
> ```
> ...



Hi, in fact, I followed your old instructions  Thread 62583


----------



## circus78 (Apr 12, 2018)

VladiBG said:


> It's better to use the ports if you need some custom options in postfix. For your problem first open /usr/local/etc/postfix/main.cf and correct your virtual_alias_domains. It's pointing to non-existing db at /usr/local/etc/postfix/virtual/domain.com. If the file location is correct, check its content. Then you can try to rebuild the domain.com.db with postmap(1).



In addiction, I just remembered that I needed to use postfix-sasl package 


```
Apr 12 01:15:07 mail postfix/smtpd[13275]: warning: SASL: Connect to smtpd failed: No such file or directory
Apr 12 01:15:07 mail postfix/smtpd[13275]: fatal: no SASL authentication mechanisms
```

Solved with:


```
# pkg delete postfix
# pkg install postfix-sasl-3.3.0_1
```


----------

