Changeset 2887 in MondoRescue


Ignore:
Timestamp:
Oct 9, 2011, 1:03:19 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Adds support for hwaddr (MAC addresses) at restore time, and map to the correct NIC if it's found at restore time (based on code from Stefan Heijmans)
Location:
branches/2.2.9
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi/README.pxe

    r2498 r2887  
    1111label mondo
    1212        kernel vmlinuz-mondo
    13         append initrd=initrd-mondo load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=131072 rw root=/dev/ram iso acpi=off apm=off devfs=nomount exec-shield=0 pxe [proto=nfs|sshfs] [prefix=machine] [ipconf=(ipdev:ipadr:netmask:broadcast:gateway|ipdev:dhcp)] [netfsmount=server:mountpoint] [netfsopt=-o option][netfspath=local_path] [ping=#] ...
     13        append initrd=initrd-mondo load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=131072 rw root=/dev/ram iso acpi=off apm=off devfs=nomount exec-shield=0 pxe [proto=nfs|sshfs] [prefix=machine] [ipconf=(ipdev:ipadr:netmask:broadcast:gateway|ipdev:dhcp)] [hwaddr=M:A:C:A:D:R] [netfsmount=server:mountpoint] [netfsopt=-o option][netfspath=local_path] [ping=#] ...
    1414
    1515ipdev is the device name (e.g. eth2)
     
    1919gateway is the default gateway (e.g. 192.168.1.254)
    2020dhcp is a keyword. Using it will provide all the previous 4 values to activate the LAN interface.
     21hwaddr is the MAC address of the device you want to use to restore through
    2122proto is the protocol to use for mounting the remote share (default is NFS, sshfs is also available)
    2223server is the ip addr of the Remote Network server
     
    4849CAVEAT: the limit to the number of char on the append line is 255. Use symlinks to reduce the size of your path if needed.
    4950
    50 Please report any problem around that tool to bruno@mondorescue.org
     51Please report any problem around that tool to bruno_at_mondorescue.org
    5152
     532011-10-09 adds support for hwaddr
    52542009-12-05 nfsopt added tp allow for custom options at mount time
    53552009-09-09 Changed to netfs for multi protocol support (nfs, sshfs, ...)
  • branches/2.2.9/mindi/mindi

    r2883 r2887  
    991991    AddFileToCfgIfExists $MINDI_TMP/NETFS-CLIENT-NETMASK netfs-client-netmask $outfile
    992992    AddFileToCfgIfExists $MINDI_TMP/NETFS-CLIENT-BROADCAST netfs-client-broadcast $outfile
     993    AddFileToCfgIfExists $MINDI_TMP/NETFS-CLIENT-HWADDR netfs-client-hwaddr $outfile
    993994    AddFileToCfgIfExists $MINDI_TMP/NETFS-CLIENT-DEFGW  netfs-client-defgw  $outfile
    994995    AddFileToCfgIfExists $MINDI_TMP/NETFS-SERVER-MOUNT  netfs-server-mount  $outfile
  • branches/2.2.9/mindi/rootfs/sbin/start-netfs

    r2709 r2887  
    1212# Get info from config file
    1313ipdev=`grep netfs-dev /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
     14hwaddr=`grep netfs-client-hwaddr /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
    1415ipaddress=`grep netfs-client-ipaddr /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
    1516ipnetmask=`grep netfs-client-netmask /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
     
    3334for i in `cat /proc/cmdline` ; do
    3435    echo $i | grep -qi ping= && ipcount=`echo $i | cut -d= -f2`
     36    echo $i | grep -qi hwaddr= && hwaddr=`echo $i | cut -d= -f2`
    3537    echo $i | grep -qi ipconf= && ipconf=`echo $i | cut -d= -f2`
    3638    echo $i | grep -qi netfsmount= && export netfsmount=`echo $i | cut -d= -f2`
     
    6466            ipgateway=`echo $ipconf | cut -d: -f5`
    6567        fi
     68
     69        # If same system, map to the right MAC address
     70        hwaddr_found=`ifconfig $ipdev | /bin/grep HWaddr | awk '{print $NF}'`
     71        if [ "$hwaddr" != "$hwaddr_found" ]; then
     72            ipdev_new=`ifconfig -a | /bin/grep $hwaddr | awk '{print $1}'`
     73            if [ "$ipdev_new" != "" ]; then
     74                LogIt "Interface $ipdev changed to $ipdev_new (MAC: $hwaddr)"
     75                ipdev=$ipdev_new
     76            else
     77                LogIt "NOTE: Interface $ipdev kept despite it doesn't match the $hwaddr MAC address"
     78            fi
     79        fi
     80
    6681        LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
    6782        ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
    6883        route add default gw $ipgateway
     84
    6985    fi
     86
     87    # Leave time to the satck to wake up (reported by some users)
     88    sleep 5
    7089
    7190    # ping server helps waking interface up
  • branches/2.2.9/mondo/src/common/libmondo-files.c

    r2847 r2887  
    11031103    /*@ buffers ******** */
    11041104    char netfs_dev[MAX_STR_LEN];
    1105     char mac_addr[MAX_STR_LEN];
    11061105    char netfs_mount[MAX_STR_LEN];
     1106    char netfs_client_hwaddr[MAX_STR_LEN];
    11071107    char netfs_client_ipaddr[MAX_STR_LEN];
    11081108    char netfs_client_netmask[MAX_STR_LEN];
     
    11311131            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    11321132    strcpy(netfs_dev, call_program_and_get_last_line_of_output(command));
     1133    sprintf(command,
     1134            "ifconfig %s | head -1 | awk '{print $5}'", netfs_dev);
     1135    strcpy(netfs_client_hwaddr, call_program_and_get_last_line_of_output(command));
    11331136    sprintf(command,
    11341137            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
     
    11481151           call_program_and_get_last_line_of_output(command));
    11491152    sprintf(tmp,
    1150             "netfs_client_ipaddr=%s; netfs_server_ipaddr=%s; netfs_mount=%s",
    1151             netfs_client_ipaddr, netfs_server_ipaddr, netfs_mount);
     1153            "netfs_client_hwaddr=%s; netfs_client_ipaddr=%s; netfs_server_ipaddr=%s; netfs_mount=%s",
     1154            netfs_client_hwaddr, netfs_client_ipaddr, netfs_server_ipaddr, netfs_mount);
    11521155    if (strlen(netfs_dev) < 2) {
    11531156        fatal_error
     
    11661169        log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", netfs_dev);
    11671170        sprintf(command,
    1168                 "ifconfig %s | awk '{print $5}' | head -n1", netfs_dev);
    1169         strcpy(mac_addr, call_program_and_get_last_line_of_output(command));
    1170         sprintf(command,
    1171                 "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1", mac_addr,netfs_dev);
     1171                "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1",netfs_client_hwaddr,netfs_dev);
    11721172        strcpy(netfs_dev, call_program_and_get_last_line_of_output(command));
    11731173        log_to_screen("Replacing it with %s\n", netfs_dev);
     
    11801180    write_one_liner_data_file(tmp, bkpinfo->netfs_proto);
    11811181
     1182    sprintf(tmp, "%s/NETFS-CLIENT-HWADDR", bkpinfo->tmpdir);
     1183    write_one_liner_data_file(tmp, netfs_client_hwaddr);
    11821184    sprintf(tmp, "%s/NETFS-CLIENT-IPADDR", bkpinfo->tmpdir);
    11831185    write_one_liner_data_file(tmp, netfs_client_ipaddr);
Note: See TracChangeset for help on using the changeset viewer.