Bug 7417

Summary: Add section on changing hostname
Product: [Documentation] Development Manual Reporter: Ross Burton <ross.burton>
Component: developmentAssignee: Scott Rifenbark <srifenbark>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Medium CC: srifenbark
Version: unspecified   
Target Milestone: 1.8 M4   
Hardware: All   
OS: Multiple   
Whiteboard: 17 March 2015: IN PROGRESS DESIGN
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Ross Burton 2015-03-06 16:39:05 UTC
We should add a section to the manuals somewhere explaining how to change the default hostname in the image.  Maybe Common Tasks in the Development Manual?

Something like this:


Changing the hostname
===

By default the configured hostname in an image is the same as the machine
name, i.e. qemux86.  This can be changed by altering the value of the variable
"hostname" in the base-files recipe, with either a bbappend
(hostname="myhostname") or configuration file (hostname_pn-base-files =
"myhostname").

If the hostname is unset then the image will have no default hostname in the
filesystem, making it suitable for environments with dynamic hostnames such as
virtual machines.
Comment 1 Scott Rifenbark 2015-03-06 19:10:55 UTC
Ross, 

I don't get this.  You say that by default, the configured hostname in an image is the same as the machine name.  Then, you say you can alter that by setting "hostname" in the recipe or messing with the configuration file.  

But if the hostname variable is unset then the image has no default hostname in the filesystem?   

There are terms here I must not understand or assumptions being made in the text because it seems contradictary.  

Scott
Comment 2 Scott Rifenbark 2015-03-06 19:11:34 UTC
Adding myself to cc list so I see the replies.
Comment 3 Ross Burton 2015-03-09 14:48:19 UTC
The default value of the variable "hostname" which is written into the image is the machine name.  You can change the variable to any other value (I use hostname_pn-base-files="bob" so all my images are called bob for ease of testing), or set it to "" and no hostname will be written into the image.

When I say written into the image, I mean written to /etc/hostname.

Hopefully that helps?
Comment 4 Scott Rifenbark 2015-03-17 17:15:22 UTC
Ross, 

I have a section in the YP Development Manual called "Customizing Images" (http://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#usingpoky-extend-customimage).  That section has a bunch of sub-sections.  How about creating a new subsection that specifically addresses how to change the hostname written into etc/hostname of the image?  To me, this is customization of sorts.  We could use your specific debug example as rationale for doing this.  Would this work?

Scott
Comment 5 Ross Burton 2015-03-18 09:27:48 UTC
Yes, that sounds good.
Comment 6 Scott Rifenbark 2015-03-18 15:34:38 UTC
Ross, 

Please look over the new section at http://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#usingpoky-extend-customimage-image-name.  

I need to know if "base-files" in that sample command is a placeholder and not a literal.  If it is a placeholder then I need to change the formatting. 

Thanks, 
Scott
Comment 7 Ross Burton 2015-03-20 20:54:33 UTC
First, base-files is a literal so the formatting is correct as far as I can tell.

The final paragraph implies the wrong facts:

"Another point of interest is that if you leave the variable "hostname" unset, the image will have no default hostname in the filesystem. This condition is suitable for environments that use dynamic hostnames such as virtual machines."

You can't leave hostname unset as it has a default value.  You can unset it by assigning "", as the note already mentions.  Maybe remove the note and change the paragraph to say "unset the variable with =''"?
Comment 8 Scott Rifenbark 2015-03-20 22:28:10 UTC
Ross, 

I made some changes.  Please verify that they are okay.  Once you do that I can close the bug.  See http://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#usingpoky-extend-customimage-image-name. 

Thanks, 
Scott
Comment 9 Ross Burton 2015-03-20 23:24:57 UTC
Looks good, closing.  Thanks Scott!