Weblog entry #13 for Grimnar

Mounting USB 2.0 External disk
Posted by Grimnar on Tue 14 Nov 2006 at 16:36
Tags:
I bought my self a WD MyBook and I was hoping to mount it on my debian server. Of course I could use windows or osx to do this. But since I have Debian running 24/7 I would really like that to work instead.

Why did I go for WD or USB 2.0 and not other brands and network storage is not the issue here.

But what kind of file system is preferred to have on such disks? I would really like a filesystem that *all* OS can write on, and not only linux. The disk will be used for a secondary backup for all my photos. And when I have the system up and running I'm hoping for a rsync line wich updates the files every day or something like that, in order to keep it 100% mirrored without me bothering with it. So, How do I mount it, and what FS to use?

Edit Are there any precautions I need to understand before doing this? Cause my main goal is to have a very safe and clean backup disk. Will a powersurge mount the disk properly on reboot? Can I destroy the FS on a surge? I'm kinda paranoid when it comes to backing up my pictures. (Of course, I have them all on dvd/other disks as well) But there is one thing I never run out of, and that is bad luck. So better safe than sorry.

 

Comments on this Entry

Posted by ajt (81.6.xx.xx) on Tue 14 Nov 2006 at 19:08
[ Send Message | View Weblogs ]
If you want any OS to write directly to the disk then you'll need to use a primitive filesystem that they can all use, e.g. FAT. That will probably mean you will lose journaling, and other nice features. How important is native access from guest operating systems? Only you can answer that question.

Assuming is mounted on a Debian box, then you probably want a journaled file system such as ext3, Reiser, XFS or JFS. They each have their merits, but in most cases people use ext3. The guest operating system will then have to access via a network share of some sorts (Samba etc). See http://www.debian-administration.org/articles/388

To mount an external USB device I use UDEV, there are some nice tips here to get you going: http://www.debian-administration.org/articles/126 and http://www.debian-administration.org/articles/127

You can have the device mounted automatically on reboot, or on demand as in the automounter article. As it's not always going to be there - you may temporarily move it for example - you may want to try the automount option.

If you are worried about the device failing then you should buy a surge protector at the minimum, or a full uninteruptible power supply. Power spikes do happen, but how frequently depends where you live, only you can assess the risk.

Remember that the life span of CD-R and DVD-R media isn't that good. You can expect CD-R and DVD-R disks to start failing within 10 years or so, negatives and slides will probably outlive them as an archival medium. Magneto-optical is a better solution, but it is more expensive than CD/DVD.

You can always use an external network storage, there are lots of commercial companies offering secure network attached storage.

If you are worried about data on disks, then you should probably run your disk in a RAID set-up, and for ease of use run LVM on-top of that. There are articles here to explain how to do that to. http://www.debian-administration.org/articles/410




--
"It's Not Magic, It's Work"
Adam

[ Parent | Reply to this comment ]

Posted by Grimnar (85.221.xx.xx) on Wed 15 Nov 2006 at 19:54
[ Send Message | View Weblogs ]
After some delays I finally can follow this. Now, I got a newer etch kernel and probably newer udev. This is what I see with my system right now:

/var/log/messages

Nov 15 20:28:11 localhost kernel: EXT3 FS on hdf, internal journal
Nov 15 20:28:11 localhost kernel: EXT3-fs: mounted filesystem with ordered data mode.
Nov 15 20:28:11 localhost kernel: u32 classifier
Nov 15 20:28:11 localhost kernel:     OLD policer on 
Nov 15 20:28:11 localhost kernel: Ingress scheduler: Classifier actions prefered over netfilter
Nov 15 20:28:11 localhost kernel: eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
Nov 15 20:28:13 localhost kernel: eth1: link up, 100Mbps, full-duplex, lpa 0xC5E1
Nov 15 20:28:14 localhost kernel: ip_tables: (C) 2000-2006 Netfilter Core Team
Nov 15 20:28:14 localhost kernel: Netfilter messages via NETLINK v0.30.
Nov 15 20:28:14 localhost kernel: ip_conntrack version 2.4 (7679 buckets, 61432 max) - 224 bytes per conntrack
Not very good eh?

dmesg | grep -i WD (Western Digital)

hdb: WDC WD800BB-22CAA1, ATA DISK drive
hde: WDC WD1600JB-00GVA0, ATA DISK drive
  Vendor: WD        Model: 2500JB External   Rev: 0107
Tried dmesg | grep -i usb, but that gave me to much info about stuff I dont understand.
How important is native access from guest operating systems? 
See http://www.debian-administration.org/articles/388
I normally use Samba to access my other internal disk from my osx/win system. So I guess I will use ext3. The only problem with this is when I'm taking the disk with me and unload it to another pc. But that can be worked around, I know.

Remember that the life span of CD-R and DVD-R media isn't that good
Yeah, I know. But I *know* my disk are going to fail within that time anyway. So its just another way of making sure.
You can always use an external network storage
I know, I know. But thanks alot for the input. Discussion is always good. But back to topic, I really dont understand anything in the links you provided. Sorry.

[ Parent | Reply to this comment ]

