Btrfs allows you to have multiple volumes (snapshots). So, if you have enough space you can create an extra (alternative) image to experiment with. You can then send that image to the eMMC and boot it. If it works well, you can make the change permanent. Or reboot back to the original image and remove the experimental image.
btrfs snapshotAfter Building the image (including the Postbuild step) you run btrfsSnapshot.py once (and only once) on your image.
meta-intel-edison/utils/flash/btrfsSnapshot.py
btrfsSnapshot.py will produce a compressed btrfs snapshot out/current/build/tmp/deploy/images/edison/edison-image-edison.snapshot.7z. The snapshot containing the rootfs has the name @new.
btrfs snapshotThe edison.snapshot.7z can be sent over-the-air (OTA) to a booted Edison assuming it is accessible with ssh root@edison.local:
meta-intel-edison/utils/flash/btrfsFlashOta.sh -i
btrfsSnapshot.py uncompresses the file and uses btrfs send/receive commands to transfer the snapshot. The image will appear as @new (alongside @, @boot, @modules and @home that where already there).
@new rootfsYou can now boot @new image by interrupting U-Boot and running:
run do_altboot
Or from linux:
reboot alt
@boot and modules at this point, so the new image will boot with the existing kernel.The easiest way (and suitable to be performed over-the-air) is, while booted in the alternative image, remove the @ volume, take a new snapshot of the @new volume with the name @, reboot and then remove the @new volume.
The subvolumes can be found in the top level volume that is not yet mounted.
root@edison:~# btrfs su list /
ID 256 gen 183338 top level 5 path @home
ID 257 gen 143392 top level 5 path @boot
ID 258 gen 699017 top level 5 path @modules
ID 259 gen 736483 top level 5 path @
ID 260 gen 507745 top level 259 path var/tmp
root@edison:~# mount -t btrfs
/dev/mmcblk0p8 on / type btrfs (rw,relatime,compress=lzo,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@)
/dev/mmcblk0p8 on /boot type btrfs (rw,noatime,compress=lzo,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@boot)
/dev/mmcblk0p8 on /usr/lib/modules type btrfs (rw,relatime,compress=lzo,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@modules)
/dev/mmcblk0p8 on /home type btrfs (rw,relatime,compress=lzo,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/@home)
root@edison:~# mount /dev/mmcblk0p8 /mnt
root@edison:~# cd /mnt
root@edison:/mnt# ll
total 4
drwxr-xr-x 1 root root 216 Oct 18 2024 @
drwxr-xr-x 1 root root 610 Oct 31 2024 @boot
drwxr-xr-x 1 root root 10 Nov 5 2024 @home
drwxr-xr-x 1 root root 326 Oct 31 2024 @modules
drwx------ 1 root root 0 Nov 5 2024 lost+found
drwxr-xr-x 1 root root 30 Mar 9 2018 root
drwxr-xr-x 1 root root 0 Mar 9 2018 srv
Now you can manipulate the volumes as needed using btrfs su commands. When done unmount.
root@edison:/mnt# cd ~
root@edison:~# umount /mnt
© 2018 Ferry Toth