Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

How to resize an OCFS2 filesystem on Linux – The Geek Diary Page 1 of 9

THE GEEK DIARY


How to resize anH OOCFS2 filesystem
WTOS | BA S I C S | C O N C E Pon
T S Linux

By admin (https://www.thegeekdiary.com/author/sandeep_patil/)

The post outlines the steps to resize an OCFS2 filesystem on Linux. The procedure
should first be tested in test before being performed against a production
environment.

1. Backup all data on the filesystem


Repartitioning a disk/device is a destructive process that may result in complete
loss of volume data. Backup the contents of the volume to be resized before
proceeding.

2. Globally unmount the filesystem to be resized


OCFS2 filesystem resize can only be performed with the filesystem unmounted
from all cluster nodes. Unmount the filesystem to be resized on all cluster nodes.
Use the mounted.ocfs2 command to verify if any nodes still have the volume
mounted e.g.:

https://www.thegeekdiary.com/how-to-resize-an-ocfs2-filesystem-on-linux/ 19/2/2019
How to resize an OCFS2 filesystem on Linux – The Geek Diary Page 2 of 9

# mounted.ocfs2 -f
Device FS Nodes
/dev/sdb1 ocfs2 node01, node02
/dev/sdc1 ocfs2 node01, node02
/dev/sdg1 ocfs2 node01, node02

# mounted.ocfs2 -f
Device FS Nodes
/dev/sdb1 ocfs2 Not mounted
/dev/sdc1 ocfs2 Not mounted
/dev/sdg1 ocfs2 Not mounted

3. Perform a filesystem check


Before resizing the device or filesystem, perform a filesystem check. Be sure to
correct/address any issues before proceeding.

https://www.thegeekdiary.com/how-to-resize-an-ocfs2-filesystem-on-linux/ 19/2/2019
How to resize an OCFS2 filesystem on Linux – The Geek Diary Page 3 of 9

number of blocks: 1048265


bytes per block: 4096
number of clusters: 1048265
bytes per cluster: 4096
max slots: 6

/dev/sdb1 was run with -f, check forced.


Pass 0a: Checking cluster allocation chains
Pass 0b: Checking inode allocation chains
Pass 0c: Checking extent block allocation chains
Pass 1: Checking inodes and blocks.
Pass 2: Checking directory entries.
Pass 3: Checking directory connectivity.
Pass 4a: checking for orphaned inodes
Pass 4b: Checking inodes link counts.
All passes succeeded.

4. Resize the underlying device/partition


The underlying LUN/device/partition upon which the filesystem resides must first
be resized before the filesystem itself can be resized. The method, and therefore
the commands required, to resize the device will differ depending upon the
storage solution used. Note, as of OCFS2 version available at the time of writing
this post, OCFS2 volumes may be resized larger, but not smaller.

In the following example, the OCFS2 partition to be resized resides on


partition /dev/sdb1 (an iSCSI target) that is resized from 4Gb to 8Gb.

# df -kl /cfs03
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb1 4193060 1578984 2614076 38% /cfs03

https://www.thegeekdiary.com/how-to-resize-an-ocfs2-filesystem-on-linux/ 19/2/2019
How to resize an OCFS2 filesystem on Linux – The Geek Diary Page 4 of 9

Before Resize

# cat /proc/partitions | grep sdb


8 16 4194304 sdb
8 17 4194288 sdb1

During Resize (LUN resized, but not partition)

# cat /proc/partitions | grep sdb


8 16 8388608 sdb
8 17 4194288 sdb1

When using OCFS2 filesystems on partitioned devices, always ensure to recreate


the partition using the original Start cylinder and larger End cylinder.

https://www.thegeekdiary.com/how-to-resize-an-ocfs2-filesystem-on-linux/ 19/2/2019
How to resize an OCFS2 filesystem on Linux – The Geek Diary Page 5 of 9

and could in certain setups cause problems with:


1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes


64 heads, 32 sectors/track, 8192 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System


/dev/sdb1 1 4096 4194288 83 Linux

Command (m for help): d


Selected partition 1

Command (m for help): n


Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8192, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-8192, default 8192):
Using default value 8192

Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes


64 heads, 32 sectors/track, 8192 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System


/dev/sdb1 1 8192 8388592 83 Linux

Command (m for help): w

https://www.thegeekdiary.com/how-to-resize-an-ocfs2-filesystem-on-linux/ 19/2/2019
How to resize an OCFS2 filesystem on Linux – The Geek Diary Page 6 of 9

Note: If using device sizes greater than 2Tb, use the parted utilty instead
of fdisk to manage partitions.

After device/partition resize, ensure that all cluster nodes’ operating systems
detect the new sizing of the device/partition before proceeding. The following
utilities/methods can be used to dynamically detect device/partition changes;
partprobe, sfdisk, blockdev, cluster-wide node reboot. Use with caution, for
example:

# /sbin/partprobe /dev/sdb

OR

# /sbin/sfdisk -R /dev/sdb

OR

# /sbin/blockdev --rereadpt /dev/sdb

Verify the kernel sees the modified device partition sizing. After Resize (both LUN
and partition resized):

# cat /proc/partitions | grep sdb


8 16 8388608 sdb
8 17 8388592 sdb1

https://www.thegeekdiary.com/how-to-resize-an-ocfs2-filesystem-on-linux/ 19/2/2019
How to resize an OCFS2 filesystem on Linux – The Geek Diary Page 7 of 9

5. Resize the OCFS2 filesystem


Once the device/partition has been resized and it’s new size visible to all cluster
nodes, resize the OCFS2 filesystem using the tunefs.ocfs2 command. For
example:

# tunefs.ocfs2 -S /dev/sdb1
tunefs.ocfs2 1.2.4
Changing volume size from 1048572 blocks to 2097148 blocks
Proceed (y/N): y
Resized volume
Wrote Superblock

6. Perform filesystem check


Having resized the OCFS2 partition, perform another filesystem check before
attempting to mount the resized volume.

https://www.thegeekdiary.com/how-to-resize-an-ocfs2-filesystem-on-linux/ 19/2/2019
How to resize an OCFS2 filesystem on Linux – The Geek Diary Page 8 of 9

c
number of blocks: 2097148
bytes per block: 4096
number of clusters: 2097148
bytes per cluster: 4096
max slots: 6

/dev/sdb1 was run with -f, check forced.


Pass 0a: Checking cluster allocation chains
Pass 0b: Checking inode allocation chains
Pass 0c: Checking extent block allocation chains
Pass 1: Checking inodes and blocks.
Pass 2: Checking directory entries.
Pass 3: Checking directory connectivity.
Pass 4a: checking for orphaned inodes
Pass 4b: Checking inodes link counts.
All passes succeeded.

7. Mount the resized OCFS2 volume


Remount the resized OCFS2 filesystem on all cluster nodes.

# mounted.ocfs2 -f
Device FS Nodes
/dev/sdc1 ocfs2 node01, node02
/dev/sdf1 ocfs2 node01, node02
/dev/sdb1 ocfs2 node01, node02

# mount -t ocfs2
/dev/sdb1 on /cfs03 type ocfs2 (rw,_netdev,heartbeat=local)
...

https://www.thegeekdiary.com/how-to-resize-an-ocfs2-filesystem-on-linux/ 19/2/2019
How to resize an OCFS2 filesystem on Linux – The Geek Diary Page 9 of 9

How to Extend ocfs2 Filesystem with tunefs.ocfs2 Command (Whole


device used without partitions) (https://www.thegeekdiary.com/how-to-
extend-ocfs2-filesystem-with-tunefs-ocfs2-command-whole-device-used-
without-partitions/)

YOU MAY ALSO LIKE

© 2019 · THE GEEK DIARY (HTTP://THEGEEKDIARY.COM)

https://www.thegeekdiary.com/how-to-resize-an-ocfs2-filesystem-on-linux/ 19/2/2019

You might also like