Btrfs auto defragmentation Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
mgrddsj
Posts: 4
Joined: Wed Feb 19, 2020 11:46 am

Btrfs auto defragmentation

Post by mgrddsj »

Hi, I bought a hard drive and formatted it to Btrfs in order to make it a NAS server. :D
Btrfs has this nice feature to automatically defrag the hard drive, and it can be turned on in the mounting option. ;)
(See #2 in https://www.thegeekdiary.com/how-to-tun ... rformance/)

My question is, is this option enabled by default in dietpi-drive_manager? Or do I have to manually mount the drive to enable that option?
Raspberry Pi 3
User avatar
Joulinar
Posts: 2269
Joined: Sat Nov 16, 2019 12:49 am

Re: Btrfs auto defragmentation

Post by Joulinar »

Hi,

I don't think it will be added by default.

However you could use Drive Manager to mount your hdd and check mount options afterwards on /etc/fstab and try to add your option if needed.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 2323
Joined: Sat Nov 18, 2017 6:21 pm

Re: Btrfs auto defragmentation

Post by MichaIng »

Indeed not added by default currently, also not applicable on non-spinning drives, but good to know this exists. Edit /etc/fstab for now, but note that or is overwritten on every drive manager run.

I'll add the option to v6.29, either as default on spinning drives or optional to toggle in UI.
mgrddsj
Posts: 4
Joined: Wed Feb 19, 2020 11:46 am

Re: Btrfs auto defragmentation

Post by mgrddsj »

MichaIng wrote: Wed Feb 19, 2020 1:23 pm Indeed not added by default currently, also not applicable on non-spinning drives, but good to know this exists. Edit /etc/fstab for now, but note that or is overwritten on every drive manager run.

I'll add the option to v6.29, either as default on spinning drives or optional to toggle in UI.
Thank you very much for replying!
I'm so excited to see it in future updates!
Raspberry Pi 3
User avatar
MichaIng
Site Admin
Posts: 2323
Joined: Sat Nov 18, 2017 6:21 pm

Re: Btrfs auto defragmentation

Post by MichaIng »

I read a bid through some man pages and actually autodefrag on BTRFS seems to be generally not recommended currently due to CPU usage and caching that is done and especially with large files. I'll definitely add it as non-default option only with link to related man pages and recommendations.

Do you face any issues that you want this option?
mgrddsj
Posts: 4
Joined: Wed Feb 19, 2020 11:46 am

Re: Btrfs auto defragmentation

Post by mgrddsj »

MichaIng wrote: Sun Feb 23, 2020 2:37 pm I read a bid through some man pages and actually autodefrag on BTRFS seems to be generally not recommended currently due to CPU usage and caching that is done and especially with large files. I'll definitely add it as non-default option only with link to related man pages and recommendations.

Do you face any issues that you want this option?
I didn't face any issues yet, but I'm dealing with a HDD and thought defrag may make it perform better.
Raspberry Pi 3
User avatar
WarHawk
Posts: 619
Joined: Thu Jul 20, 2017 8:55 am

Re: Btrfs auto defragmentation

Post by WarHawk »

Will the command line defragment it?

https://docs.oracle.com/en/operating-sy ... btrfs.html

I guess it would be the mount point
# btrfs filesystem defragment filesystem_name

Also read up on it...until the drive/drives get really full does it really start causing fragmentation
https://serverfault.com/questions/51985 ... ment-files

I ran the command on my Orange Pi PC running openmediavault with a 1TB laptop drive
# btrfs balance start /srv/drive~~~~

Just make sure you run it on a mounted btrfs filesystem

Here are the "gotchas" on a btrfs system
https://btrfs.wiki.kernel.org/index.php ... gmentation
https://btrfs.wiki.kernel.org/index.php ... y_files.3F
mgrddsj
Posts: 4
Joined: Wed Feb 19, 2020 11:46 am

Re: Btrfs auto defragmentation

Post by mgrddsj »

WarHawk wrote: Mon Feb 24, 2020 11:47 am Will the command line defragment it?

https://docs.oracle.com/en/operating-sy ... btrfs.html

I guess it would be the mount point
# btrfs filesystem defragment filesystem_name

Also read up on it...until the drive/drives get really full does it really start causing fragmentation
https://serverfault.com/questions/51985 ... ment-files

I ran the command on my Orange Pi PC running openmediavault with a 1TB laptop drive
# btrfs balance start /srv/drive~~~~

Just make sure you run it on a mounted btrfs filesystem

Here are the "gotchas" on a btrfs system
https://btrfs.wiki.kernel.org/index.php ... gmentation
https://btrfs.wiki.kernel.org/index.php ... y_files.3F
Yeah it seems like that commands works. Good enough for me. And according to those "gotchas", I guess I'll do it manually when necessary. Thanks for the reply and suggestions!
Raspberry Pi 3
Post Reply