Difference between revisions of "Change Default Host Names"

From ubermix Wiki
Jump to: navigation, search
(Updated to current script code)
m
Line 12: Line 12:
 
#Press "ctrl-x" to boot your machine
 
#Press "ctrl-x" to boot your machine
 
#When your machine finishes booting up, open a terminal (ctrl-alt-t) and type the following: sudo gedit /usr/local/bin/update-hostname
 
#When your machine finishes booting up, open a terminal (ctrl-alt-t) and type the following: sudo gedit /usr/local/bin/update-hostname
#Locate the following section of the script, and change the two instances of the word "system" to whatever you like. Be careful not to delete the "\t" before the word "system" in the second line:
+
#Locate the following section of the script, and change the three instances of the word "system" to whatever you like. Be careful not to delete the "\t" before the word "system" in the second instance:
  
 
  <nowiki>if  ! $FOUND; then
 
  <nowiki>if  ! $FOUND; then

Revision as of 15:15, 18 January 2012

In order to ensure that every device has a unique hostname for Dynamic DNS (and because unique hostnames are simply good form), the ubermix automatically assigns a hostname on first boot to every device it is installed on. This hostname, by default, is set to the word "system" followed by a "-" and the last 3 octets of the device's ethernet card MAC address. So, for example, of my device's ethernet card has a MAC address of 18:03:73:78:36:67, on first boot my device's hostname will be set to "system-783667". While this works fine for most installations, some people would prefer to set hostnames to something else.

If you would like to set the hostname to something else, you basically have two options:

  1. Alter the hostname script that sets the hostname by adding your own customizations
  2. Disable the script entirely, and manually set the hostname (or ignore it altogether)


To alter the hostname script, do the following:

  1. Boot or reboot your machine, and press "esc" when the screen goes blank immediately after showing the model specific splash screen.
  2. Select "Normal Boot" and press the "e" key on your keyboard
  3. Select the line in the box that begins with the word "initrd" and move the cursor to the end of the line. Backspace over the four letters "aufs" and replace them with "generic". Do not add any spaces.
  4. Press "ctrl-x" to boot your machine
  5. When your machine finishes booting up, open a terminal (ctrl-alt-t) and type the following: sudo gedit /usr/local/bin/update-hostname
  6. Locate the following section of the script, and change the three instances of the word "system" to whatever you like. Be careful not to delete the "\t" before the word "system" in the second instance:
if  ! $FOUND; then
	echo "system-$ETH_ADDR" >/etc/hostname
	sed -i "s/127.0.1.1.*$/127.0.1.1\tsystem-$ETH_ADDR/g" /etc/hosts
	if `mount | grep -q "SYSTEM on /ro"`; then
		mount -o rw,remount /ro
		cp /etc/hostname /ro/etc/hostname
		cp /etc/hosts /ro/etc/hosts
		mount -o ro,remount /ro
	fi
	hostname "system-$ETH_ADDR"
fi

When you are done, save your changes, reboot, and all future machines will use your new scheme.


If you want to disable the script altogether, perform steps 1-4 above, then:

  1. Open a terminal (ctrl-alt-t) and type the following: sudo gedit /etc/rc.local /etc/hostname /etc/hosts
  2. In the rc.local tab, locate the "update-hostname" line and delete it. Save and close the file.
  3. In the hostname tab, change the hostname to whatever you want
  4. In the hosts tab, change the "system-xxxxxx" to the same thing you set the hostname to in step 3 above.