How to hide a ramdisk from Finder

diskutilfinderhdiutil

I'm creating ramdisks on MacOS following the usual procedure (ie: diskutil erasevolume HFS+ mydisk after hdiutil attach -nomount ram://SIZEINBLOCKS). They work, but they show up in Finder windows with the usual icon for external drives.

I'm using these ramdisks for development tasks (as disposable drives where I can try builds and easily discard them), so I'd prefer that they don't have a drive unit icon in Finder windows. Is that possible? How?

Best Answer

Try

chflags hidden "/Volumes/RamDisk"

And restart your finder with

killall Finder