Fragmentation of modules on NTFS hard drive

Technical issues/questions of an intermediate or advanced nature.
Rapha_
Shogun
Shogun
Posts: 238
Joined: 12 Jun 2021, 21:59
Distribution: Xfce 4.12 - 5.rc3 - x86_64
Location: France

Fragmentation of modules on NTFS hard drive

Post#1 by Rapha_ » 14 Nov 2021, 22:23

Not a question but an observation

Be careful if you share an NTFS* hard drive with MS Windows and Porteus as it can fragment your files from Linux

My disk is very full [70% - 80%] and I have to defragment regularly. Because I notice that my modules saved from Porteus split into small pieces
I use Defragler on Windows, which allows me to choose the files I want to defragment (the biggest or the most fragmented), decrease the number of free spaces etc...

*I think the problem is the same on the small USB keys formatted in Fat32

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Fragmentation of modules on NTFS hard drive

Post#2 by Ed_P » 15 Nov 2021, 00:46

Rapha_ wrote:
14 Nov 2021, 22:23
*I think the problem is the same on the small USB keys formatted in Fat32
And probably on larger USB keys formatted in exFAT.

Are you saying ext2-4 formatted drives don't fragment files?

Are there any Linux apps that defrag drives?

I use DiskDefrag 8.0.23 in Windows, which defrags files on hard drives and SSD drives.


-Update-
Rapha_ wrote:
14 Nov 2021, 22:23
My disk is very full [70% - 80%] and I have to defragment regularly.
Be sure to do a Windows Disk Cleanup.

Code: Select all

echo  Do Start ^> All apps ^> Windows Administrative Tools ^> Disk Cleanup ^> OK 
echo   ^> Clean up system files ^> OK 
echo   ^> More Options ^> System Restore and Shadow Copies ^> Clean up ^> Delete ^> OK
echo   ^> Delete files
echo.
echo  * A Windows Update Cleanup can take an **HOUR**!! 

And delete .tmp files as Admin.

Code: Select all

:: Check for Run as Admin
:: https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights
net sessions >nul 2>&1
if %errorLevel% == 0 (
    echo  Running as Admin. Yeah!!
 ) else (
    echo.
    echo  Deleting .tmp files more effective when run as Admin.
    pause > nul
 )

Code: Select all

