title: How to use persistent storage on a qemu machine
body: <p>I have compiled a linux ARM image and a root FS using <a href="https://medicineyeh.wordpress.com/2016/03/29/buildup-your-arm-image-for-qemu/" rel="nofollow noreferrer">this</a> guide (used buildroot, not busybox). I am able to run the image successfully with the rootFS. However, if I create a file in /root, it disappears if I quit the machine and run it again. I would like to be able to change the rootFS, e.g., create files and install packages, and I have exhausted googling how to add a --drive or --device for that purpose.
  Also, I would like to be able to use the storage to share files btw the host and the guest.</p>
  
  <p>This is the current qemu command line I'm using:</p>
  
  <pre><code>qemu-system-arm -M vexpress-a9 -dtb 
  &lt;linux&gt;/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -kernel 
  &lt;linux&gt;/arch/arm/boot/zImage -append "console=ttyAMA0 root=/dev/sda" 
  -initrd ~/buildroot-2018.05/output/images/rootfs.cpio --nographic 
  &lt;somedir&gt;/hd0.img
  </code></pre>
  
  <p>where hd0.img was created using qemu-img.</p>
  
  <p>I'd appreciate an answer as well as a deeper explanation to what's going on.</p>
  
  <p>Thanks! </p>