Please note that this is not officially approved by the PI team but the MagPi magazine offers a similar tutorial using a pendrive.
Download the Pixel (Jessie Raspbian) image file: http://downloads.raspberrypi.org/pixel_x86/images/pixel_x86-2016-12-13/2016-12-13-pixel-x86-jessie.iso
Open Virtual Box, press new and create the following settings:
Press Create and enter the following settings
Browse to the downloaded ISO file and press Start
Pixel is loaded
To test persistence, create a new folder on your desktop and restart your OS.
Once your OS is restarted, you will notice that the folder you created is lost. This is because there is no persistence drive present.
Step 5 (to create persistence drive):
Open terminal window and enter sudo apt install gparted
When installation is finished, enter sudo gparted
Click on Device > Create Partition Table and press Apply
Right Click on the unallocated partition and press New
Enter label name persistence with the following default settings and press Add
Press the green very good sign and press Apply to any warning messages
Press Close and close everything
Now we are going to copy the whole operating system from the virtual optical drive to
the hard drive.
Open the terminal window and enter sudo dd if=/dev/sr0 of=/dev/sda bs=1M
Close the virtual machine (shutdown the OS)
Create a new Virtual Machine with the following settings. It is very important that you use your previously created virtual hard disk file. Do no create a new virtual hard disk.
Start your new machine and create a new python script to test persistence. I saved my file in the desktop. Restart your OS.
Test file is still there. Persistence worked 🙂