0

I'm running a custom OS based on ubuntu 18.04. I've ran into a problem - when the machine gets installed it sometimes doesn't have the value "127.0.1.1 hostname" in /etc/hosts. So it can't resolve itself

Does anyone know what fills that data or can you suggest where I can start debugging from ?

Malazzar
  • 21
  • 3

1 Answers1

2

On Debian, /etc/hosts comes from debian-installer and not owned by any package in particular. I have not confirmed Ubuntu, their development process a little complicated, and I don't wish spend more than a few minutes tracking down the sources.

$ dpkg --search /etc/fstab
dpkg-query: no path found matching pattern /etc/fstab

For a sysadmin, copy your desired configuration file, regardless of what the distro installer did. localhost is one of the few things it makes sense to have local files overriding what DNS says. But put records for localhost in DNS anyway.

127.0.0.1   localhost 
::1         localhost
John Mahowald
  • 30,009
  • 1
  • 17
  • 32
  • What exactly do you mean by copy your desired configuration file ? I want to make sure that when the machine starts after a fresh install it's ready to be used. I need to fix the empty /etc/hosts. Do you mean I need to use a postinst and copy it, because that would be a workaround but would not fix the problem. – Malazzar Jan 08 '21 at 07:25
  • Yes, a post install task to copy in /etc/hosts. Yes it seems like a bug that the installer doesn't do this by default, every Linux box I can remember can resolve localhost. But you should add more detail about what you mean by "custom OS", my Debian advice might not be able to help you if your customizations broke something. – John Mahowald Jan 08 '21 at 16:36