# Load data from disk to mem, turn off disk?

## ManDay

How would you load everything in / which is stored on a disk into memory and subsequently turn off the (sata) disk (completely)?

----------

## eccerr0r

The computer will tend to read once and never need to use the disk again, so simply trying to read all files once should do the trick.  But if it's still constantly accessing the disk despite you not needing to do any more demand fetches, likely something is trying to write to the disk - and this tends to be the bane of keeping the disk from spinning up and can be painful to find what the culprit/solution is.  Usually it's a logfile being written but not always - stuff like dhcp tables, wtmp entries, and atime updates are common culprits.  And there are more...

----------

## lexflex

 *eccerr0r wrote:*   

> likely something is trying to write to the disk - and this tends to be the bane of keeping the disk from spinning up and can be painful to find what the culprit/solution is.  Usually it's a logfile being written but not always - stuff like dhcp tables, wtmp entries, and atime updates are common culprits.  And there are more...

 

Yeah, it can be hard to make it not wake up at all, but you can reduce the amount of times this happens as eccerr0r suggests.

Some ideas to reduces access that might wake up the disk:

- You can use 'iotop' to get an idea what processes are accessing the disk.

- Also, mounting partitions with 'noatime' can reduces access that might wake up the disk.

You can set sleep/hibernate- timers on your disk using 'hdparm', the way this works varies from disk to disk.

Alex.

----------

## ManDay

So, assuming I can really trust the kernel to use its cached version of the filesystem exclusively, how would you suggest I go about reading all files most efficiently? I'm a bit suspicious as for something like a blunt "find . -exec cat '{}' ';'", or similar...

Regarding the "make sure it never tries to write to disk", a read-only mount should make sure of that, no? That will probably be a problem though, because I wouldn't want to mount / read-only from the start.

To be honest, I was more thinking of some "copy to ramdisk and subsequent rootswitch"-kind-of approach - that would give a "cleaner" cut - I could even umount the spinning disk and take it out of the box, if I wanted...

----------

## eccerr0r

Oh... if that's what you want... yeah I don't see why you couldn't make an initrd that creates a tmpfs that copies a hdd to that tmpfs, unmounts the hdd, and then switch_root's to the tmpfs...  That way, hdd is completely out of the picture and no read/write problems.

Just that there's no persistent data here at all, reboot and all data is gone and you still won't know what files need to be saved...

----------

## ManDay

Hm, I reckoned with certain pitfalls if I just tried that.... But now that you confirm that would work, I'll give it a shot. I think the persistence is less of an issue. I can always rsync the changes back on shutdown, or something like that. Or do it like the live disks and use some unionfs (or can btrfs do that, these days?). Any suggestions?

----------

