Question about /writable being persisted on image dd

Hi all,

lately i ve been working on creating a supposed “flasher gadget” that is sole purpose is to use the snapcraft dump plugin to include a img file inside of it and upon launch utilize cloud-init to dd the image to the disk on device.

This is the grub menu entry of the image that is being dumped and dd’ed.

menuentry "$snap_menuentry" {
    search --label $label --set=writable
    loopback loop ($writable)/system-data/var/lib/snapd/snaps/$snap_kernel    
    linux (loop)/kernel.img $cmdline
    initrd (loop)/initrd.img
}

When i dd the image and restart the device without any usb key attached.
My image works and it boots up, but there is some issues related to it.

This is lsblk output without anything attached to the device:

I think i am having trouble with /writable being persisted and this causes the following:
when i re attach the usb key and boot up, consecutive flashes are no go, the device which is ubuntu core 16 always falls back to booting from disk…