I'm trying to detect and run partitions on top of jMicron fakeRAID, which is discovered by dmraid. How far I'm stuck with making this automatically during boot.
hopungo@hopungo-pc:~$ sudo kpartx -l /dev/mapper/jmicron_GRAID
jmicron_GRAID1 : 0 7813722112 /dev/mapper/jmicron_GRAID 2048
Here is a good known solution from year 2010, but it is outdated in 2023 (probably, after 22.04). You simply will not find /etc/udev/rules.d/60-kpartx.rules
. And if you make your own, it doesn't work.
I also tried mdadm
, with the same result: I need a working way to run it on system start.
Another option is to use rc.local
script, but it doesn't work too and also looks a bit crutchy. Is there any canonical way to run kpartx
on start since 22.04?
Create a systemd service file, for example:
/usr/lib/systemd/system/custom-jmicron.service
once the file is created, run
On the next reboot, that service should run, executing the command kpartx -a /dev/mapper/jmicron_GRAID once as the service is of type oneshot.
You may need to tweak the After and Before sections to get the timing 100% right, but it should be close.
You can use @reboot option in your crontab, it works fine on most of the distros.