Showing posts with label mount. Show all posts
Showing posts with label mount. Show all posts

Tuesday, July 12, 2016

How to resize the tmpfs (/dev/shm) in Linux

There are times when the tmp file system may become full and a need arises for resizing (or increasing the size) of the file system. This can be achieved in two ways, one is to make the change temporarily without rebooting the host; the other is to make the change permanently so that everytime the host is rebooted, the tmp file system is mounted with the modified size.

Note that the size of tmp file system can be increased to a certain predefined limit. If the size specified during mount/resize(remount) is beyond the set limit, the mount would fail and the tmp file system will not be mounted.

To view the current size of the tmp file system, the following command can be run.

~]# df -h

The output would show something like below.

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              91G   26G   61G  30% /
tmpfs                 1.9G  107M  1.8G   6% /dev/shm

  • Increasing/resizing the file system temporarily:
    The following command can be run to remount the tmp file system with an increased size.

    ~]# mount -o remount,resize=4g /dev/shm
    ~]#

  • Making the size change persist across reboot:
    To make the change persist across reboot, the entry for mounting the tmp file system in the file /etc/fstab must be modified as shown below.

    ~]# vim /etc/fstab
    #
    # /etc/fstab
    # Created by anaconda on Mon Feb 8 15:28:09 2016
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    tmpfs   /dev/shm  tmpfs  defaults,size=4g  0 0
    devpts  /dev/pts    devpts  gid=5,mode=620  0 0
    sysfs   /sys    sysfs   defaults  0 0
    proc   /proc    proc    defaults  0 0
    ~]#

Once the changes are made (using either approach) run the following command to see that the change in the size.

~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              91G   26G   61G  30% /
tmpfs                 4.0G  107M  3.9G   3% /dev/shm

Monday, April 18, 2016

How to Setup NFS share in Linux

NFS or Network File System is a very convenient way of allowing the data on one Linux host to be accessible on another. The procedure for setting up a NFS share and accessing the same on a client is very simple.

Step 1: Install the nfs utilities and rpcbind (portmap) on the source host.

]# yum install nfs-utils nfs-utils-lib

Step 2: Create a file /etc/exports and enter the following information.

/tmp *(rw,sync,no_root_squash)

In the line above:

/tmp           - The folder to be shared
*              - Allow access to all clients
rw             - Provide read/write access
sync           - The requests are honored only after changes are committed
no_root_squash - Allow root user to access the share

Step 3: Make sure nfs and rpcbind services start at boot. Export the list of shared folders and start these services now.

]# chkconfig rpcbind on
]# chkconfig nfs on

]# exportfs -rv

]# service rpcbind restart
]# service nfs restart

Step 4: To see the list of nfs exports, run:

]# showmount -e localhost

To see the same list from a different host, run:

]# showmount -e <ip address/hostname>

Step 5: Mount and access the contents:

]# mount -t nfs <ipaddress/hostname>:/tmp /mnt/share