Hi
habe an meinem Vdr ein Wechselplattengehäuse. Nun möchte ich gerne eine udev Regel erstellen um die Platte immer an die selbe Stelle zu mounten.
Wenn ich die Platte beim starten im Gehäuse habe wird Sie unter /dev/sdc angelegt; wenn ich die Platte erst während des Betriebe einstecke wird Sie unter /dev/sdd angelegt, was wohl daran liegt, dass ich noch nen USB Card Reader am USB Hub habe.
Benutze easyVdr (ububuntu 14.04).
Kann mir jemand hierbei helfen?
Grüße
Wolle
Anfängerfrage Udev Regel für Wechselplatten
-
-
Das wird beim einschieben der Platte angezeigt
Code
Alles anzeigeneasyvdr@easyVDR:~/script$ sudo udevadm monitor monitor will print the received events for: UDEV - the event which udev sends out after rule processing KERNEL - the kernel uevent KERNEL[6917.472575] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0 (scsi) KERNEL[6917.472632] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0 (scsi) KERNEL[6917.472655] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk) KERNEL[6917.472671] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device) KERNEL[6917.474323] add /devices/virtual/bdi/8:48 (bdi) UDEV [6917.474360] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0 (scsi) KERNEL[6917.474393] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/scsi_generic/sg4 (scsi_generic) KERNEL[6917.474415] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg) UDEV [6917.476549] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0 (scsi) UDEV [6917.479413] add /devices/virtual/bdi/8:48 (bdi) UDEV [6917.480856] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/scsi_disk/4:0:0:0 (scsi_disk) UDEV [6917.481981] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/bsg/4:0:0:0 (bsg) UDEV [6917.482454] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/scsi_generic/sg4 (scsi_generic) UDEV [6917.482718] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/scsi_device/4:0:0:0 (scsi_device) KERNEL[6917.483403] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/block/sdd (block) KERNEL[6917.483417] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/block/sdd/sdd1 (block) UDEV [6917.691733] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/block/sdd (block) UDEV [6918.566277] add /devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/block/sdd/sdd1 (block)
-
Mit "udevadm info --name=/dev/sdd --query=all" (ggf. mit "--attribute-walk" hinten dran) bekommt man auch eine schöne Übersicht über die Eigenschaften eines Gerätes. Bei USB-Platten gibt es häufig eine Seriennummer oder ein Label, das man dann für das Mounten benutzen kann.
Googlen nach "ubuntu mount usb disk udev" ergibt z.B.: http://wiki.ubuntuusers.de/udev
Da sind ein paar Beispiele, die man ausprobieren könnte. Mit dem udevadm-Kommando oben bekommst du auch die passende Seriennummer zu deiner Platte.
Lars.
-
Hi
das Problem ist ja das ich gerne alle Platten welche ich in das Sata Wechselgehäuse stecke gleich mounten will; oder muss ich für jede der einzelnen Platten welche ich verwenden will eine eigene Udev Regel erstellen (über Label oder Seriennummer)?Gibt es die Möglichkeit alles was hinter
kommt gleich zu behandeln? Blicke mit Udev irgendwie überhaupt nicht durchGrüße
Wolle -
Vielleicht hilft dir das Beispiel.
10-my-media.rulesCode
Alles anzeigen# vim:enc=utf-8:nu:ai:si:et:ts=4:sw=4:ft=udevrules: # # /etc/udev/rules.d/10-my-media-automount.rules # start at sdb to ignore the system hard drive KERNEL!="sd[b-z]*", GOTO="my_media_automount_end" ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="my_media_automount_end" # import some useful filesystem info as variables IMPORT{program}="/sbin/blkid -o udev -p %N" # get the label if present, otherwise assign one based on device/partition ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}" ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k" # create the dir in /media and symlink it to /mnt ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'" # global mount options ACTION=="add", ENV{mount_options}="relatime" # filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat) ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},gid=100,dmask=000,fmask=111,utf8" # automount ntfs filesystems using ntfs-3g driver ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options} /dev/%k '/media/%E{dir_name}'" # automount all other filesystems ACTION=="add", ENV{ID_FS_TYPE}!="ntfs", RUN+="/bin/mount -t auto -o %E{mount_options} /dev/%k '/media/%E{dir_name}'" # clean up after device removal ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'" # exit LABEL="my_media_automount_end"
-
Ich benutze für meinen Server das.
Funktioniert bestens
11-media-by-label-auto-mount.rules
KERNEL!="sd[a-z]*", GOTO="media_by_label_auto_mount_end"
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="media_by_label_auto_mount_end"# Do not mount devices already mounted somewhere else to avoid entries for all your local partitions in /media
ACTION=="add", PROGRAM=="/bin/grep -q ' /dev/%k ' /proc/self/mountinfo", GOTO="media_by_label_auto_mount_end"# Open LUKS partition if necessary
PROGRAM=="/sbin/blkid -o value -s TYPE %N", RESULT=="crypto_LUKS", ENV{crypto}="mapper/", ENV{device}="/dev/mapper/%k"
ENV{crypto}=="", ENV{device}="%N"
ACTION=="add", ENV{crypto}!="", PROGRAM=="/usr/bin/xterm -display :0.0 -e 'echo Password for /dev/%k; /sbin/cryptsetup luksOpen %N %k'"
ACTION=="add", ENV{crypto}!="", TEST!="/dev/mapper/%k", GOTO="media_by_label_auto_mount_end"# Global mount options
ACTION=="add", ENV{mount_options}="noatime"
# Filesystem-specific mount options
ACTION=="add", PROGRAM=="/sbin/blkid -o value -s TYPE %E{device}", RESULT=="vfat|ntfs", ENV{mount_options}="%E{mount_options},utf8,gid=100,umask=002"
ACTION=="add", PROGRAM=="/sbin/blkid -o value -s TYPE %E{device}", RESULT=="ext4", ENV{mount_options}="%E{mount_options},data=writeback,barrier=0,nobh,errors=remount-ro"# Get label if present, otherwise assign one
PROGRAM=="/sbin/blkid -o value -s LABEL %E{device}", ENV{dir_name}="%c"
# Use basename to correctly handle labels such as ../mnt/foo
PROGRAM=="/usr/bin/basename '%E{dir_name}'", ENV{dir_name}="%c"
ENV{dir_name}=="", ENV{dir_name}="hd-%k"# Mount the device
ACTION=="add", ENV{dir_name}!="", RUN+="/bin/mkdir -p '/media/%E{dir_name}'", RUN+="/bin/mount -o %E{mount_options} /dev/%E{crypto}%k '/media/%E{dir_name}'"# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'"
ACTION=="remove", ENV{crypto}!="", RUN+="/sbin/cryptsetup luksClose %k"
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/rmdir '/media/%E{dir_name}'"# Exit
LABEL="media_by_label_auto_mount_end" -
Mal schnell zum Hintergrund;
ich hab in meinem video0 ein Verzeichnis Wechselplatte; hier würde ich gerne jede Platte die ich in das Sata-Gehäuse stecke hin mounten, im Prinzip verwenden wie ein DVD Laufwerk nur halt größer um den Platzmangel im VDR vor zu beugen
Wenn ich davon Ausgehe das ich ja ein Attribut brauche um die Zuordnung zu bekommen müsste ja.
reichen um dann ein Scriprt aus zu führen oder lieg ich da komplett auf dem Holzweg? -
Da war ich mit meinem Beitrag wohl zu langsam;
Jetzt muss ich mir mal die geposteten rules anschauen ich glaub das von dippes ist genau sowas was ich suche; aber nie und nimmer selber hin bekommen hätte.
Vielen Dank; jetzt hab ich einen guten Ansatz um vielleicht mal ein bisschen in die Materie einzusteigen.
Grüße
Wolle
Jetzt mitmachen!
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!