My WD MyBook / OpenWRT 21.02.02 installation is a one trick pony so to speak, the basic one HDD version.
Like I have mentioned before (being a hard drive install) I have added/been able to add a number of packages that make OpenWRT more useful/flexible, a work in progress.
Looking at the dmesg output, I see the following lines:
--- snip ---
[ 0.853468] md: Waiting for all devices to be available before autodetect
[ 0.860251] md: If you don't use raid, use raid=noautodetect
[ 0.866370] md: Autodetecting RAID arrays.
[ 0.870475] md: autorun ...
[ 0.873264] md: ... autorun DONE.
--- /snip ---
Being a one drive setup it would seem that it has no use for md (?), which I would then like to disable.
But I cannot find where to add the "raid=noautodetect" stanza.
Looking around the forum, I found a way to query init scripts here, so I checked:
root@OpenWrt:~# for F in /etc/init.d/* ; do $F enabled && echo $F on || echo $F **disabled**; done
/etc/init.d/avahi-daemon on
/etc/init.d/boot on
/etc/init.d/cron on
/etc/init.d/dbus on
/etc/init.d/done on
/etc/init.d/dropbear on
/etc/init.d/firewall on
/etc/init.d/fstab on
/etc/init.d/gpio_switch on
/etc/init.d/led on
/etc/init.d/lm-sensors on
/etc/init.d/log on
/etc/init.d/mdadm on # <--- here it is
/etc/init.d/network on
/etc/init.d/rpcd on
/etc/init.d/rsyncd **disabled**
/etc/init.d/sudo on
/etc/init.d/sysctl on
/etc/init.d/sysfixtime on
/etc/init.d/sysfsutils on
/etc/init.d/sysntpd on
/etc/init.d/system on
/etc/init.d/ucitrack on
/etc/init.d/uhttpd on
/etc/init.d/umount **disabled**
/etc/init.d/urandom_seed on
/etc/init.d/urngd on
/etc/init.d/vsftpd on
/etc/init.d/wpad on
root@OpenWrt:~#
Being a daemon, I can also query as to its status, start and stop it:
root@OpenWrt:~# /etc/init.d/mdadm status
running
root@OpenWrt:~#
So the question would be:
Being a one HDD installation, does Open WRT need mdadm to boot and work properly?
ie: can I disable mdadm without issues?
The 'raid=noautodetect' option is a command line option. Maybe you can add it in the u-boot environment. But, as you can see in the bootlog, it will only save you 20 msec boottime.
When you didn't use raid containers, you don't need mdadm. Having just a single disk doesn't automatically imply that. It's perfectly possible to have a single disk raid1 array, or something like that.
Probably, but have not found how.
Hence my question.
But my motive for disabling mdadm has no relation to boot time.
It is related to the object of starting and running a daemon for which there is no need/use whatsoever.
That was the general idea, thanks for clearing it up.
So I can disable the mdadm daemon?
I've never come across such a thing.
As far as I know, a raid1 array is a mirrored data operation.
ie: a minimum of two disks: one a mirror (exact copy) of the other.
Cannot see how that could be done with just one disk.
Be that as it may, the WD-MyBook has very limited resources so (IMO) turning off unneeded services is the only way to make the most of them.
I see.
Never bothered with a serial port mod.
Seemed too much of a hassle/complication/risk as everything was 'on disk'.
That plus disassembly/assembly of the WD-MyBook to take out the drive and hang it from my main box eventually became easy enough.
So ...
That would be: root@OpenWrt:~# fw_setenv raid=noautodetect ?
No. Using fw_printenv you can see the current environment. There is a variable 'cmdline' which has to be expanded with raid=noautodetect.
It's not a daemon which keeps running. It's a procedure in the kernel which runs once, for autodetect, and when it says 'autorun DONE' it's really done.
At some level a raid array is no more than a header on a partition. mdadm reads that header and tells the kernel to find the filesystem at an offset (header size) of the partition. (Mdadm isn't there to stay, it just reads the headers and assambles the raid arrays. Exit mdadm. Unless you run it in daemon mode, in which case it sends you an email if something goes wrong).
The purpose of a single disk raid1 array is either to be able to add a second disk in future, or to keep the firmware simple and simply put all data partitions in a raid array, no matter what.
I see.
But it was 'on' and now it is 'disabled'.
Just like wpad, which I did not need.
(see OP)
root@OpenWrt:~# for F in /etc/init.d/* ; do $F enabled && echo $F on || echo $F **disabled**; done
/etc/init.d/avahi-daemon on
/etc/init.d/boot on
/etc/init.d/cron on
/etc/init.d/dbus on
/etc/init.d/done on
/etc/init.d/dropbear on
/etc/init.d/firewall on
/etc/init.d/fstab on
/etc/init.d/gpio_switch on
/etc/init.d/led on
/etc/init.d/lm-sensors on
/etc/init.d/log on
/etc/init.d/mdadm **disabled** # <--- here it is
/etc/init.d/network on
/etc/init.d/rpcd on
/etc/init.d/rsyncd **disabled**
/etc/init.d/sudo on
/etc/init.d/sysctl on
/etc/init.d/sysfixtime on
/etc/init.d/sysfsutils on
/etc/init.d/sysntpd on
/etc/init.d/system on
/etc/init.d/ucitrack on
/etc/init.d/uhttpd on
/etc/init.d/umount **disabled**
/etc/init.d/urandom_seed on
/etc/init.d/urngd on
/etc/init.d/vsftpd on
/etc/init.d/wpad **disabled**
root@OpenWrt:~#
I see.
Learned something new today.
Thanks for that. 8^)
That are two different things. The 'raid autodetect' runs in the kernel, even before the rootfs is mounted. (The rootfs might be on the 'to be detected' array). mdadm is a tool which runs in userspace, to assemble&maintain raid arrays which are not autodetected.
That is also the reason that you have to switch it off in the kernel command line. It cannot be a config file, because there are no files, yet.
Probably. Strange that uboot-envtools are included in the image, then. Unfortunately the wiki doesn't tell how the flash is organized. Normally there is a (ro) flash partition of 128~256kB containing u-boot, followed by a (rw) partition of 8~64kB containing the environment. uboot-tools need to know which flash device to use, at which offset, and which size. And that is defined in /etc/fw_env.config.
The entries I see in the example are:
NOR example
MTD SPI-dataflash example
MTD device name
NAND example
Block device example
VFAT example
UBI volume
UBI volume by name
From what I can see (and understand) the only possiblilities are either in /dev or /boot but none of the examples are present in /dev:
boot.src is a script file handled by u-boot. As most files handled by u-boot it is preceded by a 64 byte header, containing the purpose, a name ('Boot Script' in your case) and a checksum.
You can create your own boot.scr using mkimage: mkimage -A powerpc -O linux -T script -C none -a 0 -e 0 -n 'Boot Script' -d plain.txt boot.scr
I think your plain text starts with the setenv after the '&'.
mkimage is part of uboot-tools. 'Boot Script' can be anything, the name is not used by u-boot, only printed to console.
You can strip the plain text with the command tail -c +64 boot.scr
Q1: all the content ie: purpose, name and checksum result from the mkimage above?
So it would be done in three steps:
strip the text as indicated.
edit the line/text containing the relevant kernel commands and save.
generate a new version of boot.scr with the mkimage stanza above.
Q2: does the *.scr file have room for any sort of # comments?
I'll know for sure when I strip the text.
So I could change the name to boot2.scr without any effect?
Right.
Thank you very much for taking the time to explain how to do this.
Much obliged.
I'll do it this week and report the results, hopefully usefull to the dozen or so owners of a WD-MyBook out there who have not given up and finally thrown it into a skip. 8^D
Right. I took a look, and it seems uboot-tools is not available as package on OpenWrt, and uboot-envtools is a subset of that. The envtools contain fw_printenv and fw_setenv, tools which have to be run on the router itself. The other tools can be run on another platform. I suppose for that reason nobody cared to package it for the size-constrained OpenWrt.
Further, the name of the package on Debian is u-boot-tools.
The most obvious work-around is to install u-boot-tools on your favorite non-OpenWrt Linux box and create the boot.scr there.
Done.
Almost, but no cigar ... 8^/
It did not (complete) the boot sequence.
Here's what I did:
Took the original boot.scr and stripped the plain.txt:
Original plain.txt from original boot.scr:
&setenv boot_args 'setenv bootargs root=/dev/sda2 rw rootfstype=squashfs,ext4'
setenv load_part1 'ext2load sata 0:1 ${kernel_addr_r} /boot/uImage; ext2load sata 0:1 ${fdt_addr_r} /boot/apollo3g.dtb'
setenv load_part2 'ext2load sata 1:1 ${kernel_addr_r} /boot/uImage; ext2load sata 1:1 ${fdt_addr_r} /boot/apollo3g.dtb'
setenv load_sata 'sata init; if run load_part1; then echo Loaded part 1; elif run load_part2; then echo Loaded part 2; fi'
setenv boot_sata 'run load_sata; run boot_args addtty; bootm ${kernel_addr_r} - ${fdt_addr_r}'
run boot_sata
Edited to add raid=noautodetect:
&setenv boot_args 'setenv bootargs root=/dev/sda2 rw rootfstype=squashfs,ext4 raid=noautodetect'
setenv load_part1 'ext2load sata 0:1 ${kernel_addr_r} /boot/uImage; ext2load sata 0:1 ${fdt_addr_r} /boot/apollo3g.dtb'
setenv load_part2 'ext2load sata 1:1 ${kernel_addr_r} /boot/uImage; ext2load sata 1:1 ${fdt_addr_r} /boot/apollo3g.dtb'
setenv load_sata 'sata init; if run load_part1; then echo Loaded part 1; elif run load_part2; then echo Loaded part 2; fi'
setenv boot_sata 'run load_sata; run boot_args addtty; bootm ${kernel_addr_r} - ${fdt_addr_r}'
run boot_sata
That first & does not belong to the plaintext.
And no, the platform on which mkimage runs doesn't matter. It's a simple tool to create a header, nothing fancy.