Fedora Linux Support Community & Resources Center
  #1  
Old 6th April 2012, 12:28 AM
Japplo Offline
Registered User
 
Join Date: Sep 2010
Posts: 76
linuxfirefox
F17 and Discard (TRIM) support on LUKS/dm-crypt devices

Hi guys,
how can I enabled the discard option on LUKS/dm-crypt devices?

Thanks japplo
Reply With Quote
  #2  
Old 15th April 2012, 12:22 PM
Japplo Offline
Registered User
 
Join Date: Sep 2010
Posts: 76
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

cat /etc/crypttab
luks-23a640d0-0132-4189-8459-7ede9812fe3d UUID=23a640d0-0132-4189-8459-7ede9812fe3d none,discard

doens't work in F17... any idea's?
Reply With Quote
  #3  
Old 20th April 2012, 08:42 AM
Puff65537 Offline
Registered User
 
Join Date: Apr 2012
Location: The Sky
Posts: 5
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

Quote:
Originally Posted by Japplo View Post
cat /etc/crypttab
luks-23a640d0-0132-4189-8459-7ede9812fe3d UUID=23a640d0-0132-4189-8459-7ede9812fe3d none,discard

doens't work in F17... any idea's?
Did you remember to use dracut to create a new initramfs with the new crypttab in it?
Reply With Quote
  #4  
Old 20th April 2012, 04:50 PM
StephenH Offline
Registered User
 
Join Date: Jul 2004
Location: Wake Forest, NC
Age: 60
Posts: 1,385
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

Why are you putting it in your cryptab? Why not in fstab, which is the place I have seen referenced to using the discard option in every guide I have seen?

/dev/mapper/luks-90.............f6 / ext4 defaults,noatime,discard 1 1

See these threads for more information:

http://forums.fedoraforum.org/showthread.php?t=256068
http://forums.fedoraforum.org/showthread.php?t=277082
__________________
StephenH

"We must understand the reality that just because our culture claims certain things are true it does not mean they are!" --M. Liederbach

http://pilgrim-wanderings.blogspot.com

Last edited by StephenH; 20th April 2012 at 04:51 PM. Reason: added link
Reply With Quote
  #5  
Old 20th April 2012, 05:20 PM
Japplo Offline
Registered User
 
Join Date: Sep 2010
Posts: 76
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

@Puff65537 doesn't work for me. I have a workaround using the dm-table, but this is not very easy to handle
@StephenH I'm using a luks/dm-crypt device. Only add the discard option in the /etc/fstab is not enough. http://www.fedoraforum.org/forum/sho....php?p=1511682 and cryptsetup status luks-23a640d0-0132-4189-8459-7ede9812fe3d shows me, that discard is not avaible
Reply With Quote
  #6  
Old 20th April 2012, 06:08 PM
StephenH Offline
Registered User
 
Join Date: Jul 2004
Location: Wake Forest, NC
Age: 60
Posts: 1,385
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

When I look at the /etc/crypttab file, I see the reference to the LUKS is associated with the UUID and none.
Here is an example (edited)

luks-eb9... ... ... ...f3 UUID=eb9... ... ... ... ...f3 none

There are four such entries, one for each of the encrypted partitions on my drive. I do not use LVM, so each partition is separate.

In my fstab file, I see this for my desktop system, which is on a standard HD:

/dev/mapper/luks-eb9... ... ... ... ...f3 /home ext4 defaults 1 2

In my fstab for the netbook which is on an SSD, the only difference is the addition to make the equivalent line read defaults,noatime,discard.

Now, the ext4 file system is handled by the fstab. The cryptab is just the container, but once it is unlocked, would not the trim be handled by the fstab entry since we are looking at a file system operation? My subjective experience with the SSD in this netbook seems to indicate that fstab is the appropriate place as I have not noticed the slowdown that some indicate is an issue when the trim option is not used.

I have now been using this SSD configured as I said for a number of weeks. Previously, the Read-Only Benchmark by the Disk Utility had minimum read rate of 184.4, maximum 270.6 and average of 240.4 MB/s. I just did another test, and the testing is very close to that, 183.5, 269.4, and 237.8 MB/s, respectively with repeated test coming in at around the same figures (with minor variations).

I really did not see anything in the link you posted to indicate that changing the crypttab file is needed. Post #8 in that thread claimed that the filesystem commands were not passed through to the drive. If that were the case, then it would seem that once a space on the SSD were allocated by the filesystem, then the underlying filesystem's usage would be permanently locked in the crypttab and it would be shown as allocated. However, if I delete a large file (or set of files), I can see the results when I execute a df command. The space is apparently being freed up. My drive is apparently able to use the trim command in the fstab to keep things working well, and my experience with this OCZ Vertex Plus drive is quite satisfactory.

