Welcome! Log In Create A New Profile

Advanced

how can I fix a partition

Posted by truehl 
truehl
how can I fix a partition
October 28, 2010 04:34PM
Hi,
problem: Booting the Dockstar with a usb-hd attached (and a stick) sometimes mount the stick to /dev/sda1 and sometimes to /dev/sdb1.

How can i fix the stick or the hd to a fix partition name?

Greetings,
Thomas
Re: how can I fix a partition
October 28, 2010 09:05PM
Hi Thomas,

I've just been looking into that today :)

I've used custom udev rules to do this.

An example:

I created a file named /etc/udev/rules.d/custom.rules containing:

KERNEL=="sd*[0-9]", ATTRS{product}=="Flash Disk", SYMLINK+="usb%n"
KERNEL=="sd*[0-9]", ATTRS{product}=="StorE HDD", ATTRS{serial}=="201005260571",SYMLINK+="nas_main"
KERNEL=="sd*[0-9]", ATTRS{product}=="StorE HDD", ATTRS{serial}=="2010052627E8",SYMLINK+="nas_backup"

This means my usb sticks always mount to /dev/usb%n.
And my two USB drives that I'm using as my NAS and NAS backup are mounted as /dev/nas_main and /dev/nas_backup.
I plan to rsync or duplicity those, so use the serial to distinguish between them.

To find the appropriate attributes, to do the filtering on for my disks, I used this command to list all the attributes
udevadm info --name=/dev/sda1 --attribute-walk

More info about udev I found on http://wiki.debian.org/udev

I've also used autofs to mount these automagically. But note that there is a bug in ntfs-3g which means auto-mounting ntfs drives with autofs fails unless you remove the mtab symlink to /proc/mounts. Took me a while to figure out. This is due to a bug which is not yet fixed in the ntfs-3g version on debian squeeze. Basically autofs passes a -n flag to mount when the mtab is symlinked, and ntfs-3g falls over when passed the -n flag.

Cheers,
Menno



Edited 1 time(s). Last edit at 10/28/2010 09:08PM by menno.
Re: how can I fix a partition
October 31, 2010 04:52AM
Hi Thomas,

Just to update I found some further info on this.

You can also list devices by label or by uuid (eg 'ls /dev/disk/by-label)

You can set the label using tune2fs -L and mkswap -L

Then you can use the label in fstab directly by mounting with the label by using /dev/disk/by-label/your_label

Or you can reference the label in udev rules using ENV{ID_FS_LABEL}

Note that oddly the UUID is not unique on disks. My two USB external hard disks, identical models, both use the same UUID, duh.

Cheers,
Menno
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: