Skip to main content
MKaas.1
Associate II
August 20, 2021
Solved

How tho change hostname from the default = MACHINE

  • August 20, 2021
  • 4 replies
  • 2231 views

I have set :

hostname_pn-base-files = "new_host_name"

in my conf file.

This seems changing /etc/hostname in base-files image. However, there is log message telling:

"[   7.249795] systemd[1]: Set hostname to <stm32mp1-disco>."

Also, /etc/hosname contents is "stm32mp1-disco".

I can't find what other recipe/module is dealing with hostname settings.

This topic has been closed for replies.
Best answer by Jean-Marc B

Hello @MKaas.1​ 

I agree with your modification related to hostname_pn-base-files = "new_host_name" in the conf file.

I guess there are some troubles with the dhcp service but I am not an expert on this topic so my piece of advice may be really poor.

We can see this line in the file /etc/dhcp/dhcp.client

request subnet-mask, broadcast-address, time-offset, routers,
 domain-name, domain-name-servers, host-name,
 netbios-name-servers, netbios-scope;

From my understanding, the term «host-name» implies to update the board hostname from the DHCP server. If the DHCP leasing is still active from a previous connection, it may explain the change of your hostname through the DCHP service.

To check this hypothesis, perhaps you could boot your board without any ethernet or wifi connections:

  • If the host name changes, it invalidates my hypothesis.
  • If the host name is the one you choose, it means you have a side-effect from the dhcp leasing. In that case, either purge the dhcp server or remove the request «host-name» in the file /etc/dhcp/dhcp.client.

Best regards,

--JM

4 replies

Olivier GALLIEN
Technical Moderator
August 31, 2021

Hi @MKaas.1​ ,

Sorry for late reply.

I found my side : meta-st/meta-st-stm32mp/conf/machine/stm32mp1-disco.conf:#@NAME: stm32mp1-disco

Hope it help

Olivier

Olivier GALLIEN In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
MKaas.1
MKaas.1Author
Associate II
August 31, 2021

That seems a comment to me. The file I mentioned: "/etc/hostname" carries the original hostname. That should be kept unchanged until boot. In common, recipes are not allowed touching files other recipes are producing, i.e. several recipes should not produce the same file. You can possibly cope that with PREFERRED_PROVIDER - just to select packets, but not files. Also, you could write a BBAPPEND recipe to replace the original file. So, I suppose that /etc/hostname is changed by some post-install script or BBAPPEND recipe that I can't find out.

Jean-Marc B
Jean-Marc BBest answer
ST Employee
August 31, 2021

Hello @MKaas.1​ 

I agree with your modification related to hostname_pn-base-files = "new_host_name" in the conf file.

I guess there are some troubles with the dhcp service but I am not an expert on this topic so my piece of advice may be really poor.

We can see this line in the file /etc/dhcp/dhcp.client

request subnet-mask, broadcast-address, time-offset, routers,
 domain-name, domain-name-servers, host-name,
 netbios-name-servers, netbios-scope;

From my understanding, the term «host-name» implies to update the board hostname from the DHCP server. If the DHCP leasing is still active from a previous connection, it may explain the change of your hostname through the DCHP service.

To check this hypothesis, perhaps you could boot your board without any ethernet or wifi connections:

  • If the host name changes, it invalidates my hypothesis.
  • If the host name is the one you choose, it means you have a side-effect from the dhcp leasing. In that case, either purge the dhcp server or remove the request «host-name» in the file /etc/dhcp/dhcp.client.

Best regards,

--JM

MKaas.1
MKaas.1Author
Associate II
August 31, 2021

Hi @Jean-Marc B​ 

This can be true. I checked from st-image-core....tar.gz and there /etc/hostname was that, what I had defined. So, at least build time post installation scripts had not changed it. I'll write the image to SD card and try it out without Ethernet.

MKaas.1
MKaas.1Author
Associate II
August 31, 2021

Yes, I can verify, that /etc/hostname did not change at boot when I booted first time Ethernet disconnected.

Thank you for your help