Working with SDCards

I'm learning about openwrt by building my own fw for a nanopi h3 which has an sdcard for the operating system.

I'll have maybe ten of these things, all using the same configuration once I have it working right on the first one.

To prevent having to take them apart to get into them using serial, do I simply clone the sdcard and pop it into my others and they will all run the same version/configuration etc?

The network and wireless configs can include MAC addresses which should match your actual hardware.
In addition, make sure that your mount settings use the proper file system UUID for each SD card, or mount by device name.

1 Like


I'm not completely following since I'm new to this.
I built a firmware using the make menuconfig and picked the packages I want.

When I fired up the device, I didn't mount anything, haven't had to do anything so far.

Does it mean the sd card is only used to boot and nothing else? I don't even see it when doing a df. It's an 8GB card.

df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 102.4M 16.6M 83.7M 17% /
tmpfs 215.1M 1.0M 214.1M 0% /tmp
tmpfs 512.0K 0 512.0K 0% /dev

I basically just want to replicate the build so I can pop a card into one any time I need another one fired up.

This is relevant if you plan to use block-mount for something like extroot, otherwise you can ignore it.
So, assuming you take care of the hardware-specific settings such as the ones mentioned above, cloning should work in general.

Ok, if I understand correctly, the OS is fully running on the sdcard?
And, if I prepare the OS the way I want it, excluding any hardware specific things, I will be able to copy the sdcard and use it in my other identical other devices.

If this is the case and the Os is running on the sdcard (which it must be since it's the only place I have one), why can I not see it when looking for it using df?

1 Like

Check the output:


What image have you flashed?

The image is one I created using 'make menuconfig'.

# mount
/dev/root on / type ext4 (rw,noatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)

1 Like

Perhaps you are running the initramfs-kernel image.

Do you mean the squashfs image? I thought I tried that first but I don't recall now so will again.

1 Like

Using the squash version of the build, booting goes into a loop, missing Ethernet.

Error: ethernet@1c30000 address not set.
No ethernet found.

starting USB...
Bus usb@1c1b000: USB E

The two images that resulted from my buil are.

132121389 openwrt-sunxi-cortexa7-friendlyarm_nanopi-r1-ext4-sdcard.img
28616079 openwrt-sunxi-cortexa7-friendlyarm_nanopi-r1-squashfs-sdcard.img

1 Like

Oh, I see, then use this one:

And check:

ls -l /sys/block

Is something wrong with my build?

root@OpenWrt:~# ls -l /sys/block
lrwxrwxrwx    1 root     root             0 Feb  2 21:30 loop0 -> ../devices/virtual/block/loop0
lrwxrwxrwx    1 root     root             0 Feb  2 21:30 loop1 -> ../devices/virtual/block/loop1
lrwxrwxrwx    1 root     root             0 Feb  2 21:30 loop2 -> ../devices/virtual/block/loop2
lrwxrwxrwx    1 root     root             0 Feb  2 21:30 loop3 -> ../devices/virtual/block/loop3
lrwxrwxrwx    1 root     root             0 Feb  2 21:30 loop4 -> ../devices/virtual/block/loop4
lrwxrwxrwx    1 root     root             0 Feb  2 21:30 loop5 -> ../devices/virtual/block/loop5
lrwxrwxrwx    1 root     root             0 Feb  2 21:30 loop6 -> ../devices/virtual/block/loop6
lrwxrwxrwx    1 root     root             0 Feb  2 21:30 loop7 -> ../devices/virtual/block/loop7
lrwxrwxrwx    1 root     root             0 Feb  2 21:30 mmcblk0 -> ../devices/platform/soc/1c0f000.mmc/mmc_host/mmc0/mmc0:211f/block/mmcblk0
1 Like

This is probably the SD card.

I guess it's just hardware specifics.

Try to identify block devices:

opkg update
opkg install block-mount
block info

To be clear, I built the image then I wrote it to the sdcard using a windows utility called Win32 Disk Imager.

~# block info
/dev/mmcblk0p1: UUID="09C6-628A" VERSION="FAT16" TYPE="vfat"
/dev/mmcblk0p2: UUID="ff313567-e9f1-5a5d-9895-3ba130b4a864" LABEL="rootfs" VERSION="1.0" MOUNT="/" TYPE="ext4"

1 Like

As I understand, my device doesn't have any storage at all, it only has RAM and an sdcard slot. Therefore, when I write the image to the sdcard, insert it into the router, the whole thing is running from that sdcard.

Any changes I make in /etc for example would survive and the sdcard could be cloned to use on other identical devices.

Is my understanding correct?

1 Like

That's right according to the diagnostics output.

Nice, my first build :).
I better understand now. Still not sure why I cannot see the sdcard however but at least the router is working.

Thank you for your help, it is very appreciated.

1 Like

It should be /dev/mmcblk0 split into 2 partitions, and second one appears to be mapped to /dev/root:

Thank you for all of your help and input.

1 Like