Mount MTD flash memory

Hi!

I am using a habanero-dvk board from 8devices and use an additional external nand-flash. The flash memory is accessible through /dev/mtdblock0. I can mount the device via command line interface using mount -t jffs2 /dev/mtdblock0 /mnt/nand-flash, so all good.

However, I am trying to get the device mounted at startup. What I tried first was to modify the /etc/fstab with /dev/mtdblock0 /mnt/nand-flash jffs2 rw,relatime 0 0. This lets me mount it with mount -a, but it is not mounted at startup.

So, I thought I should probably follow this: fstab . However, I could not see an option to select the jffs2 filesystem type. Also, I installed the block-mount package, but block info does not show me the /dev/mtdblock0 only the main flash:

root@OpenWrt:/# block info
/dev/mtdblock12: UUID="b9fde615-01b782b3-7a5329bb-b29896c7" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"
/dev/mtdblock13: MOUNT="/overlay" TYPE="jffs2"

So, I am a bit confused on what is the way to go to have my device being mounted on startup. Any ideas?

Thanks a lot!

@damanuel, welcome to the community!

Please provide the link to its official OpenWrt support page?

I cannot locate this device under the Table of Hardware.

Is it x86_64?

JFFS2 must not be used on bare NAND flash because it has no handling for bad blocks. If a block in the flash fails or is already bad, the filesystem will be corrupted. Use ubi + ubifs instead.

2 Likes

@damanuel, welcome to the community!

Thanks!

It is armv7l, the page should be that one:

I hope this is what you were asking for.

1 Like

JFFS2 must not be used on bare NAND flash because it has no handling for bad blocks. If a block in the flash fails or is already bad, the filesystem will be corrupted. Use ubi + ubifs instead.

Thanks a lot for the hint. I did not quite manage to do it, though.

I tried to generate an UBI devie for mtdbblock0 by doing ubiattach -m 0 /dev/ubi_ctrl

My flash than showed up here, and I also see a device /dev/ubi0.

root@OpenWrt:/# block info
/dev/mtdblock0: UUID="2597554838" VERSION="1" TYPE="ubi"
/dev/mtdblock12: UUID="b9fde615-01b782b3-7a5329bb-b29896c7" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"
/dev/mtdblock13: MOUNT="/overlay" TYPE="jffs2"

I was under the impression that I could now mount it, but this happened:

root@OpenWrt:/# mount -t ubifs /dev/ubi0 /mnt/ubi
mount: mounting /dev/ubi0 on /mnt/ubi failed: Invalid argument

This would lead me to believe, that my image does not support ubifs, but ubifs shows up in /proc/filesystems:

root@OpenWrt:~# cat /proc/filesystems 
nodev	sysfs
nodev	rootfs
nodev	ramfs
nodev	bdev
nodev	proc
nodev	cgroup
nodev	cgroup2
nodev	tmpfs
nodev	debugfs
nodev	securityfs
nodev	sockfs
nodev	bpf
nodev	pipefs
nodev	devpts
	squashfs
nodev	jffs2
nodev	overlay
nodev	ubifs
	ext3
	ext2
	ext4
	vfat

So I am still struggling to properly mount my flash memory at boot-up and with a suitable filesystem.