Disclaimer: I am not an engineer, just a satisfied user and am relaying my subjective experience, not technical information. I am willing to be shown that I am wrong and that something is needed in the crypttab. However, there is nothing compelling so far in the other thread to prove that case. "As far as I know..." is far from definitive.
__________________
StephenH

"We must understand the reality that just because our culture claims certain things are true it does not mean they are!" --M. Liederbach

http://pilgrim-wanderings.blogspot.com
Reply With Quote
  #7  
Old 27th April 2012, 12:03 PM
dismuter Offline
Registered User
 
Join Date: Apr 2012
Location: Lyon, France
Posts: 3
windows_7firefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

Quote:
Originally Posted by StephenH View Post
The cryptab is just the container, but once it is unlocked, would not the trim be handled by the fstab entry since we are looking at a file system operation? My subjective experience with the SSD in this netbook seems to indicate that fstab is the appropriate place as I have not noticed the slowdown that some indicate is an issue when the trim option is not used.
My 2 cents:
As you said fstab gives file system options, so deleting files on ext4/Btrfs/XFS will trigger a discard command. However that discard command will hit the next layer, which in your case is the LUKS/dm-crypt layer. If that layer is not given instructions to re-issue discard commands to lower levels when it receives them, then there will be no trimming (discarding) on your SSD. Same goes for the LVM layer, for which discard commands can be activated in /etc/lvm/lvm.conf by setting issue_discards to 1.
All in all, I don't think your SSD is receiving any TRIM command if you haven't done anything about enabling discard on your encryption layer.


Now I too have a problem with enabling discard upon boot-up on Fedora 17. I modified /etc/crypttab to add "discard" to the fourth column and ran 'dracut -f' to rebuild initramfs, I checked that the new crypttab was properly copied to it, but running 'dmsetup table' after a reboot shows no sign of discard being activated.
I tried the same changes on Ubuntu 12.04 ('dracut -f' changed to 'update-initramfs -u') and they worked without a hiccup. The difference in Ubuntu is that /etc/crypttab includes a "luks" option in the fourth column.
So what is the proper way of enabling discard on LUKS/dm-crypt on F17?

Quote:
Originally Posted by Japplo View Post
cat /etc/crypttab
luks-23a640d0-0132-4189-8459-7ede9812fe3d UUID=23a640d0-0132-4189-8459-7ede9812fe3d none,discard

doens't work in F17... any idea's?
Unless I'm mistaken, it should be "none discard" at the end, no comma. But that doesn't work for me under Fedora.

---------- Post added at 01:03 PM ---------- Previous post was at 09:24 AM ----------

Well, it looks like it's simply an omission from /usr/lib/dracut/modules.d/90crypt/cryptroot-ask.sh, hence the following comment:
Quote:
TODO: improve to support what cmdline does
I'll look at where to manually add the --allow-discards flag to cryptsetup in dracut's crypt module. It'll do on my side until someone more proficient fixes that.

Edit: this works:
Quote:
[]# diff cryptroot-ask-orig.sh cryptroot-ask.sh
108c108
< --ply-cmd "$luks_open -T1 $device $luksname" \
---
> --ply-cmd "$luks_open -T1 $device $luksname --allow-discards" \
111c111
< --tty-cmd "$luks_open -T5 $device $luksname"
---
> --tty-cmd "$luks_open -T5 $device $luksname --allow-discards"

Last edited by dismuter; 27th April 2012 at 01:09 PM. Reason: Added diff
Reply With Quote
  #8  
Old 30th April 2012, 02:50 AM
Puff65537 Offline
Registered User
 
Join Date: Apr 2012
Location: The Sky
Posts: 5
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

That worked
Reply With Quote
  #9  
Old 3rd May 2012, 01:30 PM
Japplo Offline
Registered User
 
Join Date: Sep 2010
Posts: 76
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

I think it doesn't work for me because with "cryptsetup status luks-xxx" the discard flag is missing. Are you using F17?
Reply With Quote
  #10  
Old 3rd May 2012, 01:47 PM
StephenH Offline
Registered User
 
Join Date: Jul 2004
Location: Wake Forest, NC
Age: 60
Posts: 1,385
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

Quote:
Originally Posted by dismuter View Post
My 2 cents:
As you said fstab gives file system options, so deleting files on ext4/Btrfs/XFS will trigger a discard command. However that discard command will hit the next layer, which in your case is the LUKS/dm-crypt layer. If that layer is not given instructions to re-issue discard commands to lower levels when it receives them, then there will be no trimming (discarding) on your SSD. Same goes for the LVM layer, for which discard commands can be activated in /etc/lvm/lvm.conf by setting issue_discards to 1.
All in all, I don't think your SSD is receiving any TRIM command if you haven't done anything about enabling discard on your encryption layer.
I can understand that. However, fixing it is a different matter then.

