Magic Folders&new way saving data, automatic swap files

Post links to your 32-bit module repos here. Repo maintainers are responsible for resolving any issues caused by their xzm's.
Post Reply
Falcony
Full of knowledge
Full of knowledge
Posts: 235
Joined: 01 Jan 2011, 12:44
Location: Russia

Magic Folders&new way saving data, automatic swap files

Post#1 by Falcony » 03 Jan 2011, 10:06

Installation

Place to slax/modules

http://falcony.googlecode.com/files/zz9 ... -0.1.3.lzm

file.

Edit /mnt/sd*/boot/slax.cfg , clear changes option

And reboot

Magic Folders

Overview

Magic folders - there is a new method of storing data that allows you to store your data and settings FIDOSlax on a USB-flash drive or hard disk partition. For this purpose, the on partition of disk should be created special catalog _slax-data/magic-folder_. After rebooting this folder will be automatically connected to you root file system and files inside this folder will be used to store and save not in the RAM on your computer but directly to the USB-flash drive or hard drive partition on your PC.


How to Use


The list of current avalaible magic folders in FIDOSlax tools, where X - a physical disk, and N - a logical partition:
/mnt/sdXN/slax-data/slax-desktop - folder for documents on your desktop. Create at any drive (if you create it on USB-flash it will allow you always have these files with yourself toughter with USB-flash FIDOSlax) directory slax-data and then subdirectory slax-desktop. Copy your files into the directory slax-desktop or create in this directory new files. After the reboot all the files and catalogs will appear on your desktop and can change them - all changes are immediately written to the device USB-flash drive or partition of HDD;
/mnt/sdXN/slax-data/slax-root - directory to store user's files settings and application's data. Create the root of any drive in the directory slax-data and subdirectory slax-root then copy into this directory any file or from root's home directory(/root) or copy of application configuration files(/root/.apps-name). For example if you copy the /root/.mozilla directory to /mnt/sda2/slax-data/slax-root/ and if you reboot FIDOSlax then application Mozilla Firefox or Thunderbird will use the saved to disk /mnt/sda2 data their own settings. You can copy your files and application settings and user application data folder to /mnt/sdXN/slax-data/slax-root on a flash drive or hard disk partition. In the case of usage of USB stick on a different computer you can run applications with different settings and data on different computers;
/mnt/sdXN/slax-data/my-documents - folder for the user's documents. Create the root of any drive in the directory slax-data, and within its subdirectory my-documents. After rebooting the directory /root/my-documents will be attached to the directory /mnt/sdXN/slax-data/my-documents;
/mnt/sdXN/slax-data/my-downloads - folder for user's downloads . For example, if you create one of the hard disk partition directory / mnt/sda2/slax-data/my-downloads, then after the restart directory /root/Downloads will be connected to /mnt/sda2/slax-data/my-downloads and then all of your downloads will be automatically saved and not lost after a reboot;
/mnt/sdXN/slax-data/slax-tmp - folder to store the partition / tmp - strongly recommended to create this folder if you use OS not periodically but as main operating system. Create a partition on your computer any file system Linux, format it. Create on this partition directory slax-data and then subdirectory slax-tmp. After the reboot / tmp partitions will be attached to the directory slax-tmp;
/mnt/sdXN/slax-data/slax-software - folder storage modules of software. Create the root of any drive in the directory slax-data and subdirectory slax-software. After rebooting the desktop folder FIDOSlax-Software appear and you can store lzm modules which you need not constantly but from time to time. If you create a folder slax-software the modules that you save there, you will be available for download on any computer;
/mnt/sdXN/slax-data/slax-etc - directory to store configuration of Linux /etc. Create at any drive directory slax-data and inside subdirectory slax-etc then edit any file in the directory /etc and copy this file to /mnt/sdXN/slax-data/slax-etc. After rebooting FIDOSlax find this file and will use this file. You can copy the modified files from the /etc folder /mnt/sdXN/slax-data/slax-etc on a flash drive or hard disk partition. In the latter case, booting from a USB drive on different computers, you will have different configuration profiles;
/mnt/sdXN/slax-data/slax-rc.d - folder for scripts of starting services. Create in root of any drive directory slax-data and subdirectory slax-rc.d, then edit any rc-script in the directory /etc/rc.d copy it to /mnt /sdXN/slax-data /slax-rc.d. After rebooting FIDOSlax find this script and run the service using this script. You can copy the modified script from the directory /etc/rc.d directory to /mnt/sdXN/slax-data/slax-rc.d on a flash drive or hard disk partition. If you are booting from a USB drive on different computers you can run different services on different computers. For example, if you use FIDOSlax on different computers and want to use different static IP-addresses for each of them then you can copy the template configuration IP /etc/rc.d/rc.nodhcp-eth0.tpl to /mnt/sdXN/slax-data/slax-rc.d/rc.nodhcp-eth0 edit it and set the IP, mask and gateway. Then repeat this process on other computers and after booting FIDOSlax with the same USB stick you will have different IP network sttings. More detail the process of network configuration considered in the paper [http://code.google.com/p/fidoslax/wiki/ ... SettingsEn "Network Configuration FIDOSlax"];
/mnt/sdXN/slax-data/slax-download - folder to download the source code of programs and for creation of new modules from sources. This folder also required for the utility of mass creation of modules _lzm_bulk-build_. Create the new partiton of any Linux file system and format it. Create a directory in the root of partiton slax-data and inside subdirectory slax-download. After restarting if you run the command slax-build, crux-build, arch-build, arch-dep or arch2lzm - slax-data/slax-download directory will be used to build new modules and for place of storeage of downloading the source code of programs;
/mnt/sdXN/slax-data/slax-outdir - folder for storage of ready lzm modules created by of slax-build, crux-build, arch-build, arch-dep or arch2lzm. This mafic folders also required for the utility of mass creation of modules _lzm_bulk-build_. Create in the root directory slax-data, but inside its subdirectory slax-outdir. After restarting if you run the command slax-build, crux-build, arch-build, arch-dep or arch2lzm this the directory will be placed slax-data/slax-outdir lzm new modules.

Saving files and directories

If you changed your distribution and you want to reboot, they do not get lost, you can use a semi-automatic command to save the file.
To save a file, go to the directory where the file is:

cd /catalog

And run:

live2root-name file


For example, command execution commands

cd /etc/
live2root hosts

make to your changes persistent and file /etc/hosts will be copied to the directory slax/rootcopy/etc/, and reboot the system will use it.

Image


Fig. 1 Saving a file using the command live2root

To preserve the directory and all files that are there (but not subdirectories), navigate to the directory where the files you want to save:

And run lived2root without arguments:

lived2root


To save the entire directory (all files that it contains subfolders and files), navigate to the directory where you want to save:


cd / catalog


And run livedirs2root without parameters:


livedirs2root


Image

Fig. 2 Saving the directory with the command livedir2root

Automatic Swap files activation

If the computer have only NTFS partitions it is recommended to create a special virtual memory file at one of the partitions on your hard disk. This can be done with the command mkfileswap. For example,

mkfileswap / mnt/sda2/swap 1024 Mb

This will create a swap file to 1024 Mb

(or /mnt/ sdaN/swap, where N - number of hard disk partition on which you want to create a virtual memory file).

After a your system automatically find this file and activate it as an additional virtual memory;

Additional information for reading

http://code.google.com/p/fidoslax/wiki/MainPageEnglish
http://code.google.com/p/fidoslax/wiki/NetworkSettingEn

User avatar
fanthom
Site Admin
Site Admin
Posts: 4616
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: Magic Folders&new way saving data, automatic swap files

Post#2 by fanthom » 04 Jan 2011, 05:06

Another great contribution Falcony :)
I'm really inspired by your 'Magic Folders' feature - although gonna do it in a little bit different way:
Script launched from Kmenu (lxde menu) will ask the user about each: destination directory for storing changes and targed directory
example: /mnt/sdb2/saved_changes/root/.mozilla and /root/.mozilla
Users preferences will be stored in some file inside /rootcopy dir (they cant be lost after reboot)
rc.S script will be mounting specified dir to specified place:
Example:
"mount -o bind /mnt/sdb2/saved_changes/root/.mozilla /root/.mozilla"
will also think about possibility for managing of 'paired' folders by the users.

