Вот мой текущий рецепт для монтирования 2 внешних USB 2.0 дисков с помощью системы udev и rc-скрипта rc.local в Ubuntu 10.04 LTS.
# Become root
su
# Find USB devices.
# Search for sd
# :/sd
dmesg | less
# Find out what partitions are currently mounted
df -h | less
# Find out where the different(i.e. Windows,NTFS,ext3) volumes are in the partition table
fdisk -l | less
#
# Disk /dev/sda: 160.0 GB, 160041885696 bytes
# 255 heads, 63 sectors/track, 19457 cylinders
# Units = cylinders of 16065 * 512 = 8225280 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disk identifier: 0x00062bd5
#
# Device Boot Start End Blocks Id System
# /dev/sda1 * 1 19269 154778211 83 Linux
# /dev/sda2 19270 19457 1510110 5 Extended
# /dev/sda5 19270 19457 1510078+ 82 Linux swap / Solaris
#
# Disk /dev/sdb: 500.1 GB, 500107862016 bytes
# 255 heads, 63 sectors/track, 60801 cylinders
# Units = cylinders of 16065 * 512 = 8225280 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disk identifier: 0x00000000
#
# Device Boot Start End Blocks Id System
# /dev/sdb1 1 60801 488384001 83 Linux
#
# Disk /dev/sdc: 500.1 GB, 500107862016 bytes
# 255 heads, 63 sectors/track, 60801 cylinders
# Units = cylinders of 16065 * 512 = 8225280 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disk identifier: 0xde504d75
#
# Device Boot Start End Blocks Id System
# /dev/sdc1 1 60801 488384001 83 Linux
# See properties of sd. devices
udevadm info --attribute-walk --name /dev/sdb1
udevadm info --attribute-walk --name /dev/sdd1
udevadm info -a -p `udevadm info -q path -n /dev/sdb1` | grep -e "SUBSYSTEM==" -e "KERNEL==" -e "ATTR{partition}==" -e "ATTR{size}==" -e "ATTRS{serial}=="
# KERNEL=="sdb1"
# SUBSYSTEM=="block"
# ATTR{partition}=="1"
# ATTR{size}=="976768002"
# ATTRS{serial}=="2HA4DF8P "
# ATTRS{serial}=="0000:02:0a.2"
udevadm info -a -p `udevadm info -q path -n /dev/sdc1` | grep -e "SUBSYSTEM==" -e "KERNEL==" -e "ATTR{partition}==" -e "ATTR{size}==" -e "ATTRS{serial}=="
# KERNEL=="sdc1"
# SUBSYSTEM=="block"
# ATTR{partition}=="1"
# ATTR{size}=="976768002"
# ATTRS{serial}=="2HA16NDX "
# ATTRS{serial}=="0000:02:0a.2"
# External hard drives
# d - delete all existing partitions
# n - add a new partition
# p - primary partition
# 1 - partition number 1
# 83 - partition type: 83 Linux
# w - write table to disk and exit
fdisk /dev/sdb
fdisk /dev/sdc
# Create ext2 filesystems on USB drives and format them
# I create ext2 not ext3 because for a while there was
# only ext2 filesystem support on Windows.
# I wanted to be able to read the filesystem from a
# Windows machine.
# Your needs may be different.
mkfs.ext2 /dev/sdb1
mkfs.ext2 /dev/sdc1
# Determine kernel version (see below)
uname -r
# Instruct udev to make symlinks for the drives based on the manufactor,
# size, or any number of properties about the device. That symlink will
# always point to that device regardless of what device node
# (ie /dev/sda, /dev/sdb) it ends up getting assigned. Then you can modify
# your fstab to use the symlink vs the device node, which in turn allows
# you to always address the device the same way.
# Put a hard return at the end so it would print
cat > /etc/udev/rules.d/85-usb-hd-fix.rules <<'EOF'
# 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
# (first paragraph or block of rules)
# and the attributes from one single parent device.
# (any paragraph or block of rules following the first paragraph or block of rules)
#
# For example, below we see some of the attributes of the device listed first
# SUBSYSTEM
# KERNEL
# ATTR{partition}
# ATTR{size}
# and the attribute from one single parent device listed last
# ATTRS{serial}
# backup500
SUBSYSTEM=="block", KERNEL=="sd?1", ATTR{partition}=="1", ATTR{size}=="976768002" , ATTRS{serial}=="2HA4DF8P ", SYMLINK+="backup500", GROUP="disk", MODE="0660"
# backup501
SUBSYSTEM=="block", KERNEL=="sd?1", ATTR{partition}=="1", ATTR{size}=="976768002" , ATTRS{serial}=="2HA16NDX ", SYMLINK+="backup501", GROUP="disk", MODE="0660"
EOF
# Change the attributes of the udev rules file
chmod 644 /etc/udev/rules.d/85-usb-hd-fix.rules
# Test udev
udevadm test /sys/block/sdb block
udevadm test /sys/block/sdc block
# Test udev
restart udev
# Install kernel for PentiumPro
sudo apt-get install linux-686
# Create the mount points
mkdir -p /mnt/backup500
mkdir -p /mnt/backup501
# Make sure that the external USB drives (identified by the udev system)
# are not referenced in /etc/fstab
#
# The current /etc/fstab file looks like:
cat /etc/fstab
# Should look like
# # /etc/fstab: static file system information.
# #
# # <file system> <mount point> <type> <options> <dump> <pass>
# proc /proc proc defaults 0 0
# # /dev/sda1
# UUID=fb518094-0d3b-42f4-a1cc-a3fa659fcd8a / ext3 relatime,errors=remount-ro 0 1
# # /dev/sda5
# UUID=b04dba06-114e-0fa5-f823-75a116ae2fc0 none swap sw 0 0
# /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
# /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
# Install sdparm
apt-get update
apt-get install sdparm
# See the current state of the STANDBY drive flag
sdparm -al /dev/backup500
# This should be 1 (on/true/enabled)
# Set STANDBY to 0 (off/false/disabled)
sdparm --clear STANDBY -6 /dev/backup500
# See the current state of the STANDBY drive flag
# This should be 0 (off/false/disabled)
sdparm -al /dev/backup500
# Modify script /etc/rc.local to mount all filesystems in /etc/fstab
cat > /etc/rc.local <<'EOF'
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Set STANDBY to 0 (off/false/disabled) only on the Maxtor OneTouch enclosures
sdparm --clear STANDBY -6 /dev/backup500
sdparm --clear STANDBY -6 /dev/backup501
# Mount USB drives
mount -t ext2 -o rw,auto,user /dev/backup500 /mnt/backup500
mount -t ext2 -o rw,auto,user /dev/backup501 /mnt/backup501
exit 0
EOF
# Change the attributes of the udev rules file
chmod 755 /etc/rc.local
# Reboot
shutdown -r now
# The following should already be mounted automatically after the reboot
# If not mounted, mount manually
# mount /mnt/backup500
# mount /mnt/backup501
# Create or rename directories
# mkdir -p /mnt/backup501/backup501/files
# mkdir -p /mnt/backup500/backup500/files
# Create symbolic links
# /home/backup500 -> /mnt/backup500/backup500
# /home/backup501 -> /mnt/backup501/backup501
ln -s /mnt/backup500/backup500 /home
ln -s /mnt/backup501/backup501 /home
# To remove the links
# unlink /home/backup500
# unlink /home/backup501
Это будет определять внешние USB-диски при загрузке каждый раз и назначать их как /dev /backup500 /dev /backup501
Я хотел бы перейти с внешних резервных копий USB 2.0 на резервные копии FireWire. Возможно, я возьму диски из существующих ящиков и получу внешние чехлы FireWire для использования с этими дисками SATA.
Видите ли, я ежедневно копирую около 64 ГБ данных, и мне нужна более быстрая скорость передачи данных. Кроме того, внутренние диски не являются опцией, так как у меня был плохой опыт (мой основной жесткий диск потерпел крах, а другой внутренний диск, использовавшийся для резервного копирования в то время, также сломался)
Как я могу изменить сценарий выше для интерфейса FireWire? Поддерживает ли система Ubuntu udev устройства FireWire? Должен ли я ждать внедрения USB 3.0 и сохранить свои деньги?