"Use A Scratch Disk For Faster Builds", but how?

I read the part "Use A Scratch Disk For Faster Builds" at Tips For Faster Rust Compile Times | corrode Rust Consulting but I cannot understand how to mount that volume in a fresh linux setup.

Can you please help me understand how to do that exactly?

Did you try this?

I added this in my /etc/fstab:

tmpfs	/home/blonk/tmp	tmpfs	nodev,nodiratime,size=16384M	0	0

(And then set target-dir in cargo's config to /home/blonk/tmp/bld/cargo)

1 Like

Thanks, but I think he suggests to avoid tmpfs, right?

Sorry I'm not a Linux expert.

They suggest using a dedicated disk due to large artifacts and the like. If your RAM isn't enough and/or you just want to follow that suggestion, the first step would be obtaining a dedicated disk.

1 Like

Right, sorry -- I just read "faster rust compile times" and "mount" and assumed the suggestion was to use tmpfs.

But the principle is basically the same -- you stick the mount in /etc/fstab. The thing he posted is the options field. You should create a ext4 partition for the scratch data, then add an ext4 entry to /etc/fstab for that partition, but with the added mount options they suggested.

(Note: There may be other ways to add mounts to Linux systems, but I assume you're using a mainstream distro).

With all that said, I strongly disagree with the tip not to use a tmpfs. The only time it has caused me problems is when I build many large crates without a cargo clean between builds. But if you're looking to have faster builds and avoid wear and tear on your persistent storage, then use a tmpfs.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.