To be implemented in v1.0 :D

Thanks!
Please add [Solved] to your thread title if the solution was found.

Falcony
Full of knowledge
Full of knowledge
Posts: 235
Joined: 01 Jan 2011, 12:44
Location: Russia

Re: Magic Folders&new way saving data, automatic swap files

Post#3 by Falcony » 04 Jan 2011, 08:57

although gonna do it in a little bit different way
No problem, do it the best way of your thinking L)
Please for avoiding mix up do not give your scripts the same names as mine
"mount -o bind /mnt/sdb2/saved_changes/root/.mozilla /root/.mozilla"
will also think about possibility for managing of 'paired' folders by the users.
In my understang better if this mount command will automatically starts for each user data found at any partitons /mnt/sd*/saved_changes/

BTW, I think reasonable to have system wide settings except /etc/, /etc.rc.d
For example for log files at /var/log - if boot script found some log files at /mnt/sdb2/saved_changes/var/log the it mount it to /var/log

User avatar
fanthom
Site Admin
Site Admin
Posts: 4616
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: Magic Folders&new way saving data, automatic swap files

Post#4 by fanthom » 04 Jan 2011, 09:47

Falcony wrote:In my understang better if this mount command will automatically starts for each user data found at any partitons /mnt/sd*/saved_changes/
my solution is more flexible as users can 'pair folders' from all available devices. please have a look, this is rc.S - lines added after '# Enable swapping':