echo  Deleting AppData Temp files 
::for /d %%d in (dir %_drv1%\"Users\%_user%\AppData\Local"\{*. /b)       do if "%%d" neq "dir" if "%%d" neq "/b" rmdir "%%d" /q /s > nul
for /d %%d in (dir %_drv1%\"Users\%_user%\AppData\Local\Temp"\*.*. /b) do if "%%d" neq "dir" if "%%d" neq "/b" rmdir "%%d" /q /s > nul
del                %_drv1%\"Users\%_user%\AppData\Local\Temp"\*.tmp                  /q /f    > nul
del                %_drv1%\"Users\%_user%\AppData\Roaming\U3"\*.*                    /q /f /s > nul
::del                %_drv1%\"Users\%_user%\AppData\Local\Edge\User Data\Default\JumpListIcons\RecentClosed"\*.tmp           /q /f > nul
del                %_drv1%\"Users\%_user%\AppData\Local\Packages\Microsoft.MicrosoftEdge*"\*.tmp                           /q /s > nul
del                %_drv1%\"Users\%_user%\AppData\Local\Packages\*"\*.tmp                                                  /q /s > nul
echo  Deleting %_drv1%\*.tmp files
del %_drv1%\*.tmp  
del %systemroot%\*.tmp
del %systemroot%\system32\*.tmp
del %systemroot%\temp\*.tmp  
Ed

fulalas
DEV Team
DEV Team
Posts: 2050
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Fragmentation of modules on NTFS hard drive

Post#3 by fulalas » 15 Nov 2021, 01:18

Is fragmentation an issue on non-disc units? I don't think so. Even on discs, the performance hit should be really minimal.

User avatar
babam
Warlord
Warlord
Posts: 526
Joined: 16 Nov 2016, 10:30
Distribution: Porteus 5.0rc3 Xfce K6.1.1
Location: Rainy city

Fragmentation of modules on NTFS hard drive

Post#4 by babam » 15 Nov 2021, 08:27

fulalas wrote:
15 Nov 2021, 01:18
Is fragmentation an issue on non-disc units? I don't think so. Even on discs, the performance hit should be really minimal.
In my case, grub4dos/grub4uefi could not boot if the Iso file was not-contiguous/fragmented.
Sorry, my English is bad.

Rapha_
Shogun
Shogun
Posts: 238
Joined: 12 Jun 2021, 21:59
Distribution: Xfce 4.12 - 5.rc3 - x86_64
Location: France

Fragmentation of modules on NTFS hard drive

Post#5 by Rapha_ » 15 Nov 2021, 14:57

Ed_P wrote:
15 Nov 2021, 00:46
Are you saying ext2-4 formatted drives don't fragment files?
From what I understand, in linux partitions (ext2/3/4) there is much less fragmentation because it is better managed: the files are saved in priority in a contiguous way, separated with space from the others and distributed on the whole disk.
Ed_P wrote:
15 Nov 2021, 00:46
which defrags files ...and SSD drives.
I read that you shouldn't do it too much because it wears out the memory device (SSD)
Ed_P wrote:
15 Nov 2021, 00:46
Be sure to do a Windows Disk Cleanup.
I use BleachBit (Portable) who do a good job. Softwares and data (on 2 différents partitions)

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Fragmentation of modules on NTFS hard drive

Post#6 by Ed_P » 15 Nov 2021, 18:16

After you run BleachBit Rapha_ try running the Windows Disk Cleanup's Windows Update Cleanup and see how much space it projects. Let me know what it shows.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Fragmentation of modules on NTFS hard drive

Post#7 by Rava » 17 Nov 2021, 18:32

Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Fragmentation of modules on NTFS hard drive

Post#8 by Ed_P » 17 Nov 2021, 23:14

An interesting link Rava. Thank you.
Ed

Rapha_
Shogun
Shogun
Posts: 238
Joined: 12 Jun 2021, 21:59
Distribution: Xfce 4.12 - 5.rc3 - x86_64
Location: France

Fragmentation of modules on NTFS hard drive

Post#9 by Rapha_ » 20 Nov 2021, 01:26

Ed_P wrote:
15 Nov 2021, 18:16
After you run BleachBit Rapha_ try running the Windows Disk Cleanup's Windows Update Cleanup and see how much space it projects. Let me know what it shows.
I use Win XP, the only thing it offers me is to compress files that I haven't used for a while...but I don't want that !
I've been doing some cleanup myself by deleting the big files I don't use, then defragmented the files and very importantly, I've reduced the free space between them
Ed_P wrote:
15 Nov 2021, 00:46
Are there any Linux apps that defrag drives?
Yes, I have tried on my laptop computer e4defrag (defragmenter for ext4 file system) :
https://man7.org/linux/man-pages/man8/e4defrag.8.html

Although practically empty, with only Porteus installed, I had some modules divided into two parts...

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Fragmentation of modules on NTFS hard drive

Post#10 by Rava » 20 Nov 2021, 08:44

Rapha_ wrote:
20 Nov 2021, 01:26
I use Win XP
I hope you never go online with that OS? Due to no security fixes available for years now.
I have even several XP professional original CDs with the original Windoze Certificates and Windoze ID… but usually if I would use Windoze any software I could be interested in would demand at least W7 if not W10…
But having no Windoze at all and only Linux is a bliss. :D

Added in 6 minutes 7 seconds:
Rapha_ wrote:
20 Nov 2021, 01:26
Yes, I have tried on my laptop computer e4defrag (defragmenter for ext4 file system) :
https://man7.org/linux/man-pages/man8/e4defrag.8.html
At least in Porteus 5.0rc3 we have it:

Code: Select all

root@porteus:~# e4defrag
e4defrag 1.46.4 (18-Aug-2021)
Usage	: e4defrag [-v] file...| directory...| device...
	: e4defrag  -c  file...| directory...| device...
:D

Info here:
https://askubuntu.com/questions/221079/ ... tem#620966

Added in 3 minutes 5 seconds:
Question: why does e4defrag print its version info but e.g. fsck.ext2 aka e2fsck refuses doing so:

Code: Select all

root@porteus:~# fsck.ext2 
Usage: /sbin/e2fsck [-panyrcdfktvDFV] [-b superblock] [-B blocksize]
		[-l|-L bad_blocks_file] [-C fd] [-j external_journal]
		[-E extended-options] [-z undo_file] device

Emergency help:
 -p                   Automatic repair (no questions)
 -n                   Make no changes to the filesystem
 -y                   Assume "yes" to all questions
 -c                   Check for bad blocks and add them to the badblock list
 -f                   Force checking even if filesystem is marked clean
 -v                   Be verbose
 -b superblock        Use alternative superblock
 -B blocksize         Force blocksize when looking for superblock
 -j external_journal  Set location of the external journal
 -l bad_blocks_file   Add to badblocks list
 -L bad_blocks_file   Set badblocks list
 -z undo_file         Create an undo file
Nope, no version info:

Code: Select all

root@porteus:~# fsck.ext2 -version
/sbin/e2fsck: invalid option -- 'e'
root@porteus:~# fsck.ext2 --version
/sbin/e2fsck: invalid option -- '-'
Whyyyyy? :cry:
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Fragmentation of modules on NTFS hard drive

Post#11 by Ed_P » 20 Nov 2021, 15:47

All this Windows XP talk reminds me of the Bart PE and 911 CD days. A good forum and good memories.
Rava wrote:
20 Nov 2021, 08:54
At least in Porteus 5.0rc3 we have it:
:o Did not expect that.
Ed

donald
Full of knowledge
Full of knowledge
Posts: 2064
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

Fragmentation of modules on NTFS hard drive

Post#12 by donald » 20 Nov 2021, 16:18

Rava wrote:
20 Nov 2021, 08:54
Question: why does e4defrag print its version info but e.g. fsck.ext2 aka e2fsck refuses doing so:
Whyyyyy? :cry:

Code: Select all

root@porteus:/# fsck.ext2 -V
e2fsck 1.43.1 (08-Jun-2016)
	Using EXT2FS Library version 1.43.1, 08-Jun-2016

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Fragmentation of modules on NTFS hard drive

Post#13 by Rava » 20 Nov 2021, 21:08

donald wrote:
20 Nov 2021, 16:18

Code: Select all

root@porteus:/# fsck.ext2 -V
e2fsck 1.43.1 (08-Jun-2016)
	Using EXT2FS Library version 1.43.1, 08-Jun-2016
Okay, now I jump behind a train, or into a very warm and shallow creek on a hot summer day, or out of the window of the basement. :D

Added in 3 minutes 54 seconds:
Anyhow, this page
https://askubuntu.com/questions/221079/ ... tem#620966
also has this info:
Use Gparted to defrag your file system

If you have enough space on your hard drive, you can use Gparted to defrag your file system (ext2, ext 4, nfts, etc.). You have to boot from a CD/DVD/USB boot disc because the drive you're working on has to be unmounted. You also have to have more unused space available than used space for this to work and it may take a while.

● Boot from a boot disc.
● Run gparted and shrink the partition that contains the data you want to defrag to just over the amount of your data.
● Make sure the partition you want to defrag is the last partition on the drive by moving it to the end (you may have to create another blank partition in front of it if there's only one partition on the drive).

With the partition you want to defrag as the last partition on the drive:

● grow the partition to the left of it to maximum size. This will move your partitions data to the end of the drive.
● Once it's done, shrink that partition back to it's previous size.
● If you created a blank partition to have more than one on the disc, you can now delete it.
● Move your partitions back into the original order and regrow the partition you wanted defragged back to it's full size.

It's now defragged.
Sounds quite complex, I never did a defragmentation like that.
What do you folks think of this approach?
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Fragmentation of modules on NTFS hard drive

Post#14 by Ed_P » 21 Nov 2021, 04:53

Rava wrote:
20 Nov 2021, 21:12
What do you folks think of this approach?
This sounds quicker:
1. Copy all files on the drive to be defrag to another drive.
2. Format the drive to be defraged.
3. Copy all files back to the original drive.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Fragmentation of modules on NTFS hard drive

Post#15 by Rava » 21 Nov 2021, 05:01

Ed_P wrote:
21 Nov 2021, 04:53
This sounds quicker:
Indeed it does. Especially when you can connect a eSATA or USB3 external drive for doing your approach.

Then there is this:
You also have to have more unused space available than used space for this to work
(highlighting by me)
Who has that on his internal drive?

Added in 57 minutes 13 seconds:
And then we have this:

https://www.ghacks.net/2010/08/11/conve ... 3-to-ext4/
Convert ext2/3 to ext4

Let's say you're a little bit behind the times. You've wanted to do some upgrading of your Linux machines but you've just not really had the time. Or let's say you did do some upgrading of your Linux system but you didn't make any changes to your file system and you're still running a machine with either ext2 or ext3. Now that's not necessarily a bad thing as both file systems work and work well. But let's say you do want to take advantage of some of the features of ext4.

In this article I am going to show you how to migrate your ext2 or ext3 partition to ext4. I will use a Ubuntu machine as an example. I want to warn you that you could lose data by doing this so, following good administrative practices, back up your data! Once you are certain you have that backup of your data, it's time to begin.

Kernel pre-requisite

You must be certain you have a kernel that is at least 2.6.28-11-generic or higher. If not, do NOT continue on with this. To find out what kernel you are running issue the command uname -r. If your kernel is lower than 2.6.28-11 stop where you are and close your browser.
I think closing your browser tab with the above Convert ext2/3 to ext4 link in it is sufficient, no need to close the whole browser. :D
Cheers!
Yours Rava

Post Reply