Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Mounting removable flash drives to improve write performance
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
massysett
Apprentice
Apprentice


Joined: 06 Jan 2006
Posts: 296
Location: Silver Spring, Maryland USA

PostPosted: Fri Jan 20, 2006 1:57 am    Post subject: Mounting removable flash drives to improve write performance Reply with quote

Perhaps you use ivman to automatically mount your removable USB flash drives. However, by default your HAL settings will cause the drive to be mounted with the "sync" option turned on. This will dramatically increase the amount of time it takes to write to the drive. In addition, it shortens the drive's lifespan. However, it has one advantage: when the drive's light stops flashing, you can safely unplug it.

You can have HAL set the drive to be mounted without the sync option. This dramatically improves write speeds. However, it has the disadvantage of requiring that you unmount the drive before unplugging it, otherwise you will risk data loss.

To mount the drive without the sync option, and to mount it so that ordinary users can unmount it (rather than just having root being able to unmount it), create the file /usr/share/hal/fdi/95userpolicy/nosync.fdi and put the following in it:

Code:

<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->

<!-- This file overrides default HAL behavior by mounting removable volumes
without sync. This dramatically speeds up write times, but requires that
volumes be unmounted before disconnecting them. The file also
allows users to unmount removable volumes. -->

<deviceinfo version="0.2">

<device>

   <!-- Use noatime, but make "sync" false and allow users to unmount,
   for all hotpluggable or removable volumes smaller than 2GB -->

   <match key="volume.size" compare_lt="2147483648">
   <match key="@block.storage_device:storage.hotpluggable" bool="true">

   <!-- set sync = false -->
   <merge key="volume.policy.mount_option.sync" type="bool">false</merge>
   <merge key="volume.policy.mount_option.noatime" type="bool">true</merge>

   <!-- added this option so that regular users can unmount the drive -->
   <merge key="volume.policy.mount_option.users" type="bool">true</merge>
   </match>
   <match key="@block.storage_device:storage.removable" bool="true">

   <!-- set sync = false -->
   <merge key="volume.policy.mount_option.sync" type="bool">false</merge>
   <merge key="volume.policy.mount_option.noatime" type="bool">true</merge>
   
   <!-- added this option so that regular users can unmount the drive -->
   <merge key="volume.policy.mount_option.users" type="bool">true</merge>
   </match>
   </match>

</device>

</deviceinfo>


You could achieve the same result by editing /usr/share/hal/fdi/90defaultpolicy/storage-policy.fdi, but this is not recommended because future updates of the HAL package might then overwrite the changes you made.
Back to top
View user's profile Send private message
eelke
Guru
Guru


Joined: 17 May 2004
Posts: 406
Location: Earth, Netherlands, Friesland

PostPosted: Fri Jan 20, 2006 5:16 pm    Post subject: Reply with quote

Quote:
However, it has one advantage: when the drive's light stops flashing, you can safely unplug it.


Devices must be unmounted before being removed. Failing todo so can cause a kernel panic.
Back to top
View user's profile Send private message
Vann
Guru
Guru


Joined: 04 Aug 2002
Posts: 357

PostPosted: Fri Jan 20, 2006 5:29 pm    Post subject: Reply with quote

I have unpludded my USB thumb drive dozens and dozens of times without a kernel panic. Maybe you have an improperly configured kernel?

Personally I prefer having the sync option.
Back to top
View user's profile Send private message
massysett
Apprentice
Apprentice


Joined: 06 Jan 2006
Posts: 296
Location: Silver Spring, Maryland USA

PostPosted: Fri Jan 20, 2006 5:34 pm    Post subject: Reply with quote

eelke wrote:
Devices must be unmounted before being removed. Failing todo so can cause a kernel panic.


Could you explain that a little more? ivman automatically unmounts removable devices when the user unplugs them. Of course ivman can't ensure that all the data has been written to the drive before the user unplugs it, which is the problem with turning off sync--some of the writing to the device is delayed a few seconds, so the drive might look like it's done but it's really not.

Maybe there would be a kernel panic if the kernel is writing to the device while it's being unplugged?
Back to top
View user's profile Send private message
eelke
Guru
Guru


Joined: 17 May 2004
Posts: 406
Location: Earth, Netherlands, Friesland

PostPosted: Fri Jan 20, 2006 7:00 pm    Post subject: Reply with quote

I must admit it is a long time ago it went wrong for me because I allways have been careful to unmount first, 2 kernel panics where enough to stop me from trying again. I have another system nowadays so maybe I should try again (after flushing my disk caches).
Back to top
View user's profile Send private message
yanos
Tux's lil' helper
Tux's lil' helper


Joined: 11 Sep 2003
Posts: 149
Location: montreal, canada

PostPosted: Thu Mar 09, 2006 3:44 am    Post subject: Reply with quote

I have a small problem: I don't have those files! I tried a couple of things but it didn't work and now I'm out of clues. My usbstick always gets mounted with the sync option. Any hint?


I described what I tried here:
https://forums.gentoo.org/viewtopic-p-3161911.html#3161911 (12th post)
Back to top
View user's profile Send private message
massysett
Apprentice
Apprentice


Joined: 06 Jan 2006
Posts: 296
Location: Silver Spring, Maryland USA

PostPosted: Thu Mar 09, 2006 4:02 am    Post subject: Reply with quote

Did you try /usr/share/hal/fdi/95userpolicy/nosync.fdi ? (Your other post says you used /usr/share/hal/fdi/policy/95userpolicy/nosync.fdi ; note the extra 'policy' in the path you used.)
_________________
Draft Windows-to-Linux Guide
Back to top
View user's profile Send private message
yanos
Tux's lil' helper
Tux's lil' helper


Joined: 11 Sep 2003
Posts: 149
Location: montreal, canada

PostPosted: Thu Mar 09, 2006 4:27 am    Post subject: Reply with quote

I just tried that then restart hald. No luck.
Back to top
View user's profile Send private message
yanos
Tux's lil' helper
Tux's lil' helper


Joined: 11 Sep 2003
Posts: 149
Location: montreal, canada

PostPosted: Wed Mar 15, 2006 3:18 am    Post subject: Reply with quote

I just bought a usb-storage mp3 player. When I mount it, it doesn't have the sync option, but my usb stick still have it. I checked back some hal config files and there doesn't seem to be a way to specify special settings for individual device. I saw settings based on the size of the volumes but the condition was at ~2Gig and none of my devices are as big as that.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum