0

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

11
  • What's the output of mount | grep devtmpfs? Commented Apr 5, 2024 at 12:45
  • Output of mount | grep devtmpfs: devtmpfs on /dev type devtmpfs (rw,nosuid,noexec,relatime,size=10240k,nr_inodes=498259,mode=755,inode64) Commented Apr 5, 2024 at 12:50
  • You're dealing with something funny/unsual. Could be your kernel. Commented Apr 5, 2024 at 12:54
  • 2
    As an aside, your use of dd is terribly inefficient. You will get much better throughout with a simple cat file.img >/dev/sda Commented Apr 5, 2024 at 13:50
  • 2
    @ChrisDavies I'm actually using pv with dd. To be honest, I didn't know cat is faster but I'll give it a go @ArtemS.Tashkinov well, that's what I'm saying, I don't configure anything in the kernel. I just boot alpine with whatever kernel settings it comes, dd and then try to mount the drive. Anyways, I found that I can actually create the missing devices using mknod: mknod -m 660 /dev/sda2 b 8 2 so the problem can be considered "fixed". Commented Apr 5, 2024 at 15:59

1 Answer 1

0

For anyone looking for a solution to this, you can either:

  1. Create your device entry under /dev. An example for adding the /dev/sda2 follows:

mknod -m 660 /dev/sda2 b 8 2

  1. Try to run

mdev -s

The 2nd command made my life easier and, so far it works without any issues. Mdev's man page:

Usage:
    mdev [-vS] 

        -v        Verbose
        -S        Log to syslog too
        -s        Scan /sys and populate /dev
        -d        Daemon, listen on netlink
        -f        Run in foreground

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.