Regras para hd externo com udev
Estou tentando automatizar um script de backup aqui na empresa utilizando regras do udev... preciso executar um script ao usuario conectar e outro ao remover o hd externo. Fiz o seguinte: kasv021:/home/fernando# cat /etc/udev/backupmovel.rules ACTION=="remove", ATTRS{product}=="Iomega HDD USB 2.0 Drive", RUN +="/home/fernando/remove.sh" ACTION=="add", ATTRS{manufacturer}=="Iomega", KERNEL=="sd*", NAME="%k", SYMLINK="iomega" RUN+="/home/fernando/backupmovel.sh" E um link simbolico para o arquivo /etc/udev/backupmovel.rules já que a regras sao lidas em /etc/udev/rules.d pelo daemon. lrwxrwxrwx 1 root root 34 2008-01-17 11:03 /etc/udev/rules.d/001_bkpmovel.rules -> /etc/udev/backupmovel.rules Quando coloco o hd externo na porta usbo script /home/fernando/backupmovel.sh é executado (neste teste que estou fazendo ele é simples, somente cria um diretorio em meu diretorio home) com sucesso. Mas já na remoção do hd externo o script /home/fernando/remove.sh não é executado, pois deveria ser criada uma pasta chamada "removidobackup" em /home/fernando e isto nao acontece. Alguem sabe o que posso estar fazendo de errado? Será que não está conflitando com alguma regra do udev da distro debian? Abaixo segue a saida do comando udevtest é a seguinte: parse_file: reading '/etc/udev/rules.d/001_bkpmovel.rules' as rules file parse_file: reading '/etc/udev/rules.d/020_permissions.rules' as rules file parse_file: reading '/etc/udev/rules.d/025_libgphoto2.rules' as rules file parse_file: reading '/etc/udev/rules.d/025_libsane.rules' as rules file parse_file: reading '/etc/udev/rules.d/025_logitechmouse.rules' as rules file parse_file: reading '/etc/udev/rules.d/035_kino.rules' as rules file parse_file: reading '/etc/udev/rules.d/85-pcmcia.rules' as rules file parse_file: reading '/etc/udev/rules.d/libnjb.rules' as rules file parse_file: reading '/etc/udev/rules.d/udev.rules' as rules file parse_file: reading '/etc/udev/rules.d/z20_persistent-input.rules' as rules file parse_file: reading '/etc/udev/rules.d/z20_persistent.rules' as rules file parse_file: reading '/etc/udev/rules.d/z25_persistent-cd.rules' as rules file parse_file: reading '/etc/udev/rules.d/z25_persistent-net.rules' as rules file parse_file: reading '/etc/udev/rules.d/z45_persistent-net-generator.rules' as rules file parse_file: reading '/etc/udev/rules.d/z50_run.rules' as rules file parse_file: reading '/etc/udev/rules.d/z55_hotplug.rules' as rules file parse_file: reading '/etc/udev/rules.d/z60_hdparm.rules' as rules file parse_file: reading '/etc/udev/rules.d/z60_xserver-xorg-input-wacom.rules' as rules file parse_file: reading '/etc/udev/rules.d/z75_cd-aliases-generator.rules' as rules file parse_file: reading '/etc/udev/rules.d/z99_hal.rules' as rules file This program is for debugging only, it does not create any node, or run any program specified by a RUN key. It may show incorrect results, if rules match against subsystem specfic kernel event variables. main: looking at device '/block/sdb' from subsystem 'block' udev_rules_get_name: reset symlink list udev_rules_get_name: add symlink 'iomega' udev_rules_get_name: rule applied, 'sdb' becomes 'sdb' run_program: 'usb_id -x' run_program: '/lib/udev/usb_id' (stdout) 'ID_VENDOR=ST332082' run_program: '/lib/udev/usb_id' (stdout) 'ID_MODEL=0A' run_program: '/lib/udev/usb_id' (stdout) 'ID_REVISION=' run_program: '/lib/udev/usb_id' (stdout) 'ID_SERIAL=ST332082_0A_DEF10C88A98F' run_program: '/lib/udev/usb_id' (stdout) 'ID_TYPE=disk' run_program: '/lib/udev/usb_id' (stdout) 'ID_BUS=usb' run_program: '/lib/udev/usb_id' returned with status 0 run_program: 'edd_id --export /dev/.tmp-8-16' run_program: '/lib/udev/edd_id' (stderr) 'no kernel EDD support' run_program: '/lib/udev/edd_id' returned with status 2 run_program: 'path_id /block/sdb' run_program: '/lib/udev/path_id' (stdout) 'ID_PATH=pci-:00:13.5-usb-0:1:1.0-scsi-0:0:0:0' run_program: '/lib/udev/path_id' returned with status 0 udev_rules_get_name: add symlink 'disk/by-id/usb-ST332082_0A_DEF10C88A98F' udev_rules_get_name: add symlink 'disk/by-path/pci-:00:13.5-usb-0:1:1.0-scsi-0:0:0:0' run_program: 'vol_id --export /dev/.tmp-8-16' run_program: '/lib/udev/vol_id' (stderr) '/dev/.tmp-8-16: unknown volume type' run_program: '/lib/udev/vol_id' returned with status 4 udev_device_event: device '/block/sdb' already in database, validate currently present symlinks udev_node_add: creating device node '/dev/sdb', major = '8', minor = '16', mode = '0660', uid = '0', gid = '25' udev_node_add: creating symlink '/dev/iomega' to 'sdb' udev_node_add: creating symlink '/dev/disk/by-id/usb-ST332082_0A_DEF10C88A98F' to '../../sdb' udev_node_add: creating symlink '/dev/disk/by-path/pci-:00:13.5-usb-0:1:1.0-scsi-0:0:0:0' to '../../sdb' main: run: '/home/fernando/backupmovel.sh' main: run: 'socket:/org/kernel/udev/monitor' main: run: 'socket:/org/freedesktop/hal/udev_event' Se alguem tiver alguma dica eu agradeço Fernando Mariano.
Re: Regras para hd externo com udev
fernando, do jeito que voce esta fazendo não lhe incomoda ? E quando voce for plugar o disco apenas para ver o seu backup como voce optaria para não realizar o backup naquele instante ? Tenho varios scripts para backup usando as novas instruções do UDEV, especialmente usando o UUID como referencia para não misturar backups de propositos diferentes numa mesma unidade de backup e tem funcionado perfeitamente para mim. Com o perdão, achei seu modelo tão automatizado que é complicado de gerenciar e implementar. Onde "backup" requer alguma interatividade humana para acompanhar que realmente não haja falhas na unidade. Tenho discos IDE ligados a case USBs usados para backup e é incrivel como eles são passiveis de falhas, mesmo com scripts automatizados para gerenciarem os backups (programação de horario, impedir discos errados, etc...), invariavelmente é necessário inserir o disco apenas para limpa-los períodicamente e fazer fsck e do jeito que estou imaginando voce inseriria o disco e um script já envolveria o backup. Sei que não é agradável, não respondí o seu questionamento, mas gostaria de saber porque resolver um problema com tanta personalização nos scripts UDEV quando é mais simples e fácil criar uma interface "fazer backup (s/n)?". []'s e sucesso. Em Thu, 17 Jan 2008 11:39:18 -200, Fernando Faria Mariano<[EMAIL PROTECTED]> escreveu: > > Estou tentando automatizar um script de backup aqui na empresa utilizando > regras do udev... preciso executar um script ao usuario conectar e outro ao > remover o hd externo. > > Fiz o seguinte: > kasv021:/home/fernando# cat /etc/udev/backupmovel.rules > ACTION=="remove", ATTRS{product}=="Iomega HDD USB 2.0 Drive", > RUN+="/home/fernando/remove.sh" > > ACTION=="add", ATTRS{manufacturer}=="Iomega", KERNEL=="sd*", NAME="%k", > SYMLINK="iomega" RUN+="/home/fernando/backupmovel.sh" > > > E um link simbolico para o arquivo /etc/udev/backupmovel.rules já que a > regras sao lidas em /etc/udev/rules.d pelo daemon. > lrwxrwxrwx 1 root root 34 2008-01-17 11:03 > /etc/udev/rules.d/001_bkpmovel.rules -> > /etc/udev/backupmovel.rules > > Quando coloco o hd externo na porta usbo script > /home/fernando/backupmovel.sh é executado (neste teste que estou fazendo ele > é simples, somente cria um diretorio em meu diretorio home) com sucesso. > > Mas já na remoção do hd externo o script /home/fernando/remove.sh não é > executado, pois deveria ser criada uma pasta chamada "removidobackup" em > /home/fernando e isto nao acontece. > > > > Alguem sabe o que posso estar fazendo de errado? Será que não está > conflitando com alguma regra do udev da distro debian? > > Abaixo segue a saida do comando udevtest é a seguinte: > > parse_file: reading '/etc/udev/rules.d/001_bkpmovel.rules' > as rules file > parse_file: reading > '/etc/udev/rules.d/020_permissions.rules' as rules file > parse_file: reading > '/etc/udev/rules.d/025_libgphoto2.rules' as rules file > parse_file: reading '/etc/udev/rules.d/025_libsane.rules' > as rules file > parse_file: reading > '/etc/udev/rules.d/025_logitechmouse.rules' as rules file > parse_file: reading '/etc/udev/rules.d/035_kino.rules' as > rules file > parse_file: reading '/etc/udev/rules.d/85-pcmcia.rules' as rules file > parse_file: reading '/etc/udev/rules.d/libnjb.rules' as > rules file > parse_file: reading '/etc/udev/rules.d/udev.rules' as rules file > parse_file: reading > '/etc/udev/rules.d/z20_persistent-input.rules' as rules > file > parse_file: reading > '/etc/udev/rules.d/z20_persistent.rules' as rules file > parse_file: reading > '/etc/udev/rules.d/z25_persistent-cd.rules' as rules file > parse_file: reading > '/etc/udev/rules.d/z25_persistent-net.rules' as rules file > parse_file: reading > '/etc/udev/rules.d/z45_persistent-net-generator.rules' as > rules file > parse_file: reading '/etc/udev/rules.d/z50_run.rules' as > rules file > parse_file: reading '/etc/udev/rules.d/z55_hotplug.rules' > as rules file > parse_file: reading '/etc/udev/rules.d/z60_hdparm.rules' > as rules file > parse_file: reading '/etc/udev/rules.d/z60_xserver-xorg-input-wacom.rules' > as rules file > parse_file: reading '/etc/udev/rules.d/z75_cd-aliases-generator.rules' as > rules file > parse_file: reading '/etc/udev/rules.d/z99_hal.rules' as > rules file > This program is for debugging only, it does not create any node, > or run any program specified by a RUN key. It may show incorrect results, > if rules match against subsystem specfic kernel event variables. > > main: looking at device '/block/sdb' from subsystem 'block' > udev_rules_get_name: reset symlink list > udev_rules_get_name: add symlink 'iomega' > udev_rules_get_name: rule applied, 'sdb' becomes 'sdb' > run_program: 'usb_id -x' > run_program: '/lib/udev/usb_id' (stdout) 'ID_VENDOR=ST332082' > run_program: '/lib/udev/usb_id' (stdout) 'ID_MODEL=0A' > run_program: '/lib/udev/usb_id' (stdout) 'ID_REVISION=' > run_program: '/lib/udev/usb_id' (stdout) > 'ID_SERIAL=ST3