FedoraForum.org - Fedora Support Forums and Community
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2009
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HowTo: set system HOST name in kickstart

    I am building a kickstart file. But I can't find anywhere how to set the $HOST variable name.

    The GUI install prompts for a host name, then uses that for several things, including naming various LVMs (vg_<host>_root, etc). So is there a way to set this in the kickstart file? Or do I need to manually name everything?

    I could write out a file like /etc/sysconfig/network in a %pre script, %include that file in, and set a variable that way (and then in a %post script write out the fhat file to the chroot'd environment). But I was wondering if there was a simpler built in way to do that. (I do know how to read a vaiable from the kernel boot line in the %pre script).

    TIA

    ken

  2. #2
    Join Date
    May 2011
    Location
    Confoederatio Helvetica (Swissh)
    Age
    46
    Posts
    4,526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HowTo: set system HOST name in kickstart

    I learn much about customizing my own KS while looking at the one's Anaconda is generating after each and every OS installation.
    Have a look at /root/anaconda-ks.cfg

    Hope this helps

    EDIT:
    As i had forgotten to name my machines during the last installations, idk if you find anything usefull.
    Good luck
    * Shell Wrapper and Runtime Modifier (SWARM): https://github.com/sri-arjuna/SWARM
    * Yet Another Simple Script Installer (YASSI): https://forums.fedoraforum.org/showthread.php?323099
    * EFI Cheatsheet :: http://forums.fedoraforum.org/showthread.php?t=298546
    * Windows 8+ & Fedora 20+ Dualboot :: http://forums.fedoraforum.org/showthread.php?t=298161

  3. #3
    Join Date
    Aug 2009
    Posts
    11,390
    Mentioned
    98 Post(s)
    Tagged
    0 Thread(s)

    Re: HowTo: set system HOST name in kickstart

    hostname is set in your kickstart file on the network line using the --hostname parameter..

    For example:

    Code:
    network --onboot yes --device p33p1 --noipv6 --nameserver 192.168.1.254 --hostname tower20.home

  4. #4
    Join Date
    Apr 2009
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HowTo: set system HOST name in kickstart

    Quote Originally Posted by DBelton
    hostname is set in your kickstart file on the network line using the --hostname parameter..

    For example:

    Code:
    network --onboot yes --device p33p1 --noipv6 --nameserver 192.168.1.254 --hostname tower20.home
    I kind of assumed that. But just a couple of clarifications: does this set the $HOSTNAME variable within the kickstart script? Put another way, how do I use that name (tower20.home) in your example) to set logvol names (vg_tower20.home_root, etc). Also, will kickstart put this value into /etc/syconfig/network, or will I need to do this in a %post script.

    (FWIW: I am planning on using this script for multiple installs, with only the host name changed. That would be set in the default pxeboot
    Anyways, thanks for this info. It is a good start, and since this first install is a fresh, test one, I guess I can play around a bit.

    ken

  5. #5
    Join Date
    Aug 2009
    Posts
    11,390
    Mentioned
    98 Post(s)
    Tagged
    0 Thread(s)

    Re: HowTo: set system HOST name in kickstart

    I have never really tried doing what you are wanting, so I really don't know for certain if it sets the $HOSTNAME variable or not.

    I did run across something in my notes from awhile back about getting the hostname in the %pre section, though. It asks for the hostname in a virtual console and set up the network (/etc/sysconfig/network) file.

    Code:
    %pre
    chvt 6
    
    ## Query for hostname, then write it to 'network' file
    read -p "
    
    What is my hostname?
    
    " NAME /dev/tty6 2>&1
    
    echo "NETWORKING=yes
    HOSTNAME=${NAME}" > network
    
    chvt 1
    And in the %post to actually write the file out:
    Code:
    %post --nochroot
    # bring in hostname collected from %pre, then source it
    cp network /mnt/sysimage/etc/sysconfig/network
    . /mnt/sysimage/etc/sysconfig/network
    # force hostname change
    /mnt/sysimage/bin/hostname $HOSTNAME
    
    # setup variables for use in /etc/hosts
    LONG=`/mnt/sysimage/bin/hostname`
    SHORT=`/mnt/sysimage/bin/hostname -s`
    IP=`/mnt/sysimage/usr/bin/host ${SHORT} | awk {'print $4'}`
    echo "${IP}\t\t${LONG} ${SHORT}" >> /mnt/sysimage/etc/hosts

  6. #6
    Join Date
    Apr 2009
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HowTo: set system HOST name in kickstart

    Thanks for all of the suggestions.

    There are some that have some nice suggestions for other uses that I need.

    But the solution to this particular problem turns out to be really simple. As DBelton pointed out, the hostname is the network's hostname. So just add "--hostname=<whatever>" to the network line in your kickstart file.

    This sets the computer's name, as well as the lv's that get generated (vg_<hostname>_lv_root, etc.). which is what I wanted.

    Thanks to all.

    ken

Similar Threads

  1. Replies: 3
    Last Post: 5th August 2008, 02:42 PM
  2. system-config-kickstart FC5 will not run
    By Luniz2k1 in forum Using Fedora
    Replies: 0
    Last Post: 14th October 2006, 12:11 AM
  3. use system-config-kickstart from FC2 for FC1
    By JJS in forum EOL (End Of Life) Versions
    Replies: 0
    Last Post: 9th June 2004, 11:21 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •