copyright | lastupdated | keywords | subcollection | content-type | services | account-plan | completion-time | ||
---|---|---|---|---|---|---|---|---|---|
|
2025-03-21 |
File Storage for Classic, NFS, mounting File Storage, mounting storage on Ubuntu, |
FileStorage |
tutorial |
paid |
1h |
{{site.data.keyword.attribute-definition-list}}
{: #mountingUbuntu} {: toc-content-type="tutorial"} {: toc-services=""} {: toc-completion-time="1h"}
Use these instructions to connect an Ubuntu Linux®-based {{site.data.keyword.cloud}} Compute instance to a Network File System (NFS) share. For more information about how to order {{site.data.keyword.filestorage_full}}, see the Getting started tutorial. {: shortdesc}
Before you begin, make sure that the host that is to access the {{site.data.keyword.filestorage_short}} volume is authorized. For more information, see Authorizing the host in the console{: ui}Authorizing the host from the CLI{: cli}Authorizing the host with Terraform{: terraform}. {: requirement}
{: #mountUbuntu}
-
Update and upgrade the distribution:
apt update && apt upgrade
{: pre}
-
Install the required tools.
apt-get install nfs-common
{: pre}
-
Create a
/mnt/nfs
directory.mkdir -p /mnt/nfs
{: pre}
-
Restart your instance:
reboot
{: pre}
-
Mount the remote share.
mount -t nfs -o <options> <host:/mount_point> /mnt
Example for
storage_as_a_service
volumes.#mount -t nfs -o nfsvers=3 fsf-wdc0403a-fz.service.softlayer.com:/IBM02SEV1414935_66/data01 /mnt
Example for
enterprise
volumes.# mount -t nfs -o nfsvers=3 nfshou0201d-fz.service.softlayer.com:/IBM01SEV1414935_2 /mnt
The mount point information can be obtained from the {{site.data.keyword.filestorage_short}} Details page in the console, with an API call -
SoftLayer_Network_Storage::getNetworkMountAddress()
, or by looking at theibm_storage_file
resource in Terraform. {: tip} -
Verify that the mount was successful by using the disk file system command.
# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda2 25G 1.4G 22G 6% / /tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/xvda1 97M 51M 42M 55%
-
Go to the mount point, and read/write files.
# touch /mnt/test # ls -la /mnt total 12 drwxr-xr-x 2 nobody nobody 4096 Sep 8 15:52 . dr-xr-xr-x. 22 root root 4096 Sep 8 14:30 .. -rw-r--r-- 1 nobody nobody 0 Sep 8 15:52 test
-
Make the configuration persistent by editing the file systems table (
/etc/fstab
). Add the remote share to the list of entries that are automatically mounted on startup:sudo nano /etc/fstab
Add a line with the following syntax to the end of the file.
(hostname):/(mount_point) /mnt nfs_version defaults 0 0
Example
nfsdal1301a.service.softlayer.com:/IBM01SV278685_7 /mnt nfsvers=3 defaults 0 0
-
Verify that the configuration file has no errors.
# mount -fav
{: pre}
If the command completes with no errors, your setup is complete.
If you're using NFS 4.1, add
sec=sys
to the mount command to prevent file ownership issues. {: tip}
{: #ubuntu-user-group-permissions}
As a system administrator, you can manage the access to data on the mounted file storage volume. After the file share is mounted, you can refine access control by using the chown
and chmod
commands to assign read, write, and execute permissions to individual users and groups. For more information, see the Ubuntu Server documentation about User management{: external}.
{: #umountUbuntu}
To unmount any currently mounted file system on your host, run the umount
command with disk name or mount point name.
umount /dev/sdb
{: pre}
umount /mnt
{: pre}