# Mac adress and serial replicate over cloning

**URL:** <https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497>\
**Category:** General Discussions\
**Tags:** uboot, mac-adress\
**Created:** [April 12, 2021, 4:54pm UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497 "2021-04-12T16:54:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![profff](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/profff/32/1117_2.png) [@profff](https://hub.mender.io/u/profff)\
**Post date:** [April 12, 2021, 4:54pm UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497/1 "2021-04-12T16:54:27Z")

</div>

Sorry if I’m posting duplicate question I’ve made a short research and did not find any thing here  
and I’m a bit surprise because what I’m dooing is quite simple and I was expecting someone else make the same mistake as me  
I’m using the PI4 image hosted here [https://d4o6e0uccgv40.cloudfront.net/2020-05-27-raspios-buster-lite-armhf/arm/2020-05-27-raspios-buster-lite-armhf-raspberrypi4-mender-2.5.0.img.xz](https://d4o6e0uccgv40.cloudfront.net/2020-05-27-raspios-buster-lite-armhf/arm/2020-05-27-raspios-buster-lite-armhf-raspberrypi4-mender-2.5.0.img.xz)  
setting up the mender client etc  
when my img is ready I whant to be able to clone it over different devices (I’ve made scripts that are generating keys and request for preauthorisation at first boot  
that works well  
I’ve added to `mender-device-identity` the use of `/proc/cpu-info` serial number  
unfortunatly i fall in 2 issue at the same time  
it looks that mac address is persistant over cloning (but I dont find the right net rule or conf file where to adjust that and it looks also that uboot (that what mender converted images are using right ?) is messing up with devtree and result is that serial is same also over cloning !!! ([Why does /proc/cpuinfo always show the same serial number? (U-BOOT). - Raspberry Pi Forums](https://www.raspberrypi.org/forums/viewtopic.php?t=183474) ) So my different devices pre autorisations requests even with different public keys are all identified from same device  
if with your help I could at least fix first mac address issue that could take me off this hole 🙂  
thank’s for any ideas

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [April 12, 2021, 8:38pm UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497/2 "2021-04-12T20:38:34Z")

</div>

I dont use raspvberry-pi’s, however when using imx6 devices i normally extract serial number from the one-time programmable fuses. It looks like the pi’s have something similar that may help if at the very least to confirm if the hardware does actually have the same serial numbers burned into them.

> **[Teach, Learn, and Make with Raspberry Pi – Raspberry Pi](https://www.raspberrypi.org/documentation/hardware/raspberrypi/otpbits.md)**
>
> The Raspberry Pi is a tiny and affordable computer that you can use to learn programming through fun, practical projects. Join the global Raspberry Pi community.

> <https://raspberrypi.stackexchange.com/questions/90832/where-does-the-raspberry-pi-ethernet-mac-get-generated>

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [April 12, 2021, 8:53pm UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497/3 "2021-04-12T20:53:54Z")

</div>

My understanding is that the on-board proprietary firmware determines the MAC address and pokes it into the DTB before U-Boot is launched. Early on we would load the full DTB from the FAT partition but that would result in overwriting the MAC address.

I don’t know what would cause the issue in your case but hopefully the posts from @dellgreen will point you in the right direction.

Drew

---

<div class="post-metadata">

**Author:** ![profff](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/profff/32/1117_2.png) [@profff](https://hub.mender.io/u/profff)\
**Post date:** [April 13, 2021, 1:20pm UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497/4 "2021-04-13T13:20:27Z")

</div>

I changed the `mender-device-identity` script to use only serial and read it directly from OTP memory  
`serial=$( vcgencmd otp_dump | grep "^28:" | cut -d ':' -f 2)`  
it looks working perfectly  
may be you should consider changing it also in your raspberry demo profiles ?  
thanks a lot for your help

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [April 13, 2021, 3:47pm UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497/5 "2021-04-13T15:47:23Z")

</div>

Nice. Thanks for digging into this. @lluiscampos do you have any thoughts on making this change?

Drew

---

<div class="post-metadata">

**Author:** ![lluiscampos](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/lluiscampos/32/112_2.png) [@lluiscampos](https://hub.mender.io/u/lluiscampos)\
**Post date:** [April 26, 2021, 8:29am UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497/6 "2021-04-26T08:29:29Z")

</div>

Hi @drewmoseley and thanks for the heads-up.

After some consideration, I don’t think is a good idea for us to override the `mender-device-identity` for Raspberry images from `mender-convert`.

The main reason is that we are going to remove the Mender client from the downloadable images (see [MEN-4256](https://tracker.mender.io/browse/MEN-4256)) so that the workflows becomes: download + install + configure + deploy (or clone, as the flow in this thread do). The “configure” step here would include writing your own identity script (using `vcgencmd` or anything else).

The `mender-device-identity` script we install is, after all, an [example](https://github.com/mendersoftware/mender/blob/master/support/mender-device-identity#L3).

---

<div class="post-metadata">

**Author:** ![profff](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/profff/32/1117_2.png) [@profff](https://hub.mender.io/u/profff)\
**Post date:** [May 20, 2021, 5:08pm UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497/7 "2021-05-20T17:08:18Z")

</div>

sounds good for me I’ve modded it with hooks

---

<div class="post-metadata">

**Author:** ![zainmehdi](https://avatars.discourse-cdn.com/v4/letter/z/ce7236/32.png) [@zainmehdi](https://hub.mender.io/u/zainmehdi)\
**Post date:** [January 12, 2022, 9:25am UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497/8 "2022-01-12T09:25:37Z")

</div>

Hi @drewmoseley I am facing the same issue. I have an SD card with mender client configured and I clone that card to deploy to multiple devices. I was using a nano pi board before and replaced my mender-identity script to following

```auto
grep Serial /proc/cpuinfo | tr -d "\n\r\t" | sed 's/Serial/cpuid/' | sed 's/:/=/' | tr -d "[:blank:]" | sed 's/$/\n/'

```

Whenever I connected a new nano pi it was detected as a new device on hosted mender dashboard and i was able to add it.

Recently I moved to Raspberry pi and tried to use the same trick but no matter how many boards i change it shows up as one on the dashboard (The first one registered) even though the serial numbers are different. It seems that the device identity is not being read after the first registration,

Would be thankful for any help

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [January 12, 2022, 2:15pm UTC](https://hub.mender.io/t/mac-adress-and-serial-replicate-over-cloning/3497/9 "2022-01-12T14:15:47Z")

</div>

Hi @zainmehdi

When you clone the card you may need to wipe the `/data/mender/mender-store*` and `/data/mender/mender-agent.pem` files/directories.

Drew
