KB450231 – CephFS Kernel Mount using Secretfile on Linux Clients
Description:
- This guide will show you how to mount a cephfs filesystem on a linux client using the kernel driver and secret file.
Prerequisites:
- A running Ceph Cluster
- CephFS filesystem running on a Ceph Cluster
- The IP or host-name of one or more Ceph monitors
- Access to a linux client system that is able to connect to the Ceph Cluster through a network
Steps:
Install required packages and dependencies on the linux client system
- The only package required on the client is the ceph-common package and dependencies
For CentOS 7:
root@centos7-45drives:~# cat <<EOF >> /etc/yum.repos.d/ceph_stable.repo
[ceph_stable]
baseurl = http://download.ceph.com/rpm-octopus/el7/$basearch
gpgcheck = 1
gpgkey = https://download.ceph.com/keys/release.asc
name = Ceph Stable $basearch repo priority = 2
[ceph_stable_noarch]
baseurl = http://download.ceph.com/rpm-octopus/el7/noarch
gpgcheck = 1
gpgkey = https://download.ceph.com/keys/release.asc
name = Ceph Stable noarch repo
priority = 2
EOF
root@centos7-45drives:~# yum install ceph-common
For Ubuntu 20.04:
root@ubuntu-45drives:~# vim /etc/apt/source.list
deb https://download.ceph.com/debian-octopus/ focal main
# deb-src https://download.ceph.com/debian-octopus/ focal main
root@ubuntu-45drives:~# apt install ceph-common
Copy secret-client-admin-keyring to client system in secret file
On any ceph monitor system:
- Create client user admin keyring:
root@OSD1-45drives:~# ceph auth get-key client.admin > admin.secret
- Copy it to the client machine
root@OSD1-45drives:~# scp admin.secret clientIP:/etc/ceph/
On client system:
Ensure the permissions are set appropriately for the file most likely:
root@client-45drives:~# chmod 600 /etc/ceph/admin.secret
Mounting filesystem on Client
Kernel Driver Mount:
- Create location to mount CephFS:
root@client-45drives:~# mkdir /mnt/mycephfsmount
- Mount the filesystem:
root@client-45drives:~# mount -t ceph {ip-address-of-ceph-monitor}:/ /mnt/mycephfsmount -o name=admin,secretfile=/etc/ceph/admin.secret
Example:
root@client-45drives:~# mount -t ceph 10.0.0.1,10.0.0.2,10.0.0.3:/ /mnt/mycephfsmount -o name=admin,secretfile=/etc/ceph/admin.secret
Adding Filesystem to fstab to remount on boot:
- To remount the CephFS filesystem on boot, we’ll have to edit the /etc/fstab file. We do this by:
root@client-45drives:~# vim /etc/fstab
CEPH-MON-IP:/ /mnt/mycephfsmount ceph name=admin,secretfile=/etc/ceph/admin.secret noatime,_netdev 0 0
Example:
10.0.0.1,10.0.0.2,10.0.0.3:/ /mnt/mycephfsmount ceph name=admin,secretfile=/etc/ceph/admin.secret,noatime,_netdev 0 0
Verification:
- If we run df -h we should now see the CephFS mount and the available storage
root@client-45drives:~# df -h