[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

User can't unmount by uuid (was: Pendrive not mounted when another usb device is plugged in)



Rodolfo Medina <rodolfo.medina@gmail.com> writes:

>>> I have Debian Etch.
>>>
>>> In my /etc/fstab there is the following entry:
>>>
>>>  /dev/sda        /mnt/sda 	vfat    rw,user,noauto       0       0
>>>
>>> , so I normally mount my usb pendrive simply with:
>>>
>>>  $ mount /mnt/sda



Ron Johnson <ron.l.johnson@cox.net> writes:

>> [...] in /etc/fstab I'd refer to that drive not as /dev/sda but by it's
>> UUID.




Rodolfo:

> All right, I did so [...].  But now,
> when I want to unmount it, with: `umount /mnt/sda', the output is:
> `Segmentation fault', and the drive is not unmounted.
>
> How to unmount it now?



It seems to be a bug (in fact, the problem does not occur in Debian Sid):
see:

 http://bugs.archlinux.org/task/11110

.  To fix it, I'm attaching the patch.  To find the device's UUID, do:

# blkid

.  In my case, the output contained the line:

 /dev/sda: SEC_TYPE="msdos" UUID="44F1-7D0C" TYPE="vfat"

.  Then I put the following line in fstab:

 UUID=44F1-7D0C /mnt/pendrive 	vfat    rw,user,noauto       0       0

and did:

 # mkdir /mnt/pendrive

, then rebooted.  I copied the patch into /tmp and named it
`util-linux_user_mount.patch'. Then I ran the following commands:

 # apt-get install build-essential
 # apt-get build-dep mount
 # cd /tmp
 # apt-get source mount
 # cd util-linux-2.12r
 # ./debian/rules patch
 # patch -Np1 -i ../util-linux_user_mount.patch
 # ./configure
 # make lib
 # make -C mount
 # chmod 4755 mount/umount
 # mv mount/umount /bin

.  Now I was able to mount the pendrive with:

 $ mount /mnt/pendrive

and unmount it with:

 $ umount /mnt/pendrive

Bye
Rodolfo


diff -U 3 -r util-linux-2.12r/mount/fstab.c util-linux-2.12r.new/mount/fstab.c
--- util-linux-2.12r/mount/fstab.c	2007-04-27 09:11:18.000000000 -0500
+++ util-linux-2.12r.new/mount/fstab.c	2007-04-26 21:59:09.000000000 -0500
@@ -296,7 +296,7 @@
 	const char *devuuid;
 	int ret;
 
-	devuuid = mount_get_devname_by_uuid(device);
+	devuuid = mount_get_volume_uuid_by_spec(device);
 	ret = !strcmp(uuid, devuuid);
 	/* free(devuuid); */
 	return ret;
diff -U 3 -r util-linux-2.12r/mount/mount_blkid.c util-linux-2.12r.new/mount/mount_blkid.c
--- util-linux-2.12r/mount/mount_blkid.c	2007-04-27 09:11:18.000000000 -0500
+++ util-linux-2.12r.new/mount/mount_blkid.c	2007-04-26 22:01:13.000000000 -0500
@@ -32,6 +32,11 @@
 }
 
 const char *
+mount_get_volume_uuid_by_spec(const char *spec) {
+	return blkid_get_tag_value(blkid, "UUID", spec);
+}
+
+const char *
 mount_get_devname_by_label(const char *label) {
 	return blkid_get_devname(blkid, "LABEL", label);
 }
diff -U 3 -r util-linux-2.12r/mount/mount_blkid.h util-linux-2.12r.new/mount/mount_blkid.h
--- util-linux-2.12r/mount/mount_blkid.h	2007-04-27 09:11:18.000000000 -0500
+++ util-linux-2.12r.new/mount/mount_blkid.h	2007-04-26 22:02:51.000000000 -0500
@@ -6,6 +6,7 @@
 extern void mount_blkid_get_cache(void);
 extern void mount_blkid_put_cache(void);
 extern const char *mount_get_devname_by_uuid(const char *uuid);
+extern const char *mount_get_volume_uuid_by_spec(const char *spec);
 extern const char *mount_get_devname_by_label(const char *label);
 extern const char *mount_get_volume_label_by_spec(const char *spec);
 extern const char *mount_get_devname(const char *spec);

Reply to: