Koozali.org formerly Contribs.org

USB external Hard disk to ibay

USB external Hard disk to ibay
« on: February 28, 2008, 01:40:52 AM »
Hi, there as lots of people here in the forum I need to plug an external USB hard disk to a ibay so my users can store lots of data there.
Sa as your recommendations, I dig into the forum and found so many advices to do it, but all of them failed. The most closer one was this

Create ibay <ibayname>
Mount usb disk to /media/<usbdisk>
ln -s /media/<usbdisk> /home/e-smith/files/ibays/<ibayname>/html/<linkdir>
chown -RL admin:shared /home/e-smith/files/ibays/<ibayname>/html (or chown -R admin:shared /media/<usbdisk>)
db accounts setprop <ibayname> FollowSymLinks enabled
signal-event ibay-modify <ibayname>
/etc/init.d/httpd graceful
access external disk at http://<servername>/<ibayname>/<linkdir>[/list:o]

Every works, I can reach the Ibay I can access the hard disk, but just in "read only mode", when  I trie to apply the  4 line from above:

chown -RL admin:shared /home/e-smith/files/ibays/<ibayname>/html (or chown -R admin:shared /media/<usbdisk>)

it tells me... "the operation can not be performed...".

then I wen to check the owner of the symlink and it is root:root, and chwon do not change it to admin. Of course when I access the share with the admin or whatever user I will never be able to write to the disk.

So how can I change the owner of that folder to admin:share? that is the only thing I need.

By the way I already format the hard disk .

Re: USB external Hard disk to ibay
« Reply #1 on: February 28, 2008, 06:44:14 AM »
I found that using chown -h owner:group [directory] will change the permissions but still can not write to the disk

Offline raem

  • *
  • 3,972
Re: USB external Hard disk to ibay
« Reply #2 on: February 28, 2008, 07:00:02 AM »
pablitobs

Please realise there is a lot of valuable information in the wiki (in addition to the manuals), so look there first for answers.
If you look at all the Howtos (which is linked at the top of these forums)
http://wiki.contribs.org/Category:Howto
you will see
http://wiki.contribs.org/USBDisks

Also see the FAQ (which is also linked at top of forums)
http://wiki.contribs.org/SME_Server:Documentation:FAQ

...

Re: USB external Hard disk to ibay
« Reply #3 on: February 29, 2008, 07:02:05 PM »
pablitobs,

It's probably not a good idea to try and mount a removable disk on a perminent file system.

What I do is let users store stuff in an Ibay on the file system and then sync that Ibay with a removable disk.

In fact most of my clients have a laptop drive in a casing and plug it in when they get to work and take it with them when they leave. I have a cron job which runs every 15 minutes and syncs /home/e-smith/files with the USB disk. They get an off site copy of the data including email if you run imap.

Here is the code I run :

##<START>***************************************************************
#
#!/bin/bash
#
#
#   BACKUP TO USB
#
#
 
ADMIN_EMAIL="admin"


# Ensure the device is plugged in
if [ ! -b /dev/sdd1 ]; then
        exit 1
fi

# Ensure the script isn't already running
if [ -f /var/run/backuptousbdrive.sh.pid ]; then
        PID="`cat /var/run/backuptousbdrive.sh.pid`"
        for i in `ps x | grep backuptousbdrive.sh | sed 's/^ *\([0-9]*\).*/\1/g'`; do
                if [ "$i" == "$PID" ]; then
                        exit 2
                fi
        done

fi

echo $$ > /var/run/backuptousbdrive.sh.pid &&

# Create Temp Directory for backup

mkdir -p /tmp/usbdisk &&
mount -t auto /dev/sdd1 /tmp/usbdisk &&
sync

# perform backup
###########################
#
#

mkdir  -p /tmp/usbdisk/home/e-smith/files

rsync -ar --delete-after /home/e-smith/files/ /tmp/usbdisk/home/e-smith/files 2>&1


#
#
############################

# wait a few seconds to make sure the disk is no longer being used
sleep 5

if [ "$?" == "0" ]; then
        SCRIPT_MESSAGE="Backup completed successfully."
   touch /tmp/usbdisk/timestamp
else
        SCRIPT_MESSAGE="Backup failed. To retry, please remove the drive, wait 10 seconds, and re-insert"
   echo $SCRIPT_MESSAGE | mail -s "USB BACKUP FAILED $?" $ADMIN_EMAIL
fi



umount /tmp/usbdisk
rm -rf /tmp/usbdisk

rm /var/run/backuptousbdrive.sh.pid


# END

##<END>*****************************************************************


I know it's not perfect and yes I don't get emails from the script, I get emails from cron when they pull out the drive during a sync or worse. Also it does not remove files from the USB disk, so the disk will fill up and overflow, but that's what service agreements are for :)

man sync and you can make exclude files to piss off tmp files or directories you don't want to capture.

Generally it works well for me and I show the USB disk as /dev/sdd1 in this script. Yours may differ.
« Last Edit: February 29, 2008, 07:22:21 PM by tandum »

Re: USB external Hard disk to ibay
« Reply #4 on: March 01, 2008, 12:57:57 PM »
I dont' see what the problem is with mounting a USB disk on a permanent file syste, since it's just another resource. It's the same as temporarely mounting an internal HDD for backup purposes. Just bear in mind that disconnecting it while it's being used could cause data loss, but since a USDB cable is either 1m or 2m, and the HDD will sit right next to the SME server, this shouldn't be a problem

Re: USB external Hard disk to ibay
« Reply #5 on: March 14, 2008, 04:33:12 AM »
Hi, Thaks a lot for you advice, but I already read, and read those how to's my problems is simple, I can moun the Usb disk into an ibay, I can browse th econtent but I cant write to the ibay, and I can not change the ownership. I already search into the forums, but I cant get to write into the ibay.

So, now you know I am not just asking for a quick solution, and now you know I made my homework and try to search.....could you be so kind and give any helpfull advice?


pablitobs

Please realise there is a lot of valuable information in the wiki (in addition to the manuals), so look there first for answers.
If you look at all the Howtos (which is linked at the top of these forums)
http://wiki.contribs.org/Category:Howto
you will see
http://wiki.contribs.org/USBDisks

Also see the FAQ (which is also linked at top of forums)
http://wiki.contribs.org/SME_Server:Documentation:FAQ



Re: USB external Hard disk to ibay
« Reply #6 on: March 14, 2008, 09:52:42 AM »
pablitobs,

I don't understand this line...

access external disk at http://<servername>/<ibayname>/<linkdir>[/list:o]

Are you trying to say that you want to write file to your usb disk using a Web browser?

thomasch


Re: USB external Hard disk to ibay
« Reply #7 on: March 14, 2008, 12:06:38 PM »
pablitobs,

I don't understand this line...

Are you trying to say that you want to write file to your usb disk using a Web browser?

thomasch



Ummmm, no actually that line belongs to one suggestion I found digging on the forum, that didnt work, by the way. But finally I found that if I formatted the hard disk to ext3 instead  of vfat, then SME Server allows me to do a chown and allow write access to it, so now I can browse and I can write, yeah!!!!! . But I still think it should work with the vfat, any way we now microsoft sucks and usually everything that descends from MS sucks too.

Thanks guys for your help it tooks me 3 weeks to find out the answer and the lesson I got from all this was......

Search the forums, read the howto's run out of ideas before post for help.

Thanks

Offline raem

  • *
  • 3,972
Re: USB external Hard disk to ibay
« Reply #8 on: March 14, 2008, 07:39:59 PM »
Quote
if I formatted the hard disk to ext3 instead  of vfat, then SME Server allows me to do a chown and allow write access to it, so now I can browse and I can write...

Added to Howto to make the requirement clearer.
http://wiki.contribs.org/USBDisks#Format_limitations_when_linking_disk_to_an_ibay
...

Offline _YO_

Re: USB external Hard disk to ibay
« Reply #9 on: April 10, 2011, 12:19:32 PM »
I've seen it's a quite old topic. But I've done it !
 :cool: --> Writable USB disk linked to iBay <-- :cool:

Using mount option fmask=0000,dmask=0000.

fmask (for files) and dmask (for directories) are used to "do NOT pass preset bit(s)" of attributes.
See here http://en.wikipedia.org/wiki/Fmask

By default fmask=022 and dmask=022 (seen in /proc/mounts). It means that Write bits of group and other are not set.

When in your USB mount options you precise fmask=0000,dmask=0000, you are going over this default behaviour and you can write on your USB disk from your symlink...

Format your USB in FAT 32 fs
Mount usb disk to /media/<usbdisk> using fmask=0000,dmask=0000
Create ibay <ibayname>
ln -s /media/<usbdisk> /home/e-smith/files/ibays/<ibayname>/files/<linkdir>
« Last Edit: April 10, 2011, 12:21:23 PM by _YO_ »
.YO.