Menu

Parameter -hn1 uses the MAC address of eth0 always instead of using the one which restores the image before

Help
2018-07-24
2018-09-29
  • Frank Steudle

    Frank Steudle - 2018-07-24

    Dear forum,

    On most of our computers we are using the integrated NIC for the PXE boot of Clonezilla and restoring the images. The internal NICs get the eth0 in most cases. We also have secondary external NICs (mostly common Intel chips) built in which receive the eth1 normally. No external NIC is connected to a switch or router currently. To ensure the right NIC to DHCP lookup, we use the command ocs_prerun1="dhclient -v eth0" to ensure later function.

    Now we have a PC with an integrated NIC (Intel) and an external NIC of Realtek. This time the external NIC receives the eth0 instead of eth1 and the integrated NIC the eth1. Making our default Clonezilla menu not working anymore.

    I already introduced the parameter nicif="a0:48:1c:aa:08:db" (MAC of eth1) to get the Clonezilla image from the server. This is working fine, but the -hn1 parameter generates a computer name called after the MAC address of the network card eth0 (00:08:9F:DA:46:61). It should use the MAC address of eth1 instead.

    I spent a whole day in trying to work it out, but I am failing. Is there a simple way of parameterizing the underlying Debian/Ubuntu system to use eth0 for MAC a0:48:1c:aa:08:db and eth1 for another MAC? And are those parameters integratable in the example Clonezilla call from below?

    We are using the Clonezilla Lite Server clonezilla-live-20180606-bionic-amd64.iso as CD on a separate server.

    label restoreWin7FromRefImage
      # MENU DEFAULT
      # MENU HIDE
      MENU LABEL Restore Windows 7 Home Premium 64 Bit DE
      # MENU PASSWD
      KERNEL Clonezilla-live-vmlinuz
      APPEND 
      initrd=Clonezilla-live-initrd.img 
      boot=live 
      union=overlay 
      hostname=artful 
      config 
      components 
      quiet 
      noswap 
      edd=on 
      nomodeset 
      locales=en_US.UTF-8 
      keyboard-layouts=us 
      echo_ocs_prerun="no" 
        ocs_prerun2="sudo mount -t cifs //x.y.z.abc/share /mnt/ -o user=x,password=y,domain=domain,vers=1.0" 
        ocs_prerun3="sleep 2" 
        ocs_prerun4="sudo mount --verbose --bind /mnt/images/ /home/partimag/" 
        ocs_live_run="/usr/sbin/ocs-sr -icds -scr -e1 auto -e2 -hn1 TST-PANO -b -t -r -j2 -k -p reboot -f sda1 restoreparts REF_MBR_PANO sda1" 
        ocs_live_extra_param="" 
        ocs_live_batch="no" 
      net.ifnames=0 
      nicif="a0:48:1c:aa:08:db"
      nosplash 
      noeject fetch=http://x.y.z.a/Clonezilla-live-filesystem.squashfs 
    

    I am looking for a fast reply.

    Best wished
    Frank

     
  • Frank Steudle

    Frank Steudle - 2018-07-25

    Maybe I have found a solution. Currently untested with the original source of Clonezilla Live from Gitlab. But I have tested the ifconfig/awk/sed statements separately on a Clonezilla Live Testing Cosmic 20180712 AMD 64 image on command line. Those are working.

    # Convert IP address to strings
    tmp_default_route_interface=$(ip r show | awk '/default via / { print $5 };') # returns the name of the interface which is connected to the default route (can be eth0, eth1, eth*)
    
    concat_ifconfig_defaultrouteinterface = "ifconfig " + $tmp_default_route_interface;
    
    tmp_ip=$($concat_ifconfig_defaultrouteinterface | awk '/inet / { print $2 };' | cut -d'/' -f 1 |awk -F. '{print $1+1000"-"$2+1000"-"$3+1000"-"$4+1000 }' | sed -e 's/^1//' -e 's/\-1/-/g') # returns the ip address of the interface which is connected to the default route (for example 009-030-222-015)
    
    tmp_mac=$($concat_ifconfig_defaultrouteinterface | awk '/ether/ { print $2 };' | sed -e 's/://g')  # returns the MAC address of the interface which is connected to the default route (for example a0b2c3d4e5f6)
    

    This code should be put in file ocs-chnthn-functions in directory scripts/sbin/ocs-chnthn-functions in line 263. Replacing the the two lines starting with tmp_ip and tmp_mac.

    The script checks for the default route and saves the network adapter name connected with it. For example eth1.

    Then there is a string concatenation of the command ifconfig and the previously identified network adapter name.

    If the computer name should be adjusted according to the used IP address, then it searches for the IP address in the return of statement ifconfig <ETH*>. The IP is then converted to a value like 009-030-222-015.

    If the computer name should be adjusted according to the used MAC address, then it searches for the MAC address in the return of statement ifconfig <ETH*>. This MAC address is then converted to a value like a0b2c3d4e5f6.

    Steven or Ceasar please review and adopt it if appropriate. Currently I am unable to create an own build environment because I am wondering, if the steps given here are up to date?

    I am looking forward to your answer.

    Best wishes
    Frank

     
  • Steven Shiau

    Steven Shiau - 2018-08-23

    This is not a general case. Normally MAC address is unique, so no matter it's from eth0 or eth1, the generated hostname is unique. Then it should be OK. If you really want to change the hostname with your own idea, then you can write a script and use the command ocs-chnthn to do that. The option "-hn0" or "-hn1" is just a quick option for people to change the hostname of Windows without caring the name, just want the unique name.

    Steven

     
  • Frank Steudle

    Frank Steudle - 2018-09-04

    Hi Steven,

    thank you for your reply and suggestion. You are right, the generated computer names by MAC address are unique.

    For me it is curious, that a computer with built in Realtek NIC and Intel onboard NIC are mixed in the numbering of the NIC. Normally the onboard NIC gets the eth0 and the dedicated NIC gets the eth1. On this computer it is different.

    However I made it easy in my case and accepted it like it is (documented the exception). The computer name is now generated by the MAC address of eth1.

     
  • Steven Shiau

    Steven Shiau - 2018-09-29

    " a computer with built in Realtek NIC and Intel onboard NIC are mixed in the numbering of the NIC. Normally the onboard NIC gets the eth0 and the dedicated NIC gets the eth1. " -> It depends. AFAIK, it depends on the Linux kernel, i.e., the one which is detected first will be the eth0, then eth1, ...

    Steven

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.