2011-05-14

tmpfs on Linux and Mac

On Linux and FreeBSD, we can create tmpfs (a file system in RAM / volatile memory).

$ mkdir /tmp/space
$ sudo mount -t tmpfs -o size=128M,mode=777 tmpfs /tmp/space
...
...
$ sudo umount /tmp/space

mount command of Mac doesn't support tmpfs. But I knew that hdid command can create file space in RAM disc.

$ hdid -nomount ram://256000  # 256000 (sector) * 512 (bytes/sector)
/dev/disk1
$ newfs_hfs /dev/disk1
Initialized /dev/rdisk1 as a 125 MB HFS Plus volume
$ mkdir /tmp/space
$ mount -t hfs /dev/disk1 /tmp/space
...
...
$ umount /tmp/space/
$ hdiutil detach /dev/disk1 
"disk1" unmounted.
"disk1" ejected.

tmpfs provides high-speed access performance. And it contributes to increase the lifespan of HDD or SSD.

I don't use SSD (Solid-state drive) just yet. The high-speed access performance is attractive, but the fragility is main fear. When the reliability improve, I want to use it and all HDDs are replaced by SSD.

Thanks.

0 comments:

Post a Comment