Preeti
Preeti

Reputation: 723

How to implement A/B dual copy scheme partitioning?

I am trying to implement A+B dual copy scheme partition on my Avenger96 board. I am using Yocto build system and also .wks file to create partitions. My .wks file:

part fsbl1 --source rawcopy --sourceparams="file=u-boot-spl.stm32" --part-name "fsbl1" --ondisk mmcblk --align 1 --size 256k
part fsbl2 --source rawcopy --sourceparams="file=u-boot-spl.stm32" --part-name "fsbl2" --ondisk mmcblk --align 1 --size 256k
part ssbl --source rawcopy --sourceparams="file=u-boot.itb" --part-name "ssbl" --ondisk mmcblk --align 1 --size 2M
part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root_A --part-name "rootfs_A" --align 4096 --use-uuid --active --size 3G
part /rootfsB --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root_B --part-name "rootfs_B" --align 4096 --use-uuid --size 3G

bootloader --ptable gpt

And I am able to build .wic.xz image and copied image to SD. It created 2 rootfs partitions.

But when I boot using this SD card, I could see both partitions are mounted. For example, there is also /dev/root which refers to current active partition /dev/mmcblk0p4 and also /dev/mmcblk0p5 (/rootfsB) when I do df -h

Filesystem                Size      Used Available Use% Mounted on
/dev/root                 5.0G      1.1G      3.6G  23% /
devtmpfs                469.7M         0    469.7M   0% /dev
tmpfs                   502.2M         0    502.2M   0% /dev/shm
tmpfs                   502.2M      9.6M    492.5M   2% /run
tmpfs                   502.2M         0    502.2M   0% /sys/fs/cgroup
tmpfs                   502.2M         0    502.2M   0% /tmp
tmpfs                   502.2M     16.0K    502.1M   0% /var/volatile
/dev/mmcblk0p5            5.0G      1.1G      3.6G  23% /rootfsB
tmpfs                   100.4M         0    100.4M   0% /run/user/0

And boot messages also show:

Mounting /rootfsB...
         Starting Start psplash boot splash screen...
[  OK  ] Mounted /rootfsB.

Also doing mount from linux user-space results in:

/dev/mmcblk0p4 on / type ext4 (rw,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=480932k,nr_inodes=120233,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=666)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /var/volatile type tmpfs (rw,relatime)
/dev/mmcblk0p5 on /rootfsB type ext4 (rw,relatime)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=102840k,mode=700)

Is this the expected behavior for A+B type partitioning?

Can anyone please let me know what could be the issue and how to resolve it?

Your help will be much appreciated.

Thanks in advance.

P.S: Please let me know if any info is missing here.

Upvotes: 2

Views: 2365

Answers (1)

robert.berger
robert.berger

Reputation: 13861

This is actually what I would expect. You want to boot from the "active" (A) partition, but you also want to be able to update the "passive" (B) partition. After you updated the "passive" (B) partition you typically tell the bootloader to try to boot from it. If that works (B) becomes the "active" partition and (A) the "passive" one.

Upvotes: 1

Related Questions