![]() |
![]() |
![]() |
![]() |
![]() |
Contents |
In ZorOS v.3.8 is now implemented an SSH server, so we can build a remote disk using ZorOS live filesystem. In addition the system, at init (rc.S), can search and execute a custom script in all disks (also USB stick), so to implement new functions. The name of custom script is passed with append="CUSTOMZ=path/scriptname ..." in lilo.conf.
In this tutorial we will use the remote disk as local resource, mapped in /etc/fstab.
It is necessary a minimal PC and, obvious, a hard disk (may be also an USB stick). I've build the system using a low power consuption thin client and an external 750GB USB hard disk.
#!/bin/sh PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin ifconfig eth0 192.168.0.123 #Put here the IP of your shared disk server . /etc/profile echoc "Exec CUSTOMZ script ..." red ## Remount /customz read-write # mount -w -v -n -o remount /customz cp -Rpdf /customz/CustomZ/etc/* /etc/ cp -Rpdf /customz/CustomZ/var/* /var/ cp -pdf /customz/CustomZ/CustomZ.2 /bin /bin/CustomZ.2 &
CustomZ/CustomZ.2 (example with 3 users: john, mary and peter)
#!/bin/sh PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin . /etc/profile echoc "Exec CUSTOMZ.2 script ..." yellow sleep 2 CUSTOMZ_DEV=`mount | grep /customz | cut -d" " -f1` if [ "a$CUSTOMZ_DEV" != "a" ] ; then # Remount /customz read-write Ext2 umount /customz mount -t ext2 -w -v $CUSTOMZ_DEV /customz else echoc "ERROR: /customz NOT mounted" red fi if [ ! -d /customz/home ] ; then mkdir -p /customz/home/{john,mary,peter,public} chmod 700 /customz/home/{john,mary,peter} chown john.john /customz/home/john chown mary.mary /customz/home/mary chown peter.peter /customz/home/peter chmod 4777 /customz/home/public fi cd / ln -s /customz/home home /etc/rc.d/rc.sshd start crond -L /var/log/crond.log
CustomZ/var/spool/cron/crontabs/root
00 * * * * /var/spool/cron/crontabs/bin/cron.minutes.sh 15 * * * * /var/spool/cron/crontabs/bin/cron.minutes.sh 30 * * * * /var/spool/cron/crontabs/bin/cron.minutes.sh 45 * * * * /var/spool/cron/crontabs/bin/cron.minutes.sh 01 * * * * /var/spool/cron/crontabs/bin/cron.hourly.sh 02 4 * * * /var/spool/cron/crontabs/bin/cron.daily.sh 22 4 * * 0 /var/spool/cron/crontabs/bin/cron.weekly.sh 42 4 1 * * /var/spool/cron/crontabs/bin/cron.monthly.sh
CustomZ/var/spool/cron/crontabs/bin/cron.minutes.sh
#!/bin/sh # Cron minutes PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin CUSTOMZ_BUSY=`lsof | grep /customz` if [ "a$CUSTOMZ_BUSY" = "a" ] ; then CUSTOMZ_DEV=`mount | grep /customz | cut -d" " -f1` sdparm --command=stop $CUSTOMZ_DEV fi
Download CustomZ tree (compressed), used this example File:CustomZ-sshfs-disk.tar.gz
Uncompress at root of your remote disk filesystem. To complete server installation you must copy client files: passwd, group and shadow to server /etc/
Download ISO image of ZorOS live tools, mount ISO as loop file, copy kernel and initrd, install Lilo.
An example referred to an external HD, mapped as /dev/sdb, and a boot partition as /dev/sdb2:
Copying files
mount /dev/sdb2 /mnt/sdb2 mkdir CD mount zoros-4.0-xx.iso CD -o loop cp CD/isolinux/linuz /mnt/sdb2/ cp CD/isolinux/zramfs.igz /mnt/sdb2/
You can install ZorOS inside an existing Linux installation. If you proceed with a new installation edit /mnt/sdb2/etc/lilo.conf (In new installation you must create also /etc /boot and /dev):
# generated by zoros # # Start LILO global section boot = /dev/sdb map=/map #message=/message #message=/graphical compact prompt large-memory timeout = 50 vga = 788 # End LILO global section # Linux bootable partition config begins image = /linuz label = English initrd=/ramusb.igz append = "TOOLSLANG=1 CUSTOMZ=CustomZ/CustomZ apm=off" # Linux bootable partition config ends
Install
lilo -r /dev/sdb2
Note: you don't need a root entry, ZorOS, at init,will search /CustomZ/CustomZ file in all disks.
As project page explains, sshfs is very easy to set up: server side there's nothing to do, and client side, mounting the filesystem is as easy as logging into the server with ssh.
Get and install sshfs from: fuse.sourceforge.net
To access remote disk without need to type a password, we use a user ssh key. Here is how to do:
create key
john@darkstar:~$ ssh-keygen -t rsa
copy key to remote system
john@darkstar:~$ scp .ssh/id_rsa.pub john@192.168.0.123:/home/john/.ssh/authorized_keys
Note: replace 192.168.0.123 with your remote disk IP
Append to /etc/rc.d/rc.local
mkdir -p /mnt/sshNET chmod 777 /mnt/sshNET echo "sshfs#192.168.0.123:/home /mnt/sshNET fuse user,noauto 0 0" >> /etc/fstab #replace 192.168.0.123 with your IP
This is an example to create a mount/umount icon in your desktop (tested in KDE3)
/home/username/Desktop/SSHFSdisk.desktop
#/bin/sh # zeta_sshNET - mount/umount sshfs user disk # Copyleft Fabio Zorba - 2010 PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin ICON_ADD="_add" ICON_REMOVE="_remove" for i in "s" "c" "v" do ICON_ADD=$i$ICON_ADD ICON_REMOVE=$i$ICON_REMOVE done if [ ! -d /mnt/sshNET ]; then kdialog --sorry "Mountpoint /mnt/sshNET not exist" exit fi sshNET_mounted=`mount | grep /mnt/sshNET` if [ "a$sshNET_mounted" = "a" ]; then MOUNT_ERRORS=`mount /mnt/sshNET 2>&1` if [ "a$MOUNT_ERRORS" != "a" ]; then kdialog --sorry "$MOUNT_ERRORS" TMPFILE=`echo $(tempfile -m 755)` sed "s/Icon=$ICON_REMOVE/Icon=$ICON_ADD/g" $HOME/Desktop/SSHFSdisk.desktop > $TMPFILE mv -f $TMPFILE $HOME/Desktop/SSHFSdisk.desktop exit fi TMPFILE=`echo $(tempfile -m 755)` sed "s/Icon=$ICON_ADD/Icon=$ICON_REMOVE/g" $HOME/Desktop/SSHFSdisk.desktop > $TMPFILE mv -f $TMPFILE $HOME/Desktop/SSHFSdisk.desktop konqueror /mnt/sshNET & else UMOUNT_MSG=`fusermount -u /mnt/sshNET 2>&1` if [ "a$UMOUNT_MSG" != "a" ]; then kdialog --sorry "$UMOUNT_MSG" exit else TMPFILE=`echo $(tempfile -m 755)` sed "s/Icon=$ICON_REMOVE/Icon=$ICON_ADD/g" $HOME/Desktop/SSHFSdisk.desktop > $TMPFILE mv -f $TMPFILE $HOME/Desktop/SSHFSdisk.desktop fi fi exit [Desktop Entry] Comment= Comment[it]= Encoding=UTF-8 Exec='$HOME/Desktop/SSHFSdisk.desktop' GenericName=Mount or Umount remote SSHFS disk GenericName[it]=Mount or Umount remote SSHFS disk Icon=vcs_add MimeType= Name=SSHFSdisk Name[it]=SSHFSdisk Path= StartupNotify=false Terminal=false TerminalOptions= Type=Application X-DCOP-ServiceType=none X-KDE-SubstituteUID=false X-KDE-Username=