Quote:
Now I too have a problem with enabling discard upon boot-up on Fedora 17. I modified /etc/crypttab to add "discard" to the fourth column and ran 'dracut -f' to rebuild initramfs. . .
So what is the proper way of enabling discard on LUKS/dm-crypt on F17?

Well, it looks like it's simply an omission from /usr/lib/dracut/modules.d/90crypt/cryptroot-ask.sh, hence the following comment:

I'll look at where to manually add the --allow-discards flag to cryptsetup in dracut's crypt module. It'll do on my side until someone more proficient fixes that.

Edit: this works:
Well, this didn't work for me with F16. It left me with a system that would not recognize the password and just kept giving me a message about discard not being supported.

I thought I had destroyed my working setup, but just booting to the previous kernel, then uninstalling the newest one where I had done the change (which deleted the initramfs which didn't work) and then reinstalling it got things back to normal.

I think I'll wait until the upstream support is there before I mess with this again. As I said, I have not noticed any slowdown with only having the trim support enabled in fstab, even if crypttab is not passing it through. Maybe this summer when I have more time I can try again, especially after F17 is released.
__________________
StephenH

"We must understand the reality that just because our culture claims certain things are true it does not mean they are!" --M. Liederbach

http://pilgrim-wanderings.blogspot.com
Reply With Quote
  #11  
Old 5th May 2012, 03:21 AM
Puff65537 Offline
Registered User
 
Join Date: Apr 2012
Location: The Sky
Posts: 5
windows_xp_2003firefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

For performance reasons you have to run fstrim by hand. My setup has the following mods:

/etc/cryptsetup : "none discard" at the end of all lines on an ssd
/usr/lib/dracut/modules.d/90crypt/cryptroot-ask.sh : all lines using "luks_open" also have --allow-discard (note that you have to fix this every time dracut is updated).
/etc/fstab: noatime,discard added to all ssd files systems.

initfs rebuilt after all the changes

after all that I still run "time fstrim -v /<ssd filesystem>" by hand when I'm ready for the performance hit (note: time isn't needed, but it will show you why they don't auto-trim).
Reply With Quote
  #12  
Old 5th May 2012, 08:38 AM
Japplo Offline
Registered User
 
Join Date: Sep 2010
Posts: 76
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

Hello Puff65537,
can you show me a "cryptsetup status luks-xxx | grep flag" ?
Reply With Quote
  #13  
Old 5th May 2012, 08:49 AM
Puff65537 Offline
Registered User
 
Join Date: Apr 2012
Location: The Sky
Posts: 5
windows_xp_2003firefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

I show:
" flags: discards"
Reply With Quote
  #14  
Old 5th May 2012, 09:20 AM
Japplo Offline
Registered User
 
Join Date: Sep 2010
Posts: 76
linuxfirefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

Crazy, and are you using F17?
Reply With Quote
  #15  
Old 5th May 2012, 09:29 AM
Puff65537 Offline
Registered User
 
Join Date: Apr 2012
Location: The Sky
Posts: 5
windows_xp_2003firefox
Re: F17 and Discard (TRIM) support on LUKS/dm-crypt devices

I did change /etc/issue not to say beefy miracle (that was too whack for me), but other than that its F17-TC2 + all updates. Note that I did zero out my MBR and LVM volumes from the previous F16 so I could get the new kernel to auto-align them with the ssd blocks.

edit: from x86-64 install DVD

Last edited by Puff65537; 5th May 2012 at 09:30 AM. Reason: add info
Reply With Quote
Reply

Tags
devices, discard, f17, luks or dmcrypt, support, trim

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora 16 and Discard (TRIM) support on LUKS/dm-crypt devices NoHumanBeing F16 Development 9 19th September 2011 07:52 PM
how to remove boot mount of dm-crypt LUKS md1 skiffx Security and Privacy 11 24th December 2009 05:40 AM
crypt-luks drive is 0.9 GB short in size patemos Security and Privacy 2 7th November 2009 07:43 PM
dm-crypt luks & lvm Full system encryption?? any joy anybody techie-munkey Security and Privacy 1 5th March 2007 02:39 PM
mini-HOWTO encrypt devices using dm-crypt and LUKS. raoul Links 2 23rd September 2005 07:22 PM


Current GMT-time: 19:55 (Tuesday, 21-10-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Sidi Amrane - Wodzislaw Slaski Instagram Photos - Sakhipur Travel Photos on Instagram