Die externe Festplatte ist als ext3 formatiert
lsusb gibt folgendes aus:
Bus 004 Device 002: ID 0471:0815 Philips (or NXP) eHome Infrared Receiver
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 1267:0103 Logic3 / SpectraVideo plc G-720 Keyboard
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 003: ID 1058:1021 Western Digital Technologies, Inc.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Und nun zu meiner genauen Vorgehensweise:
1. Anmeldung per ssh am Server
2. root werden (hierfür nutze ich den Befehl "sudo su")
3. Externe Festplatte anschließen und einschalten
4. Herausfinden als welches device die Festplatte erkannt wird
Hierfür nutze ich dmesg
dmesg bringt folgendes:
[32466.390150] usb 2-1: new high speed USB device using ehci_hcd and address 3
[32466.660452] Initializing USB Mass Storage driver...
[32466.661722] scsi8 : usb-storage 2-1:1.0
[32466.662241] usbcore: registered new interface driver usb-storage
[32466.662246] USB Mass Storage support registered.
[32467.664004] scsi 8:0:0:0: Direct-Access WD Ext HDD 1021 2021 PQ: 0 ANSI: 4
[32467.665326] sd 8:0:0:0: Attached scsi generic sg2 type 0
[32467.667161] sd 8:0:0:0: [sdb] 3907024896 512-byte logical blocks: (2.00 TB/1.81 TiB)
[32467.672354] sd 8:0:0:0: [sdb] Write Protect is off
[32467.672385] sd 8:0:0:0: [sdb] Mode Sense: 17 00 10 08
[32467.672394] sd 8:0:0:0: [sdb] Assuming drive cache: write through
[32467.679246] sd 8:0:0:0: [sdb] Assuming drive cache: write through
[32467.679313] sdb: sdb1
[32467.699099] sd 8:0:0:0: [sdb] Assuming drive cache: write through
[32467.699125] sd 8:0:0:0: [sdb] Attached SCSI disk
[32469.070108] EXT3-fs: barriers not enabled
[32469.086325] kjournald starting. Commit interval 5 seconds
[32469.089467] EXT3-fs (sdb1): using internal journal
[32469.089479] EXT3-fs (sdb1): mounted filesystem with ordered data mode
Somit wird die Festplatte als sdb erkannt und die Partition auf der Festplatte als sdb1.
5. Jetzt hole ich mir detaillierte Informationen zu der USB-Festplatte.
Und zwar mit folgendem Befehl:
udevadm info -a -p $(udevadm info -q path -n /dev/sdc)
Ausgabe:
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:04.1/usb2/2-1/2-1:1.0/host8/target8:0:0/8:0:0:0/block/sdb':
KERNEL=="sdb"
SUBSYSTEM=="block"
DRIVER==""
ATTR{range}=="16"
ATTR{ext_range}=="256"
ATTR{removable}=="0"
ATTR{ro}=="0"
ATTR{size}=="3907024896"
ATTR{alignment_offset}=="0"
ATTR{discard_alignment}=="0"
ATTR{capability}=="50"
ATTR{stat}==" 174 0 1386 200 1 0 8 0 0 200 200"
ATTR{inflight}==" 0 0"
looking at parent device '/devices/pci0000:00/0000:00:04.1/usb2/2-1/2-1:1.0/host8/target8:0:0/8:0:0:0':
KERNELS=="8:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{device_blocked}=="0"
ATTRS{type}=="0"
ATTRS{scsi_level}=="3"
ATTRS{vendor}=="WD "
ATTRS{model}=="Ext HDD 1021 "
ATTRS{rev}=="2021"
ATTRS{state}=="running"
ATTRS{timeout}=="30"
ATTRS{iocounterbits}=="32"
ATTRS{iorequest_cnt}=="0xd2"
ATTRS{iodone_cnt}=="0xd2"
ATTRS{ioerr_cnt}=="0xb"
ATTRS{modalias}=="scsi:t-0x00"
ATTRS{evt_media_change}=="0"
ATTRS{dh_state}=="detached"
ATTRS{queue_depth}=="1"
ATTRS{queue_type}=="none"
ATTRS{max_sectors}=="240"
looking at parent device '/devices/pci0000:00/0000:00:04.1/usb2/2-1/2-1:1.0/host8/target8:0:0':
KERNELS=="target8:0:0"
SUBSYSTEMS=="scsi"
DRIVERS==""
looking at parent device '/devices/pci0000:00/0000:00:04.1/usb2/2-1/2-1:1.0/host8':
KERNELS=="host8"
SUBSYSTEMS=="scsi"
DRIVERS==""
looking at parent device '/devices/pci0000:00/0000:00:04.1/usb2/2-1/2-1:1.0':
KERNELS=="2-1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="usb-storage"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bNumEndpoints}=="02"
ATTRS{bInterfaceClass}=="08"
ATTRS{bInterfaceSubClass}=="06"
ATTRS{bInterfaceProtocol}=="50"
ATTRS{modalias}=="usb:v1058p1021d2021dc00dsc00dp00ic08isc06ip50"
ATTRS{supports_autosuspend}=="0"
looking at parent device '/devices/pci0000:00/0000:00:04.1/usb2/2-1':
KERNELS=="2-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{configuration}==""
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bmAttributes}=="c0"
ATTRS{bMaxPower}==" 2mA"
ATTRS{urbnum}=="667"
ATTRS{idVendor}=="1058"
ATTRS{idProduct}=="1021"
ATTRS{bcdDevice}=="2021"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumConfigurations}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{speed}=="480"
ATTRS{busnum}=="2"
ATTRS{devnum}=="3"
ATTRS{devpath}=="1"
ATTRS{version}==" 2.00"
ATTRS{maxchild}=="0"
ATTRS{quirks}=="0x0"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{authorized}=="1"
ATTRS{manufacturer}=="Western Digital"
ATTRS{product}=="Ext HDD 1021"
ATTRS{serial}=="5743415A4141323930313936"
looking at parent device '/devices/pci0000:00/0000:00:04.1/usb2':
KERNELS=="usb2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{configuration}==""
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bMaxPower}==" 0mA"
ATTRS{urbnum}=="56"
ATTRS{idVendor}=="1d6b"
ATTRS{idProduct}=="0002"
ATTRS{bcdDevice}=="0206"
ATTRS{bDeviceClass}=="09"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumConfigurations}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{speed}=="480"
ATTRS{busnum}=="2"
ATTRS{devnum}=="1"
ATTRS{devpath}=="0"
ATTRS{version}==" 2.00"
ATTRS{maxchild}=="6"
ATTRS{quirks}=="0x0"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{authorized}=="1"
ATTRS{manufacturer}=="Linux 2.6.35-31-generic ehci_hcd"
ATTRS{product}=="EHCI Host Controller"
ATTRS{serial}=="0000:00:04.1"
ATTRS{authorized_default}=="1"
looking at parent device '/devices/pci0000:00/0000:00:04.1':
KERNELS=="0000:00:04.1"
SUBSYSTEMS=="pci"
DRIVERS=="ehci_hcd"
ATTRS{vendor}=="0x10de"
ATTRS{device}=="0x077e"
ATTRS{subsystem_vendor}=="0x1019"
ATTRS{subsystem_device}=="0x2666"
ATTRS{class}=="0x0c0320"
ATTRS{irq}=="21"
ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000003"
ATTRS{local_cpulist}=="0-1"
ATTRS{modalias}=="pci:v000010DEd0000077Esv00001019sd00002666bc0Csc03i20"
ATTRS{numa_node}=="0"
ATTRS{dma_mask_bits}=="32"
ATTRS{consistent_dma_mask_bits}=="32"
ATTRS{enable}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{msi_bus}==""
ATTRS{companion}==""
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""6. Aus diesen Informationen erstelle ich die udev Regel:
#nano /etc/udev/rules.d/50-backup.rules
Inhalt:
KERNEL=="sd?1", ACTION=="add", SUBSYSTEMS=="scsi", ATTRS{vendor}=="Western Digital", ATTRS{serial}=="5743415A4141323930313936", RUN+="/root/backup.sh %k"7. UDEV neu starten:
#service udev reload
8. Jetzt das Backup Script erstellen:
nano /root/backup.sh
Inhalt:
#!/bin/bash
#
#-----------------------------------------------------------------------
#
# Script to backup all needed data upon USB hard disk insertion
# It is called thru UDEV with :
# - the device name (sda1, ...) given as the first parameter
#
#-----------------------------------------------------------------------
# Log beggining of backup
/usr/bin/logger Backup - Beginning at `date`
# if needed, create the mount directory
if [ ! -d /media/backup ] ; then mkdir /media/backup ; fi
# if your backup disk is formatted in ext2 or ext3, use following line to mount the backup disk
/bin/mount -t auto /dev/ /media/backup
# or if your backup disk is formatted in FAT32, use following line to mount the backup disk
#/bin/mount -t vfat -o shortname=mixed,iocharset=utf8 /dev/ /mnt/backup
# Backup command using RSync
/usr/bin/logger Backup - Video
/usr/bin/rsync -rtv --del --modify-window=2 /Daten/Benutzer /media/backup
# You can add here some other backups ...
#/usr/bin/logger Backup - other files
#/usr/bin/rsync -rtv --del --modify-window=2 /path/to/your/files/other /mnt/backup
# force sync of files to disk before unmounting
/bin/sync
# unmount the backup disk
/bin/umount /media/backup
# Log end of backup
/usr/bin/logger Backup - End at `date`
Habe die Anleitung aus dem ersten Post genauso, wie ich hier gerade beschrieben habe durchgeführt. Nicht mehr und nicht weniger.
Trotzdem funktionert es nicht. Wo liegt mein Fehler?