Looking to create a shared VxFS filesystem the easy way on Linux?
Rest assured, we’ve got you covered.
The Veritas File System (VxFS), an extent-based journaling file system crafted by Veritas Software, is designed to allocate disk space to files in cohesive groups. These groups consist of contiguous blocks referred to as extents.
VxFS offers a range of advantageous functionalities, including snapshot creation, volume replication, and cluster filesystem support.
This tutorial will show how you can create a shared VxFS filesystem, step-by-step.
Let’s get started!
What You’ll Need
Before going into the necessary steps, you should fulfill the requirements to create a VxFS filesystem. Here’s what you need:
- Veritas Storage Foundation installed (guide)
- A terminal for issuing commands
- Shared disks between the nodes in your cluster
- Disk group creation is mandatory in the Master Node
Once everything is in place, you can proceed to the next section and start creating the filesystem.
How to Create Shared VxFS FileSystem on Linux: Step-By-Step
Step 1: Identify the Disk You Want to Use for the Shared Filesystem
First, you need to identify the disk for your new filesystem. You also need to ensure the disk has a shared flag set.
As mentioned earlier, you need a disk that can be shared among all nodes in a cluster. If the disk doesn’t have the shared property, then only the node where the disk is located can access it.
- To identify the disk, use the below command:
vxdisk -e list
DEVICE TYPE DISK GROUP STATUS OS_NATIVE_NAME
c1t0d0s2 auto:none - - online invalid sda
c1t1d0s2 auto:none - - online invalid sdb
c2t2d0s2 auto:none - - online invalid sdd
c2t3d0s2 auto:LVM - - LVM sde
c2t4d0s2 auto:LVM - - LVM sdf
Note: If you see Online Invalid in the STATUS column and auto:none in the TYPE column, it means those disks are not part of Veritas Volume Manager (VxVM).
- If you’re unable to find the disks you’re looking for,
scanf
the disks again with this command:
vxdisk scandisks
This command will look for any new or changed disk devices you added to the system and update its configuration.
Step 2: Initializing Disks
After you’ve found the targeted disk for creating the filesystem, you must initialize it.
Initializing the disk means preparing it for use with the Veritas Volume Manager. This is done by writing the metadata and other configuration information to the disk.
- Initialize the target disks with this command:
vxdisksetup -i sda
vxdisksetup -i sdb
The -i flag indicates initialization. We are initializing two disks—sda and sdb.
- Now you can check the STATUS and TYPE once again to see any changes. Identify the disks with this command:
vxdisk -e list
DEVICE TYPE DISK GROUP STATUS OS_NATIVE_NAME
c1t0d0s2 auto:cdsdisk - - online sda
c1t1d0s2 auto:cdsdisk - - online sdb
c2t2d0s2 auto:none - - online invalid sdd
c2t3d0s2 auto:LVM - - LVM sde
c2t4d0s2 auto:LVM - - LVM sdf
As you can notice from the output, the TYPE of the initialized disks has changed to auto:cdsdisk, and the STATUS has changed to online now.
- You can also check the information of individual disks by running this command:
vxdisk list <disk name>
So in our example, the command will look like this:
vxdisk list c1t0d0s2
This command will display detailed information, such as status, attributes, disk group membership, etc., of the specified disk.
Step 3: Identify the Master Node
Since you must create the shared Disk Group from the Master node, you need to identify which node is the Master node and which one is the slave node.
- To identify whether a node is the master node or not, run this command:
vxdctl -c mode
mode: enabled
This command checks for the operational mode of the node. When you use the -c flag and the operation mode is enabled, it will also output the cluster state in the below format:
mode: enabled: <clustered_state>
In case the current node is the Master node, the output will look like this:
mode: enabled: cluster active - MASTER
Once you confirm you’re in the Master node, you can start creating a shared Disk Group, as shown in the next step.
Step 4: Create a Shared Disk Group and Add Disks
After finding the master node, we can now create the Disk Group in it. Think of Disk Groups as the same as Volume Groups in LVM.
- To create a Disk Group, you must add a minimum of one disk. The basic syntax for creating a Disk Group is as follows:
vxdg init [Disk Group Name] [Disk Name=Disk Device]
So let’s create the Disk Group using the initialized disks. We’ll do that with the below command:
vxdg -s init newdg disk1=c1t0d0s2 disk2=c1t1d0s2
The -s flag creates a cluster dynamic disk group.
- After creating a new Disk Group, you can fetch its relevant information by running this command:
vxdg list
But if you only want to display the information about the Disk Group you just created, pass its name to the above command:
vxdg list newdg
- If you try to check the STATUS, DISK, and GROUP of the disks now, you should see they’ve been updated. Check this information with this command:
vxdisk -e list
DEVICE TYPE DISK GROUP STATUS OS_NATIVE_NAME
c1t0d0s2 auto:cdsdisk disk1 newdg online shared sda
c1t1d0s2 auto:cdsdisk disk2 newdg online shared sdb
c2t2d0s2 auto:none - - online invalid sdd
c2t3d0s2 auto:LVM - - LVM sde
c2t4d0s2 auto:LVM - - LVM sdf
The first two disks now have the online shared status and are in the newdg group.
Step 5: Create Veritas Volume
The first thing to do is to check available space. Unless you know the amount of free space you have, you won’t be able to accurately specify a size for the volume.
- To know the max size of your created Disk Group, run this command:
vxassist -g newdg maxsize
Maximum volume size: XXXXXXXX
It will display the size in megabytes. So depending on the size, you can now choose sufficient space for the volume.
- Create a volume of your preferred size with this command:
vxassist -g newdg make newvol1 1024g
This will create a 1TB volume called newvol1.
- To check the details of the newly created volume, run this command:
vxlist volume
Step 6: Create VxFS FileSystem
Now finally, you’re ready to create a VxFS filesystem. For that, we’re going to use the mkfs command. This command is used for creating a filesystem on a device.
- Create a VxFS filesystem with this command:
mkfs -t vxfs /dev/vx/rdsk/newdg/newvol1
We are specifying the type of the filesystem, which is VxFS. Then we’re passing the raw device containing the volume where we want to create the filesystem.
Step 7: Mount VxFS FileSystem
After creating the new filesystem, you need to mount it.
- Create a directory in the Master node and the slave nodes. Create the directories with this command:
mkdir /shared_data
- Then we’ll use a special utility to add the cluster-mounted filesystem. To do that, run this command:
cfsmntadm add newdg newvol1 /shared_data vcsdata_sg testnode01=cluster testnode02=cluster
After executing this command, you’ll have a new mount configuration added for the specific Veritas Cluster File System.
- Next, mount the shared volume with the mount point and the nodes with this command:
cfsmount /shared_data testnode01 testnode02
This should mount VxFS successfully.
Conclusion
Congratulations! You’ve successfully created a shared VxFS filesystem on Linux and mounted it for use. If you have any doubts, you can always check if the disk is mounted using the df command.
If this guide helped you, please share it.