Run program when second hdd gets mounted

Ask questions about Arch Linux ARM. Please search before making a new topic.

Run program when second hdd gets mounted

Postby dinjo » Sun Dec 16, 2012 11:51 am

Is there a way I can get a set of programs to execute only when I attach my second hdd to pogoplug

Reason being pogo cannot boot when 2 drives are attached so I boot pogo attach second hdd which has transmission samba and minidlna data so these programs should be started only when second hdd is attached
dinjo
 
Posts: 258
Joined: Mon Nov 28, 2011 5:59 am

Re: Run program when second hdd gets mounted

Postby xenoxaos » Sun Dec 16, 2012 2:41 pm

Make a udev rule.
Arch Linux ARM exists and continues to grow through community support, please donate today!
xenoxaos
Developer
 
Posts: 323
Joined: Thu Jan 06, 2011 1:45 am

Re: Run program when second hdd gets mounted

Postby dinjo » Sun Dec 16, 2012 2:55 pm

Can you assist me how do i proceed ahead looked at below but what should be the filename ? And i should be putting the start commands in the rules file right ?

http://hackaday.com/2009/09/18/how-to-write-udev-rules/
dinjo
 
Posts: 258
Joined: Mon Nov 28, 2011 5:59 am

Re: Run program when second hdd gets mounted

Postby dinjo » Mon Dec 17, 2012 2:28 pm

I tried creating rules didn't worked

$this->bbcode_second_pass_quote('', '[')root@alarm /etc/udev/rules.d]$ more 90-media-by-label.rules
KERNEL=="sdb2",ACTION=="add", RUN+="/root/startProcess.bash > /tmp/start"


The drive gets mounted

$this->bbcode_second_pass_code('', '
[ 1609.920000] usb 1-1.3:1.0: uevent
[ 1609.930000] usb 1-1.3: uevent
[ 1609.930000] usb 1-1.3: uevent
[ 1609.930000] usb 1-1.3:1.0: uevent
[ 1614.890000] scsi 4:0:0:0: Direct-Access Seagate FreeAgent GoFlex 0148 PQ: 0 ANSI: 4
[ 1614.900000] usb-storage: device scan complete
[ 1614.900000] sd 4:0:0:0: [sdb] 976773167 512-byte logical blocks: (500 GB/465 GiB)
[ 1614.910000] sd 4:0:0:0: [sdb] Write Protect is off
[ 1614.910000] sd 4:0:0:0: [sdb] Mode Sense: 1c 00 00 00
[ 1614.910000] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[ 1614.920000] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[ 1614.930000] sdb: sdb2
[ 1615.000000] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[ 1615.000000] sd 4:0:0:0: [sdb] Attached SCSI disk
[ 1615.010000] usb 1-1.3:1.0: uevent
[ 1615.630000] kjournald starting. Commit interval 5 seconds
[ 1615.640000] EXT3 FS on sdb2, internal journal
[ 1615.640000] EXT3-fs: mounted filesystem with writeback data mode.
')
dinjo
 
Posts: 258
Joined: Mon Nov 28, 2011 5:59 am

Re: Run program when second hdd gets mounted

Postby hydro » Mon Dec 17, 2012 4:35 pm

Is /root/startProcess.bash executable? Does it contain a shebang at the beginning? I don't know if redirections work inside the RUN statement, I suggest to remove it
$this->bbcode_second_pass_code('', '
KERNEL=="sdb2", ACTION=="add", RUN+="/root/startProcess.bash"
')
and start with a very simple /root/startProcess.bash
$this->bbcode_second_pass_code('', '
#!/bin/bash
date > /tmp/start
')
Not sure if full paths to executables are required in the script, too, but It seems not. Don't forget to
$this->bbcode_second_pass_code('', '
chmod +x /root/startProcess.bash
')
Then see if /tmp/start is created.
VDR on DockStar / Pogoplug E02: http://linux.bplaced.net/
hydro
 
Posts: 210
Joined: Wed Jun 15, 2011 2:03 pm
Location: Germany

Re: Run program when second hdd gets mounted

Postby dinjo » Tue Dec 18, 2012 3:51 am

Yes the shebang is there and file is exec i added the redirection to verify it it does not work is the rules file name ok ?
dinjo
 
Posts: 258
Joined: Mon Nov 28, 2011 5:59 am

Re: Run program when second hdd gets mounted

Postby hydro » Tue Dec 18, 2012 7:22 am

Filename is okay. Works as described on DockStar. I even installed udev-automount to see if it interferes, but it doesn't. I can make udev write the date to a stick previously mounted by 11-media-by-label-auto-mount.rules.
VDR on DockStar / Pogoplug E02: http://linux.bplaced.net/
hydro
 
Posts: 210
Joined: Wed Jun 15, 2011 2:03 pm
Location: Germany

Re: Run program when second hdd gets mounted

Postby dinjo » Tue Dec 18, 2012 2:44 pm

Not sure what happened earlier it seems working perfectly fine now thanks for your help
dinjo
 
Posts: 258
Joined: Mon Nov 28, 2011 5:59 am


Return to User Questions

Who is online

Users browsing this forum: No registered users and 7 guests