Skip to main content
Topic: how to defrag f2fs file system at startup (Read 1039 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

how to defrag f2fs file system at startup

Hello guys  :D played with f2fs file system and after testing it few days it looks like there are small performance loss over time and i defrag it after booting into a live session umount disks and # defrag.f2fs /devsdx .Something looked like they fixed stuff on my home and root partitions where i use f2fs. My question is, can this defrag process take place at startup so every restart i will have the best performance f2fs can give? I'm on runit init so how can this be achieved and if it's possible altogether. Regards and have  an amazing day!

Re: how to defrag f2fs file system at startup

Reply #1
Maybe you can put a script named defrag.start that does that on /etc/local.d. It'll be called after the disks are mounted, but before runit actually starts the services. (any executable file with a name ending in .start in that folder will).

Re: how to defrag f2fs file system at startup

Reply #2
I think it's not possible due to the fact that f2fs defrag must be done on unmounted partitions. Unless that script after is loaded into memory unmount partitions again to perform defrag and then mount all the stuff back after it finishes


Re: how to defrag f2fs file system at startup

Reply #4
Wow, i knew it must be something hard core to deal with this one. I better leave it for now as i don't really know the security impact making a script running at that critical moment of the boot. Thanks for the solution @strajder  and @capezotte, i must read more about this hope i can get it done in the end.

 

Re: how to defrag f2fs file system at startup

Reply #5
https://wiki.archlinux.org/title/F2FS
Looks like it (should?) get fsck'ed at boot as std, mkinitcpio has a fsck hook, enabled in /etc/mkinitcpio.conf:
https://wiki.archlinux.org/title/Fsck
I already have a hook for BTRFS, which could be looked at as an example, I guess you could add a similar custom script in that dir:
Code: [Select]
$ pacman -Qo /usr/lib/initcpio/hooks/btrfs 
/usr/lib/initcpio/hooks/btrfs is owned by btrfs-progs 5.12.1-1
For some reason the f2fs-tools package does not have an equivalent hook.