I have a file.img file which was obtained by running dd if=/dev/sda of=file.img. This was done on a device with two partitions, /dev/sda1 and /dev/sda2.
In order to flash a new device with the same image, I'm booting an Alpine Linux using network boot, copy the file.img from the network and run the dd if=file.img of=/dev/sda. This is competed successfully and if I reboot, the device boots up properly.
The issue is that I want to add some files to the new device. Naturally, I thought I'll just mount the /dev/sda2 (that's the device I want to add stuff to) and add stuff there. Well, not that simple: /dev/sda2 is missing - sometimes.
After the dd command runs, sometimes - without a pattern observed - the partitions are missing. Checking the disk using fdisk -l /dev/sda shows both partitions there.
Running partprobe /dev/sda; dmesg always shows (dmesg command outputs this) sda: sda1 sda2 so the partitions are there and they're being recognized. Still, they don't appear under /dev/.
The funny part is that running partprobe /dev/sda sometimes fixes the issue, other times it doesn't.
With all this madness, rebooting the device will ALWAYS boot correctly.
If anyone has any idea what I could try, I'd greatly appreciate the ideas.
Thank you.
P.S.:
I also tried to run partx -uv /dev/sda. That tells me:
partition: none disk: /dev/sda, lower: 0, upper: 0
/dev/sda: partition table type 'dos' detected
/dev/sda: partition #1 added
/dev/sda: partition #2 added
But the partitions still can't be found under /dev/sdaX
mount | grep devtmpfs?mount | grep devtmpfs:devtmpfs on /dev type devtmpfs (rw,nosuid,noexec,relatime,size=10240k,nr_inodes=498259,mode=755,inode64)ddis terribly inefficient. You will get much better throughout with a simplecat file.img >/dev/sdamknod -m 660 /dev/sda2 b 8 2so the problem can be considered "fixed".