Welcome to Machine Unix

Search Below

How To Create a Ramdisk For Your Solaris Zone

Following entry is an example of how one might want to create a ramdisk for a Solaris Zone from the global system. Ramdisks can be used for many purposes due  to their fast access and nonvolatile nature. To create a Ramdisk in Solaris, we can use “ramdiskadm” command. What I am going to do is to create a 300M of Ramdisk called my_volatile from the global zone, and mount it under one of my development zones. Since the zone itself resides on ZFS, creating and mounting the ramdisk is a snap.

root@solu9# ramdiskadm -a my_volatile 300m

/dev/ramdisk/my_volatile

To list the available ramdisks, you can just use ramdiskadm command without any options:

root@solu9# ramdiskadm
Block Device                                                                  Size  Removable
/dev/ramdisk/my_volatile                                 314572800    Yes

So now, from the global zone:

root@solu9# zpool create mytmpfs /dev/ramdisk/my_volatile

root@solu9# df -h
….
…..
mytmpfs                262M    21K   262M     1%    /mytmpfs

Great, so now I can go ahead and mount it on the zone I want:

root@solu9# zfs create mytmpfs/tmpfs
root@solu9# zfs set mountpoint=/zones/zdev/root/tmpfs mytmpfs/tmpfs

I can login to my zone and check my newly created ramdisk specifically for the zone:

root@solu9# zlogin zdev
[Connected to zone ‘zdev’ pts/5]
Last login: Sun Apr 10 18:04:51 on pts/4
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
root@zdev# df -h
Filesystem             size   used  avail capacity  Mounted on
/                              72G   100M    72G     1%    /
/dev                       72G   100M    72G     1%    /dev
/lib                        76G   4.2G    72G     6%      /lib
/platform            76G   4.2G    72G     6%       /platform
/sbin                    76G   4.2G    72G     6%       /sbin
/usr                     76G   4.2G    72G     6%        /usr
proc                       0K      0K       0K    0%       /proc
ctfs                      0K     0K     0K     0%           /system/contract
mnttab               0K     0K     0K     0%           /etc/mnttab
objfs                   0K     0K     0K     0%           /system/object
swap                1.2G   328K   1.2G     1%       /etc/svc/volatile
/usr/lib/libc/libc_hwcap1.so.1
76G   4.2G    72G     6%    /lib/libc.so.1
fd                              0K     0K     0K     0%        /dev/fd
swap                         1.2G    36K   1.2G     1%      /tmp
swap                         1.2G    24K   1.2G     1%      /var/run
mytmpfs/tmpfs  262M    21K   262M     1%    /tmpfs

Now I have a /tmpfs which is around 300M. The size of the ramdisk will depend on the hardware implementation. Since it’s a volatile piece of software implementation of a hardware, the next time you reboot your zone, it won’t be there and you won’t see it as mounted.