Code: Select all

# Enable swapping.
swapon -a 2> /dev/null &

# Bind magic_folders
if [ -e /etc/magic_folders/folders.cfg ]; then
  echo "Binding magic_folders..."
  num=`wc -l /etc/magic_folders/folders.cfg | cut -d " " -f1`; x=1
  while [ $x -le $num ]; do
    line=`awk NR==$x /etc/magic_folders/folders.cfg`
    echo "mount -o bind $line"
    mount -o bind $line
    x=$(($x+1))
  done
fi
and this is script for generating all necessary files/dirs:
http://pastebin.com/KLqvwEp6
Please try it if you want.
Please add [Solved] to your thread title if the solution was found.

Falcony
Full of knowledge
Full of knowledge
Posts: 235
Joined: 01 Jan 2011, 12:44
Location: Russia

Re: Magic Folders&new way saving data, automatic swap files

Post#5 by Falcony » 04 Jan 2011, 10:18

Cool! Will try and will use at FIDOSlax netxt version.
Your solution more flexible L)

And what about automatic swap files activation?
Noob user do not like move or resize of HDD partion
So it is quite good if your checks for exist of specilal swap files at any partiion(select uniq name) and activate it at boot stage

I done it by this way

/etc/rc.d# cat rc.swap

Code: Select all

#!/bin/sh
# Script for swap file activate
# if swap file exist on any mounted partition
# it will be activate automatically

for i in /mnt/*/swap; do

if [ -e $i ]
  then
   echo "Found FIDOSlax "$i" swap file."
   swapon $i
   echo "FIDOSlax "$i" swap file activated."
  fi
done
and for creation of swap files this code

cat /usr/sbin/mkfileswap

Code: Select all

#!/bin/bash
# Create an empty file in /mnt and activate it as a swap
# Author: Tomas M <http://www.slax.org>
#

# only root can run this
if [ "0$UID" -ne 0 ]; then
   echo "Only root can run $(basename $0)"; exit 1
fi

SWAPFILE=$(readlink -f "$1")
SWAPSIZE="$2"

if [ $(($SWAPSIZE)) -lt 1 ]; then
   echo >&2
   echo "mkfileswap - create swap as a file in writable filesystem" >&2
   echo "usage: $0 [/mnt/partition/new_name.swap] [size MB]" >&2
   echo >&2
   exit 1
fi

if [ -d "$SWAPFILE" ]; then
   echo "$SWAPFILE is a directory, use $SWAPFILE/slax.swp instead" >&2
   exit 2
fi

if [ "$(echo "$SWAPFILE" | egrep "^/mnt")" = "" ]; then
   echo "you must use path in /mnt, I am sorry" >&2
   exit 3
fi

echo "Creating empty file $SWAPFILE, size $SWAPSIZE MB"
dd if=/dev/zero of=$SWAPFILE count=$SWAPSIZE bs=1M 2>/dev/null
if [ "$?" -ne 0 ]; then exit 4; fi

echo "Formating the file with Linux Swap filesystem..."
mkswap $SWAPFILE >/dev/null
if [ "$?" -ne 0 ]; then exit 5; fi

echo "Activating swap..."
swapon $SWAPFILE
if [ "$?" -ne 0 ]; then exit 6; fi




User avatar
fanthom
Site Admin
Site Admin
Posts: 4616
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: Magic Folders&new way saving data, automatic swap files

Post#6 by fanthom » 04 Jan 2011, 15:42

'mkfileswap' utility is already included in porteus. i'm not sure if activation of swap files automatically during boot time is a good idea. Users should know what is going on with their systems. I will rather add an extra Q/A to the FAQ to explain how to create and use swap files. Thanks for mentioning it :)
Please add [Solved] to your thread title if the solution was found.

Falcony
Full of knowledge
Full of knowledge
Posts: 235
Joined: 01 Jan 2011, 12:44
Location: Russia

Re: Magic Folders&new way saving data, automatic swap files

Post#7 by Falcony » 04 Jan 2011, 21:48

As you think better L)

Post Reply