postfix got "file has 2 hard links" error frequently

Asked by Jack

I got a postfix error with "file has 2 hard links" frequently.
When the host bootup postfix is running well, but sometime will get
the error "postfix/pickup[13654]: fatal: /etc/mailname: file has 2 hard links"
When I done the below command and become normal running.
but after few days will got the error again. I can't found the frequency.
Is anyone know how to fix this issue forever ?

sudo service postfix stop
ps -ef | grep postfix
cd /etc
sudo cp mailname mailname.cp
sudo mv mailname mailname.bad.001
sudo cp mailname.cp mailname
cd /var/spool/postfix/pid
sudo rm -f *
sudo service postfix start
sudo service postfix status
ps -ef | grep postfix
tail -10 /var/log/mail.err
tail -10 /var/log/mail.log

Error log:
more /etc/lsb*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.6 LTS"

uname -a
Linux mars 4.15.0-202-generic #213-Ubuntu SMP Thu Jan 5 19:19:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

dpkg -l | grep postfix
ii postfix 3.3.0-1ubuntu0.4 amd64 High-performance mail transport agent

/var/log/syslog
Jan 16 07:12:31 mars postfix/pickup[13654]: fatal: /etc/mailname: file has 2 hard links
Jan 16 07:12:32 mars postfix/master[1739]: warning: process /usr/lib/postfix/sbin/pickup pid 13654 exit status 1
Jan 16 07:12:32 mars postfix/master[1739]: warning: /usr/lib/postfix/sbin/pickup: bad command startup -- throttling
Jan 16 07:13:32 mars postfix/pickup[13663]: fatal: /etc/mailname: file has 2 hard links
Jan 16 07:13:33 mars postfix/master[1739]: warning: process /usr/lib/postfix/sbin/pickup pid 13663 exit status 1
Jan 16 07:13:33 mars postfix/master[1739]: warning: /usr/lib/postfix/sbin/pickup: bad command startup -- throttling
Jan 16 07:14:12 mars postfix/master[1739]: warning: unix_trigger_event: read timeout for service public/pickup
/var/log/mail.err
Jan 16 07:12:31 mars postfix/pickup[13654]: fatal: /etc/mailname: file has 2 hard links
Jan 16 07:13:32 mars postfix/pickup[13663]: fatal: /etc/mailname: file has 2 hard links
Jan 16 07:14:33 mars postfix/pickup[13675]: fatal: /etc/mailname: file has 2 hard links
Jan 16 07:15:34 mars postfix/pickup[13680]: fatal: /etc/mailname: file has 2 hard links
Jan 16 07:16:35 mars postfix/pickup[13684]: fatal: /etc/mailname: file has 2 hard links
/var/log/mail.log
Jan 16 07:12:31 mars postfix/pickup[13654]: fatal: /etc/mailname: file has 2 hard links
Jan 16 07:12:32 mars postfix/master[1739]: warning: process /usr/lib/postfix/sbin/pickup pid 13654 exit status 1
Jan 16 07:12:32 mars postfix/master[1739]: warning: /usr/lib/postfix/sbin/pickup: bad command startup -- throttling
Jan 16 07:13:32 mars postfix/pickup[13663]: fatal: /etc/mailname: file has 2 hard links
Jan 16 07:13:33 mars postfix/master[1739]: warning: process /usr/lib/postfix/sbin/pickup pid 13663 exit status 1
Jan 16 07:13:33 mars postfix/master[1739]: warning: /usr/lib/postfix/sbin/pickup: bad command startup -- throttling
Jan 16 07:14:12 mars postfix/master[1739]: warning: unix_trigger_event: read timeout for service public/pickup
Jan 16 07:14:33 mars postfix/pickup[13675]: fatal: /etc/mailname: file has 2 hard links

list -il /etc/mailname*
23986809 -rw-r--r-- 1 root root 23 Jan 7 08:08 /etc/mailname
23986415 -rw-r--r-- 1 root root 23 Oct 31 11:12 /etc/mailname.bad.001
23986722 -rw-r--r-- 3 root root 23 Oct 31 11:12 /etc/mailname.bad.002
23986660 -rw-r--r-- 2 root root 23 Jan 7 08:08 /etc/mailname.bad.003
23986392 -rw-r--r-- 1 root root 23 Jan 7 08:08 /etc/mailname.cp

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu postfix Edit question
Assignee:
No assignee Edit question
Solved by:
Jack
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

You can search using the below command:

find -L / -samefile /etc/mailname

Should show where the links are, at least

Source:
https://stackoverflow.com/questions/4532241/linux-find-all-symlinks-of-a-given-original-file-reverse-readlink

Revision history for this message
Jack (wenbor) said :
#2

I run the below command which try to found the same file, but the screen is always show up the below message.

sudo find -L / -samefile "/etc/mailname"
find: File system loop detected; ‘/sys/class/thermal/thermal_zone2/subsystem’ is part of the same file system loop as ‘/sys/class/thermal’.
find: File system loop detected; ‘/sys/class/thermal/cooling_device1/device/firmware_node/physical_node’ is part of the same file system loop as ‘/sys/class/thermal/cooling_device1/device’.
find: File system loop detected; ‘/sys/class/thermal/cooling_device1/device/firmware_node/power_resources_D0/LNXPOWER:01/subsystem/devices/device:26/physical_node/firmware_node’ is part of the same file system loop as ‘/sys/class/thermal/cooling_device1/device/firmware_node/power_resources_D0/LNXPOWER:01/subsystem/devices/device:26’.
find: File system loop detected; ‘/sys/class/thermal/cooling_device1/device/firmware_node/power_resources_D0/LNXPOWER:01/subsystem/devices/device:26/subsystem’ is part of the same file system loop as ‘/sys/class/thermal/cooling_device1/device/firmware_node/power_resources_D0/LNXPOWER:01/subsystem’.
find: File system loop detected; ‘/sys/class/thermal/cooling_device1/device/firmware_node/power_resources_D0/LNXPOWER:01/subsystem/devices/device:2d/physical_node/firmware_node’ is part of the same file system loop as

I try to search the hard link message found below command can used:
https://askubuntu.com/questions/972121/how-to-find-all-hardlinks-in-a-folder

sudo find / -type f -links +1 -samefile "/etc/mailname.bad.003"
find: ‘/proc/2182/task/2182/fdinfo/7’: No such file or directory
find: ‘/proc/2182/fdinfo/6’: No such file or directory
/home/mike/bkup/mailname
/etc/mailname.bad.003

ls -il /etc/mailname*
23986809 -rw-r--r-- 1 root root 23 Jan 7 08:08 /etc/mailname
23986415 -rw-r--r-- 1 root root 23 Oct 31 11:12 /etc/mailname.bad.001
23986722 -rw-r--r-- 3 root root 23 Oct 31 11:12 /etc/mailname.bad.002
23986660 -rw-r--r-- 2 root root 23 Jan 7 08:08 /etc/mailname.bad.003
23986392 -rw-r--r-- 1 root root 23 Jan 7 08:08 /etc/mailname.cp

cd /home/mike/bkup
ls -il mailname
23986660 -rw-r--r-- 2 root root 23 Jan 7 08:08 mailname

I found the user using wrong cp command parameter with cp -l ,
then bkup script run will create the hardlink mailname.

Thanks for all answer support.