Any way to avoid needing to defrag my SSD?

First of all, I know you’re not meant to defrag SSDs!.. but hear me out.

I have a device called the iODD 2531 (which is a re-badge of, or the original version of the Zalman VE350). It’s an external enclosure for 2.5" disks, that connects via USB, and that can be used as a plain old external storage device, along with being able to act as a virtual optical drive and thumb drive(s). It can mount any ISO stored in a specific folder, as if it were a physical disc.

The problem I’m having though, and the reason for my question is that, in order to mount an ISO properly, the .iso file must not be fragmented on the disk. Most of the time this doesn’t present a problem but sometimes, it means that I have to defrag the disk in order to make the ISO contiguous (I think that’s the right word) and thus, mountable.

Surely there’s a better way though?

I guess what I’m asking is, is there a way of writing files to an SSD that will avoid the need to defrag?.. preferably on Linux.

… Wait, you’ve never heard of Linux native .iso mounting capabilities with a loopback device?

Just do the following two-step process in the command line:

$ sudo mkdir /media/iso
$ sudo mount -o loop file.iso /media/iso

Do the first line only if the directory does not exist yet. Now you should be good to go.

Otherwise, here is what you are asking for, though I think you are jumping over the river for water…

$ rsync -I --preallocate my-disc.iso /path/to/destination/folder
$ filefrag /path/to/destination/folder/my-disc.iso #(To verify, eq to 1 extent)

This may fail if your drive does not have enough continuous space, however, at which point you must defrag regardless. Another weakness is that some sectors may be damaged on your SSD drive at which point a continuous copy will not work. So I would recommend loopback as a first option.

6 Likes

says who? :smiley: - I must have been doing it wrong for 2 decades

2 Likes

The firmware on that external enclosure with proprietary software on it

2 Likes

Oh, the exceptionally shoddy firmware of the Zalman VE350, got it.

Does fragmentation makes sense on flash media? Its not like you’re dealing with hdd needles being tortured by accessing data in different cylinders.

1 Like

It makes no sense at all, but that didn’t stop the CS grads at Zalman from turning dreams into proprietary miracles.

https://ma.ttwagner.com/zalman-ve400-review/

The thing is fairly intolerant of filesystem fragmentation. I thought NTFS was supposed to somewhat reduce the impact of fragmentation. And I have an SSD inside, which doesn’t exactly require fragmentation, since seeks are practically free. But after filling this thing 2/3 of the way, I started getting an error, “>> DEFRAG <<“, whenever I tried to mount the latest ISO file. There is no documentation that seems to cover this, but it was clear what I had to do—defragment my solid-state drive, running NTFS, through Linux. (The “solution” to this, BTW, is to copy everything off of the drive, reformat it as a new NTFS filesystem, and copy everything back.) It was just incapable of reading the fragmented ISO.

OP, unless someone at hackaday managed to put Arch on it, you’re out of luck.

2 Likes

Sorry, I wasn’t clear. The external enclosure mounts ISOs so that you can boot from them. No more burning discs / future coasters, or using external applications to write files to thumb drives. You just copy the ISO to the _iso folder, and Bob’s your mother’s brother.

It’s also meant to have write protection capabilities, so you can plug it into infected devices but I’m not brave enough for that sort of thing… that’s when spinning rust plastic comes in handy.

I’ll give that a go and see how I get on. Thank you.

It’s my understanding that data fragmentation on SSDs actually improves their speed as the data is spread across multiple DRAM dies that can be read from and written to in parallel.

Doesn’t look like they have yet… probably too busy trying to get Doom to run on it.

2 Likes

Grub can do that for a lot of isos without any special requirements, though it does need the right linux and initrd commands for the distro. I boot isos from my downloads folder, no copy required.

One can install Ventoy to an external drive to achieve a similar result to your enclosure; just copy and reboot. It knows the quirks of hundreds of distros.

If you have a 10MB file - and its contiguous (IE: not fragmented) - you can issue multiple large read operations to read the file. If a file is split into tiny fragments (say 4kb sectors), then you’ll need to issue lots of tiny reads to read the entire file. So heavily fragmented files will require more IO operations, which will reduce performance on SSDs (SSDs have limited IOPs, especially SATA SSDs). This means de-fragmenting a SSD can make sense.

However modern filesystems (including NTFS) do a great job at avoiding fragmentation. Except when the filesystems get really full (>90%), in which case it doesn’t have enough free space to prevent fragmentation. So in practise SSDs don’t need defragmentation, even a little bit of fragmentation in things like log files aren’t really an issue. Just make sure you keep your disks at >20% free space to be sure.

(An interesting aside is that ZFS’s copy on write nature actually causes quite a bit of fragmentation. But in practise it does enough caching and prefetching to reduce performance issues.).

Another interesting aside. ZFS does not have defragmentation even if you wanted to. SSD, HDD does not matter.

It is a hardware precursor to ventoy.

With a screen and a selector so you can choose which iso it is imitating, before you use it to boot.

Literally the same idea, done different

1 Like

There are a lot of people here suggesting software bootloader alternatives, but you have to realize that this sort of ISO emulator is super useful for old systems or old OSes that can’t/don’t liek to boot over USB. There are ISOs of Windows PE and some versions of Embedded that use features of the ISO-9660 boot sector/etc that make them only bootable from either actual media or an emulated drive of some sort.

I just had to deal with this for installing an old version of Windows Embedded POSReady onto a Wincor-Nixdorf POS PC for use with some development tools, since the software is ancient and the powered +24V/+12V USB makes connecting programmers/etc more convenient. No ODD and Embedded/POSReady will not easily boot from USB.

Just a public service announcement.

1 Like