Articles

[HOWTO] Create and use magic folders

As of Version 1.0, Porteus comes with a feature called "Magic Folders", which was borrowed from falcony's FIDOSlax project. Many thanks to falcony, and to fanthom, for implementing this in Porteus!

See this thread for more background information.

The short explanation is that magic folders will allow you to save changes that you make to a particular folder in your live filesystem to a particular folder (or .dat image file) on a hard disk, USB flash drive, or other media.

For example, if you do not want all of your persistent changes saved to the same place (e.g. save.dat), you can save your changes to /root to root.dat and changes to /guest to guest.dat. Or, you can create a file on your flash drive that will save files to the same location across multiple users or installs (more on that later).

To begin using magic folders, you need to open Porteus Settings Centre (located in the KDE, LXDE or Xfce menu under the 'System' heading), click on the button at the top for "Changes", and then click on the "Porteus Magic Folders" button.  This will open a window that will ask you for a source directory and a target directory or .dat container.  The source directory refers to the folder inside your live filesystem, for example, /home/guest/Downloads.  The target directory refers to the folder or .dat container on a real fileysystem, for example, /mnt/sdb1/Downloadsave.dat.  Click on the folder icon next to each blank in order to find and select the desired folders (you can create new folders from within this dialog, but if you would like to use a .dat container, you must create one using the 'Porteus save.dat manager' first).  Once you have selected the source and target, Click "OK" to complete the pairing, and you will then be asked if you want to begin recording changes in the current session.  Click yes or no, then click Ok, and the process will be complete.  A configuration file will be generated in your rootcopy directory, at /porteus/rootcopy/etc/magic_folders. This file is a list of paired folders, and you can edit it directly (or go through the above process again) to create more magic folder pairings.

Note:  If you are saving changes to a FAT or NTFS filesystem, it is suggested that you use a .dat file container to preserve permissions and symlinks.

Upon reboot, your system will pair the folders, and changes in one location will show up in the other. Using my example above, any time I save something to my /home/guest/Downloads directory, it will also be saved to the Downloadsave.dat container on my flash drive, at /mnt/sdb1.

Now, for a real example of one implementation I've come up with for myself:

I want a folder on my desktop, where I can save and access files directly, without navigating through a bunch of subdirectories. I want this to be accessible for both my 'root' and 'guest' users.

I created the following directories in my /porteus/rootcopy file:

/home/guest/Desktop/magic
/root/Desktop/magic

This puts a folder on my desktop, within my live filesystem.

I then created a directory at the root of my flash drive and called it 'magic' as well:

mkdir /mnt/sdb1/magic

I then ran the Porteus Magic Folders tool, specifying /home/guest/Desktop/magic as my source location, and /mnt/sdb1/magic as my target directory. This created the text file at /rootcopy/etc/magic_folders which I then edited to include the second linked file for my /root/Desktop folder. This is my folders.cfg file:


/mnt/d94e44a7-235e-5f64-7521-d8202a695fde/magic /home/guest/Desktop/magic

/mnt/d94e44a7-235e-5f64-7521-d8202a695fde/magic /root/Desktop/magic

 

(note: the long string of characters in the example above represents my UUID for the partition I've referenced here as /mnt/sdb1.  Magic folder pairings use the UUID of the drive to make sure the correct folders are linked up even if you have your drive plugged into different machines or in a different order)

Upon reboot, the folders get linked together. If I log in as guest and put something in my 'magic' folder on the desktop, I can reboot as root, and access the same file that I put there earlier (as 'guest') by clicking on the 'magic' folder on root's desktop. I can also access this file from windows, by navigating to E:\magic. Note that I do not have 3 copies of these files on my flash drive. These files are only stored permanently on my pendrive, at /mnt/live/sdb1/magic, and are synced from there into the live filesystem at startup.

(yes, I know that I am not following my own advice to store my files to a .dat container when using a FAT filesystem. In this case, I am only storing documents and not system configuration files.)

This only begins to demonstrate the flexibility of the magic folders system--I'd love for anyone else to post examples of how they are using them.

Thanks, and enjoy!