Posted by Grimnar (85.221.xx.xx) on Wed 15 Nov 2006 at 20:18
[ Send Message | View Weblogs ]
Spicing up this site abit:) Linking image did not work. Oh well.

[ Parent | Reply to this comment ]

Posted by ajt (81.6.xx.xx) on Wed 15 Nov 2006 at 21:02
[ Send Message | View Weblogs ]

udev can be an interesting challenge! but it is worth persisting to get it to work. I don't think it's mentioned in the articles I linked too, but there are some extra tools shipped with udev which can make creating the rules a little easier.

The basic idea is that you boot your box. Start a shell sesion, then plug-in the new device and see what is reported. Unplug it. Try and figure out something unique to describe it, write a rule, then try again.

It's probably worth running tail -f /var/log/messages when you plug something in, then you can see what's going on in real time. When I plug in a USB memory key I get the following (slightly edited) in my /var/log/messages/

~ kernel: usb 5-6: new high speed USB device using ehci_hcd and address 3
~ kernel: scsi3 : SCSI emulation for USB Mass Storage devices
~ kernel:  Vendor: Easy      Model: Disk        Rev: 3000
~ kernel:  Type:   Direct-Access                ANSI SCSI revision: 00
~ kernel: SCSI device sdb: 1014784 512-byte hdwr sectors (520 MB)
~ kernel: sdb: Write Protect is off
~ kernel: SCSI device sdb: 1014784 512-byte hdwr sectors (520 MB)
~ kernel: sdb: Write Protect is off
~ kernel:  sdb: sdb1
~ kernel: sd 3:0:0:0: Attached scsi removable disk sdb

I can see some key details, "Easy", "Disk" and it's being treated as "SCSI", which should be enough to separate it from all the other plug-in devices I have (not many). Towards the end you can see that the kernel has create the next available SCSI device node for it sdb. I've configured udev to let the kernel do what it wants - frankly I don't care where the device goes - but I've told udev to create a constant symlink to it, which is what I put in my /etc/fstab.

My /etc/udev/local.rules looks like this:

BUS=="scsi", SYSFS{model}=="Camera  KD-25", SYMLINK="konica_camera"
BUS=="scsi", SYSFS{vendor}=="WDC AC34", SYSFS{model}=="000L", SYMLINK="icy_box"
BUS=="scsi", SYSFS{vendor}=="Easy", SYSFS{model}=="Disk", SYMLINK="easy_disk"

You can see that what I'm doing is pulling a few features from a device, and just telling udev to create a symlink, the normal kernel device node will be created automatically and I don't pay any attention to that.

In my fstab I have a corresponding line to the symlink (not the kernel created device node) and a mount point. I'm not using automounter, but you may want to in your case.

/dev/easy_disk /media/easy vfat user,noauto 0 0

In your case the following rule may get you going.

BUS=="scsi", SYSFS{vendor}=="WD", SYSFS{model}=="2500JB External", SYMLINK="external"

And in your /etc/fstab, assuming it's been formatted ext3 already.

/dev/external /media/external ext3 user,noauto 0 0

Hope this helps! I plan to do a talk on udev at my LUG sometime...

--
"It's Not Magic, It's Work"
Adam

[ Parent | Reply to this comment ]

Posted by Grimnar (85.221.xx.xx) on Wed 15 Nov 2006 at 21:26
[ Send Message | View Weblogs ]
Thanks alot. Need some sleep now. Will see into it tomorrow. Thanks alot.

[ Parent | Reply to this comment ]

Posted by Grimnar (85.221.xx.xx) on Thu 16 Nov 2006 at 23:41
[ Send Message | View Weblogs ]
Update. Last night I testet the waters on a very different forum, just for the fun of it. Checking if there is a different approach to this. And sure enough, I got this.

1.tail -f /var/log/messages (upon usb connection, no news here)
2.Get the device name (/dev/sda) format it and mount it. (ext3)
3.edit fstab with /dev/sda5 /mnt/dir ext3 user,auto,fmask=0111,dmask=0000 0 1

Great, it's working. Figured out a basic rsync one liner as well without asking here:)

Now, what does the great people of DA.org think about this solution?

Is it risky?

[ Parent | Reply to this comment ]

Posted by Utumno (60.248.xx.xx) on Tue 12 Dec 2006 at 03:39
[ Send Message | View Utumno's Scratchpad | View Weblogs ]
It's not 'risky' it's incorrect. I mean, it is going to work *if* the attached disk really gets assigned the '/dev/sda' node, but that's not always the case. Udev way is always going to work.

[ Parent | Reply to this comment ]

Posted by eric (194.2.xx.xx) on Fri 17 Nov 2006 at 15:58
[ Send Message | View Weblogs ]
I normally use Samba to access my other internal disk from my osx/win system. So I guess I will use ext3. The only problem with this is when I'm taking the disk with me and unload it to another pc. But that can be worked around, I know.
You can try the ext2/ext3 drivers which exist for Windows. A fast search on google gave me : I can't give you any advice about them as I haven't try them. I only tried explore2fs (http://www.chrysocome.net/explore2fs) which give read only access to ext2/ext3 partitions and works well.

:eric:
http://blog.sietch-tabr.com

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search