Mac address Home Media

From NAS-Central Iomega Wiki
Jump to: navigation, search

The mac address of the Home Media is stored on harddisk. It is provided when loading the gmac kernel module.
Contents of /etc/modules:

gmac mac_adr=0x00,0xD0,0xB8,0x12,0x34,0x56
thermAndFan
ehci-hcd
usb-storage
usblp

On a factory reset the MAC address is removed from /etc/modules. Then /etc/init.d/gmac will extract the address from one of the 2 u-boot environment blocks, and write it to /etc/modules:

unset ethaddr
for blk in 239 10846 ; do
        eval `dd if=/dev/sda skip=${blk} count=16 2> /dev/null \
                | readenv | grep ethaddr`
        if [ -n "${ethaddr}" -a "${ethaddr}" != "${mfgMAC}" ] ; then
                break
        fi
done
if [ -z "${ethaddr}" -o "${ethaddr}" = "${mfgMAC}" ] ; then
        echo
        echo "FATAL: $0 found invalid (or no) MAC ${ethaddr} in /etc/modules"
        echo "or u-boot env blocks at 239 or 10846 - going catatonic ..."
        mcucmd led_err
        mcucmd gauge_critical
        sh      ## stop mfg boot dead at a shell prompt
fi
if lsmod | grep ^gmac ; then
        /bin/ip link set eth0 address "${ethaddr}"
else
        modarg=0x$(echo ${ethaddr} | sed -e 's/:/,0x/g')
        sed -i -e "s/^gmac.*/gmac mac_adr=${modarg}/" /etc/modules
fi
exit 0

The MAC addresses in the environment blocks could be found at absolute byte offsets 122380 and 5553164 on harddisk. (No guarantee about that addresses. Don't know how the environment blocks are filled in the factory.)