Tuesday, September 26, 2017

How to create and remove directories in a vSAN datastore with osfs-mkdir and osfs-rmdir

Creating and removing directories in a vSAN datastore is not as simple as using mkdir and rmdir or rm -rf because the vSAN datastore is object based. In order to do that, special vSAN related commands exist to perform such tasks.

Notice what happens if you try to use the mkdir command:

# cd /vmfs/volumes/vsanDatastore
# mkdir testdir
mkdir: can't create directory 'testdir': Function not implemented

The commands that follow perform the same tasks as the icon with the green plus sign on the web client. These commands should be used if the vCenter server is not available.

How to do it:

Step 1: Access the folder that contains the utilities

# cd /usr/lib/vmware/osfs/bin

Step 2: List the contents of that directory

# ls
objtool     osfs-ls     osfs-mkdir  osfs-rmdir  osfsd

Step 3: Verify that a directory called testdir does not exist

# ls -lh /vmfs/volumes/vsanDatastore/testdir
ls: /vmfs/volumes/vsanDatastore/testdir: No such file or directory

Step 4: Create such directory

# ./osfs-mkdir /vmfs/volumes/vsanDatastore/testdir

Step 5: Verify that it exists

# ls -lh /vmfs/volumes/vsanDatastore/testdir
lrwxr-xr-x    1 root     root          36 Sep 26 21:03 /vmfs/volumes/vsanDatastore/testdir -> 92c0ca59-0c9a-84f0-d2f0-005056013e28

Step 6: Delete the directory

# ./osfs-rmdir /vmfs/volumes/vsanDatastore/testdir
Deleting directory 92c0ca59-0c9a-84f0-d2f0-005056013e28 in container id 521305e4430dd845d59b1943736fdc88 backed by vsan (force=False)

Step 7: Verify that it is gone

# ls -lh /vmfs/volumes/vsanDatastore/testdir
ls: /vmfs/volumes/vsanDatastore/testdir: No such file or directory

No comments:

Post a Comment