[solved] using fstrim with encrypted filesystem

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

[solved] using fstrim with encrypted filesystem

Postby jiml8 » Oct 17th, '14, 07:11

The SCSI subsystem in my workstation is old and is becoming unreliable. So, I've had a migration route planned, and was prepared to implement it when next I experienced a failure.

Well, that happened Tuesday. A hard drive went down. So I ordered a new Samsung 500 GB SSD, planning to replace the failed HD and one other when the SSD arrived. So it arrived today. I shut down the workstation, plugged in the new SSD along with all the other drives, powered the system back up...and the system hard drive (also a SCSI drive) refused to start. Couldn't get it to power up. So, now, I have a double HD failure to contend with. Happy happy, joy joy.

To make it more fun, the drive that failed Tuesday contained the backup of my system, while the failure today was my system. What fun. My second backup is on my NAS, so I had to get the system from there.

To keep this short, I restored my system from the NAS copy, and now I have my system running on a new SSD. I allocated 30 GB for the system, and the rest is another partition of some 460 GB. It now contains all the contents of both the failed SCSI drives.

Now, I never encrypt my system partition, but I do encrypt everything else. So I have this second partition on my shiny new SSD that is encrypted, and that includes the bulk of the SSD.

How do I make TRIM work with this? Following what I have found on the web, I set up my crypttab to look like this:
Code: Select all
crypt_sdc5 UUID=47141196-6ce9-4119-9fca-8b8025556cae none luks,discard


Also, here is the line from fstab:
Code: Select all
LABEL=SDC5 /mnt/sdc5 ext4 relatime,nofail 0 0


But, when I run "fstrim /mnt/sdc5", I get this:
Code: Select all
fstrim: /mnt/sdc5: FITRIM ioctl failed: Operation not supported

However, "fstrim /" works fine. I therefore infer the problem is due to the encryption.

Now, I have not rebooted since doing this, though I have unmounted sdc5, closed it with cryptsetup luksClose, reopened it, and remounted it (actually, systemd promptly remounted it when I reopened it). Because this is not the root filesystem, I saw no need to use dracut to rebuild the initrd; this partition is not mounted until after the system is running.

So, can some kind soul tell me what is wrong here? I don't see a thing wrong, but something must be.
Last edited by jiml8 on Oct 17th, '14, 23:33, edited 1 time in total.
jiml8
 
Posts: 1254
Joined: Jul 7th, '13, 18:09

Re: using fstrim with encrypted filesystem

Postby doktor5000 » Oct 17th, '14, 21:18

Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18066
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: using fstrim with encrypted filesystem

Postby jiml8 » Oct 17th, '14, 23:16

It turns out that I do have to generate a new initrd and reboot. This was simple enough, I just didn't realize it was necessary for a non-system drive.

Anyway, the solution turns out to be (in addition to the steps described in my first post) to issue the appropriate dracut command as root:
Code: Select all
dracut -f -I /etc/crypttab

and reboot.

No, Doktor. I am not using lvm, just luks.
jiml8
 
Posts: 1254
Joined: Jul 7th, '13, 18:09


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest

cron