Solid State Drives and memory

Hey guys,

So got an interesting topic. I'm watching the crash course computer science playlist on Youtube. It surprisingly goes into quite a lot of depth in certain topics, So far I'm thoroughly enjoying it.

I'm currently at the video on file systems - https://www.youtube.com/watch?v=KN8YgJnShPM&list=PLH2l6uzC4UEW0s7-KewFLBC1D0l6XRfye&index=21

but I have a question, Carrie Ann mentions that each directory such as root,home,documents,etc has a special file called a directory file. This file contains metadata about the files stored in that particular directory such as the size,MAC settings,blocks,etc.

As above, I mentioned blocks. These blocks will be a fixed size with some slack space to take into consideration the possibility of a file getting larger or even smaller. These blocks are also aligned for faster read/write accesses. Now here comes my question(sorry to drag on), when a file is deleted, the actual data inside the file isn't deleted itself but rather the listing for said file is removed from the directory file. So this allows memory recovery tools to recover data on a disk(if the data has not been overwritten of course) but I have also read on many articles that when a file is deleted on an SSD, it's gone forever!

so as you guessed, the above paragraph conflicts. So is data on an SSD, let's assume a text file actually deleted(gone forever) when it is deleted and if so, is my understanding(Carrie Ann's explanation) on how operating systems read/write memory in blocks wrong?

Thanks!
Last edited on
I have also read on many articles that when a file is deleted on an SSD, it's gone forever!
Hmm... SSDs are a special case.
When you access sector 0 of a disk, you're accessing the track closest to the edge of the platter, and when you access sector n - 1 you're accessing the track closes to the center of the platter. This never changes.
To implement wear-leveling, SSDs perform regular internal reorganizations of their free space[1]. If you delete a file and immediately apply TRIM[2], the SSD is free to shuffle the sectors for that file arbitrarily. If you tried to undelete the file, the sectors would appear spread throughout free space. I'm guessing this is what the article meant. If that's not it then I don't know.


[1] Occupied space cannot be reorganized because the file system may contain pointers to physical sectors, and the SSD would have to copy the sector.
[2] TRIM clears the bits in the SSD's internal used sectors bitmap.
Last edited on
^^ I agree. BECAUSE of the limited # of writes (yes, its a very high number these days, but its a lot lower than magnetic disk levels) I can't see that they would wipe the data, but it may be very difficult to find the blocks.
Wear levelling is part of it for sure, but an SSD sector has to be wiped regardless before it can be re-used.

Whereas a magnetic 'bit' on a spinning disk can be arbitrarily flipped between '0' and '1', an SSD bit can only ever go from '1' to '0'.

https://www.extremetech.com/extreme/210492-extremetech-explains-how-do-ssds-work
Would you mind quoting the relevant passage?
Starting to make sense but when the operating system stores a directory file in each directory detailing the properties of the files contained in that directory, so it can actually read/write to the files, is it different with an SSD as opposed to a HDD?

I thought the physical medium, be it a HDD or SSD wouldn't matter, The OS should still store the directory file on the SSD in the same way it would a HDD (obviously not taking into account the physical mechanisms as HDDs are obviously quite different than SSDs).

On an SSD would the operating still store a directory file in each directory? and more importantly when a file is deleted(on an SSD) wouldn't the OS just delete the listing for the file in the same manner it would for a HDD? also when the file is deleted why would the data be erased on the SSD as the OS would be doing the same thing to an SSD as it would to a HDD, right?

thanks guys
when the operating system stores a directory file in each directory detailing the properties of the files contained in that directory, so it can actually read/write to the files, is it different with an SSD as opposed to a HDD?
No. You can image an SSD sector-per-second and write that image to an HDD and it'll work, and vice versa.

when a file is deleted(on an SSD) wouldn't the OS just delete the listing for the file in the same manner it would for a HDD?
Deletion is different. Immediately, yes, the OS will only unlink the file from the file system's data structure and mark those clusters/inodes as free. But to keep the SSD operating efficiently one in a while a TRIM must be performed so the SSD knows which sectors no longer contain data.
The OS can not do this and treat the SSD as if it was an HDD, but its performance will degrade over time.
That makes sense, so the OS doesn't take into consideration what type of physical medium is used, it's abstracted.

So periodically the SSD will do a TRIM as you said to keep it operating efficiently, but how does the SSD actually know which sectors do not contain data? as the OS will not overwrite this section on the SSD

No, the SSD is incapable of performing a TRIM, precisely because it doesn't know which sectors are occupied, only which sectors are free. The OS is the one that does it.
so I'm guessing the OS would detect if the medium was an SSD rather than a HDD, and if so it would perform the TRIM?

thanks Helios
Yes.
Specifically, as far as I know, the OS talks to the drivers, and the drivers talk to the disk hardware. The SSD driver knows what to do, the OS interface to that driver--- I don't think the os can tell that its SSD, RAMDISK, 5.25 inch floppy, or rotating hard disk, or anything else.
Yes, the OS is able to determine the type of device. For example:
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/msft-physicaldisk
(See member MediaType.)
Windows uses the type of device to decide whether to defragment or TRIM the unit. SSDs can be defragmented, but it's very bad for the write endurance. HDDs cannot be TRIMed.
Topic archived. No new replies allowed.