Product SiteDocumentation Site

9.3. Create and Populate GFS2 Filesystem

Before we do anything to the existing partition, we need to make sure it is unmounted. We do this by telling the cluster to stop the WebFS resource. This will ensure that other resources (in our case, Apache) using WebFS are not only stopped, but stopped in the correct order.
[root@pcmk-1 ~]# pcs resource disable WebFS
[root@pcmk-1 ~]# pcs resource
 ClusterIP      (ocf::heartbeat:IPaddr2):       Started pcmk-1
 WebSite        (ocf::heartbeat:apache):        Stopped
 Master/Slave Set: WebDataClone [WebData]
     Masters: [ pcmk-1 ]
     Slaves: [ pcmk-2 ]
 WebFS  (ocf::heartbeat:Filesystem):    Stopped (disabled)
 Clone Set: dlm-clone [dlm]
     Started: [ pcmk-1 pcmk-2 ]
You can see that both Apache and WebFS have been stopped, and that pcmk-1 is the current master for the DRBD device.
Now we can create a new GFS2 filesystem on the DRBD device.

Warning

This will erase all previous content stored on the DRBD device. Ensure you have a copy of any important data.

Important

Run the next command on whichever node has the DRBD Primary role. Otherwise, you will receive the message:
/dev/drbd1: Read-only file system
[root@pcmk-1 ~]# mkfs.gfs2 -p lock_dlm -j 2 -t mycluster:web /dev/drbd1
It appears to contain an existing filesystem (xfs)
This will destroy any data on /dev/drbd1
Are you sure you want to proceed? [y/n] y
Discarding device contents (may take a while on large devices): Done
Adding journals: Done
Building resource groups: Done
Creating quota file: Done
Writing superblock and syncing: Done
Device:                    /dev/drbd1
Block size:                4096
Device size:               0.50 GB (131059 blocks)
Filesystem size:           0.50 GB (131056 blocks)
Journals:                  2
Resource groups:           3
Locking protocol:          "lock_dlm"
Lock table:                "mycluster:web"
UUID:                      0bcbffab-cada-4105-94d1-be8a26669ee0
The mkfs.gfs2 command required a number of additional parameters:
Now we can (re-)populate the new filesystem with data (web pages). We’ll create yet another variation on our home page.
[root@pcmk-1 ~]# mount /dev/drbd1 /mnt
[root@pcmk-1 ~]# cat <<-END >/mnt/index.html
<html>
<body>My Test Site - GFS2</body>
</html>
END
[root@pcmk-1 ~]# chcon -R --reference=/var/www/html /mnt
[root@pcmk-1 ~]# umount /dev/drbd1
[root@pcmk-1 ~]# drbdadm verify wwwdata