De-frag hard drive?

70 Tango Charlie

Well-Known Member
Joined
Oct 7, 2019
Messages
523
Reaction score
676
Credits
2,064
Greetings everyone,
Seeing that I was a Windows guy for lots of years, de-fragging the hard-drive every so often was recommended.
Since coming to Linux, I have not seen anything at all about de-fragging.
Am I coming to the right conclusion that there is no need to de-frag; and is this because of the way the file system is set up?
Thanks from the old geezer
TC
 


Running Linux Mint 18.3 for 5 years ....spaced across 3 hard drives....haven't defragged one of them in that time, and have no need to do so.
 
Thanks for the responses guys. That confirms my guesses.
I get a kick out of trying to figure stuff out. Looking back on my life, that seems to be the way I have always been. It's the way I have learned how to operate the cp. {start pushing buttons and see what happens} The biggest problem with that is remembering which buttons I pushed to get the result I got! LOL.
Old Geezer
TC
 
Somewhat likewise here.....(remembering what I typed to achieve a particular result).....

I had to go back to a topic dated May, 2018 to remind myself how to "trim" a SSD !!!!

Haven't done it for a while...it took care of 3.8 GB !!

(This only applies to Solid State Drives)
 
When your hard disk reads the file, its heads must skip around between different physical locations on the hard drive to read each chunk of sectors — this slows things down. Defragmenting is an intensive process that moves the bits of files around to reduce fragmentation, ensuring each file is contiguous on the drive
 
Thanks for the responses guys. That confirms my guesses.
I get a kick out of trying to figure stuff out. Looking back on my life, that seems to be the way I have always been. It's the way I have learned how to operate the cp. {start pushing buttons and see what happens} The biggest problem with that is remembering which buttons I pushed to get the result I got! LOL.
Old Geezer
TC
me 2 ; i write everything down
 
The way the GNU/Linux File System works you don't really need to de-frag your hard drive. In face if you're running an SSD you should NEVER de-frag since it puts unnecessary ware and tear on the drive.
 
If you feel like you must do something, do an fsck on the partition(s). If it finds errors, it will attempt to fix. Otherwise, it will just say that everything is "clean".

And it will be!
 
No need to defrag, usually.
We are a spoiled bunch, aren't we?
 
As others have said, you don't need to defrag with Linux because Linux isn't Windoze and thank God for that.
 
Actually, I'm pretty sure most modern Linux distros install a TRIM run out of the box, and typically configurable if you don't like the default run period. This is what mine looks like under Kubuntu 20.04.1:
Code:
john@john-Desktop:/etc$ systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
     Loaded: loaded (/lib/systemd/system/fstrim.timer; enabled; vendor preset: enabled)
     Active: active (waiting) since Sun 2020-11-01 06:54:43 CST; 12h ago
    Trigger: Mon 2020-11-02 00:00:00 CST; 4h 37min left
   Triggers: ● fstrim.service
       Docs: man:fstrim

Nov 01 06:54:43 john-Desktop systemd[1]: Started Discard unused blocks once a week.
And this is how it's set up:
Code:
john@john-Desktop:/etc$ systemctl cat fstrim.service
# /lib/systemd/system/fstrim.service
[Unit]
Description=Discard unused blocks on filesystems from /etc/fstab
Documentation=man:fstrim(8)
ConditionVirtualization=!container

[Service]
Type=oneshot
ExecStart=/sbin/fstrim --fstab --verbose --quiet
ProtectSystem=strict
ProtectHome=yes
PrivateDevices=no
PrivateNetwork=yes
PrivateUsers=no
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
MemoryDenyWriteExecute=yes
SystemCallFilter=@default @file-system @basic-io @system-service
 
I do think they use trim also. I just like to do it manually from time to time to make sure.
 
Umm, yes, like I said ;)
 
I have Trim set to daily on my SSD but I will from time to time do it manually with this...
Code:
 sudo fstrim -av

Manually it looks like this when done...
/: 245 GiB (263098654720 bytes) trimmed

:)
 

Members online


Top