-1

When building core-image-minimal on poky (in my case this is being built for custom hardware loosely based on the BBG reference), yocto writes a hostname to /etc/hostname on the file system image.

Occasionally it is preferable to exclude the creation of the hostname file during the fs image build, and instead generate a hostname, and subsequently an /etc/hostname file, dynamically the first time a device boots the image.

An example implementation would be the employment of systemd and a 'firstboot' unit file that uses ConditionPathExists=|!/etc/hostname to determine the need to generate a hostname.

So, where is the most appropriate place/method for disabling the creation of /etc/hostname?

1 Answers1

1

You can change and define your own hostname, edit your local.conf:

hostname_pn-base-files = "your_hostname_here"
Cleiton Bueno
  • 326
  • 2
  • 10
  • 1
    ...and to actually answer the question: If you define an empty hostname that way, the `/etc/hostname` isn't created. It is handled in `base-files` recipe in openembedded-core, you can check it there. – Tomas Novotny Mar 21 '18 at 14:05
  • hostname_pn-base-files sets a hostname. The requirement im facing is to NOT set a hostname. Further, no /etc/hostname file should be created. @TomasNovotny I may have misinterpreted you suggestion; an empty hostname_pn-base-files will raise a parser exception. The only reference to the hostname that I am aware of in core, is hostname.sh, which generates the /etc/hostname file if it doesnt exist. Is the proposed option, patch the hostname.sh in my layer? – SuicidalLabRat Mar 21 '18 at 22:47
  • maybe just look at the [manual](https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#usingpoky-extend-customimage-image-name) – Nayfe Mar 22 '18 at 10:16