Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
I am not a very good scriptor - I can fuddle my way thru most of it but I am not sure how to even start what I am after now....
Little background:
I have a external USB/Firewire Seagate 100g portable hard drive formatted NTFS.
Via my laptop (always with me) at work etc I am in the process of "archiving" my DVD collection.
On the Seagate drive I have a folder with a specific layout etc identical to what is on my DNS box for layout etc.
I have the usb-storage.ko and ntfs.ko modues on the DNS box. Fun_plug system has been modified the insmod them so they are loaded etc.
What I am after is
1. Via cron like every 5 min or so, check to see if the seagate drive is there
2. If yes - mount it to a specific location
2b. copy (cant move because NTFS is read only) the contents of my archive dir on the seagate drive to the archive dir on the DNS box
3. When finished umount the drive
I know how to do the copying etc - but am not sure how to look if /dev/sdb5 (why 5 I have no clue....) is active and attached....
Anyone point me in the right direction?
Thanks
Myk
Last edited by mykroft (2007-05-18 08:46:35)
Offline
mykroft wrote:
I know how to do the copying etc - but am not sure how to look if /dev/sdb5 (why 5 I have no clue....) is active and attached....
There's "/proc/partitions" which contains a list of all available disk partitions. My DNS shows this:
/ # cat /proc/partitions major minor #blocks name 7 0 5120 loop0 31 0 64 mtdblock0 31 1 64 mtdblock1 31 2 1536 mtdblock2 31 3 6336 mtdblock3 31 4 192 mtdblock4 8 0 488386584 sda 8 1 530113 sda1 8 2 487853887 sda2 8 16 488386584 sdb 8 17 530113 sdb1 8 18 487853887 sdb2
sda and sdb are the disks, mtd is the flash, loop is for mounting files as disks.
When I plug in a usb stick, contents change. New entries for the usb stick appear:
8 32 128000 sdc 8 33 127984 sdc1
sdc is the whole usb stick, sdc1 is the first partition on it. So, to detect whether your external drive is connected, you can do:
grep sdc /proc/partitions 1>/dev/null 2>/dev/null if [ $? -eq 0 ]; then mount ... rsync / cp / tar / .... umount .... fi
Offline
mykroft wrote:
/dev/sdb5 (why 5 I have no clue....)
1..4 are primary partitions, 5 is the first logical/extended partition.
Do you have only a single drive in your DNS? I think that's why it's sdb (and not sdc like here).
Offline
fonz wrote:
mykroft wrote:
/dev/sdb5 (why 5 I have no clue....)
1..4 are primary partitions, 5 is the first logical/extended partition.
Do you have only a single drive in your DNS? I think that's why it's sdb (and not sdc like here).
Ya I only have a signle drive at the moment until the 2nd one shows up.
Will just make it a var and export it in the fun_plug file so when I get a 2nd drive I can just edit the var and dont have to change the script or crontab entry.
I knew it had to be easy but I was just not sure how to check for it.
Thanks!
Offline
This is what I got so far
#!/bin/sh DRIVE_DEVICE=sdb DRIVE_PART=5 MOUNT_FLAGS="-t ntfs" MOUNT_OPTS="" MOUNT_DEST=${VOL1}/SG_HD SYNC_SOURCE=${VOL1}/SG_HD/Ripped SYNC_DEST=${VOL1}/share OWNER=mykroft.Admin PERMS=777 TESTMODE="-n" ## -n will only display what rsync wants to do otherwise leave blank grep ${DRIVE_DEVICE} /proc/partitions 1>/dev/null 2>/dev/null if [ $? -eq 0 ]; then echo "USB Drive Exists, Mounting & Syncing files..." >> ${LOGFILE} date >> ${LOGFILE} ## S_TIME=date Need to track Start Time echo "mount ${MOUNT_FLAGS} ${MOUNT_OPTS} /dev/${DRIVE_DEVICE}${DRIVE_PART} ${MOUNT_DEST}" >> ${LOGFILE} mount ${MOUNT_FLAGS} ${MOUNT_OPTS} /dev/${DRIVE_DEVICE}${DRIVE_PART} ${MOUNT_DEST} echo "rsync -v -r ${TESTMODE} ${SYNC_SOURCE}/ ${SYNC_DEST}/ >> ${LOGFILE}" >> ${LOGFILE} rsync -v -r ${TESTMODE} ${SYNC_SOURCE}/ ${SYNC_DEST}/ >> ${LOGFILE} echo "Drive Unmounted, Starting Cleanup..." >> ${LOGFILE} umount ${MOUNT_DEST} echo "Setting Owner/Group (${OWNER}) On Files" >> ${LOGFILE} chown -R ${OWNER} ${SYNC_DEST} echo "Setting Permissions (${PERMS}) On Files" >> ${LOGFILE} chmod -R ${PERMS} ${SYNC_DEST} date >> ${LOGFILE} ## E_TIME=date Need To Track End Time ## echo "Process Start ${S_TIME}, End {$E_TIME}, Length !Figure this out yet!" >> ${LOGFILE} fi
I want to track the start and ending time and display in the log file how long it took, but I am at a loss on how to do that....
Otherwise do you see anything that might be a issue or a better way to any part of it better?
Thanks
Myk
Last edited by mykroft (2007-05-18 22:45:16)
Offline
Anyone know how to save a start and end time/date variable and then calc diff between them? Have never tried to do that and am not sure what command busybox supports if any to start with - have gone thru busybox docs online twice, all i can find is date command....
Thanks
Myk
Offline
unix time is seconds since 1970/01/01. before you start, save unix time before and after your copy.
t1=$(date '+%s') ... t2=$(date '+%s') let T=$t2-$t1
$T now contains the elapsed time in second. you only need to find out how print this nicely...
Offline
Thank you.....
Offline
I know this is a really old post but i am new to a DNS323,
I have read lots and i'm almost there but when i connect my usb drive after installing the usb-storage.ko , it is not properly detected, in 'dmesg' the last line says sxuptp: registered the new interface dev-001/003/0, but if i try to mount it i get "failed: no such device or sddress" and the results of "cat /proc/partitions" does not indicate any third disk (I run 2 internal drives) as indicated in post #2 and displayed below.
Please help - I've been at this for days and no luck. thanks in advanced
As quoted in post #2 above
"When I plug in a usb stick, contents change. New entries for the usb stick appear:
Code:
8 32 128000 sdc
8 33 127984 sdc1
Last edited by Okadz (2010-05-28 17:22:07)
Offline