Blog | Pythian

fsfreeze in Linux

Written by Minto Joseph | May 14, 2015 4:00:00 AM

Suspending and Resuming Access

A filesystem can be frozen using following command: # /sbin/fsfreeze -f /data

Now if you are writing to this filesystem, the process/command will be stuck. For example, following command will be stuck in D (UNINTERRUPTIBLE_SLEEP) state:

# echo “testing” > /data/file

Only after the filesystem is unfreezed using the following command, can it continue: # /sbin/fsfreeze -u /data

Use Cases and System Support

As per the fsfreeze man page, “fsfreeze is unnecessary for device-mapper devices. The device-mapper (and LVM) automatically freezes filesystem on the device when a snapshot creation is requested.”

fsfreeze is provided by the util-linux package in RHEL systems. Along with userspace support, fsfreeze also requires kernel support.

Troubleshooting "Operation Not Supported" Errors

For example, in the following case, fsfreeze was used in the ext4 filesystem of an AWS CentOS node: # fsfreeze -f /mysql fsfreeze: /mysql: freeze failed: Operation not supported

Analyzing ioctl Failures

From strace we found that ioctl is returning EOPNOTSUPP:

fstat(3, {st_dev=makedev(253, 0), st_ino=2, st_mode=S_IFDIR|0755, st_nlink=4, st_uid=3076, st_gid=1119, st_blksize=4096, st_blocks=8, st_size=4096, st_atime=2014/05/20-10:58:56, st_mtime=2014/11/17-01:39:36, st_ctime=2014/11/17-01:39:36}) = 0 ioctl(3, 0xc0045877, 0) = -1 EOPNOTSUPP (Operation not supported) 

Kernel Source Insights

From latest upstream kernel source:

static int ioctl_fsfreeze(struct file *filp) { struct super_block *sb = file_inode(filp)->i_sb;if (!capable(CAP_SYS_ADMIN)) return -EPERM;/* If filesystem doesn’t support freeze feature, return. */ if (sb->s_op->freeze_fs == NULL) return -EOPNOTSUPP; /* Freeze */ return freeze_super(sb); } 

EOPNOTSUPP is returned when a filesystem does not support the feature. On testing to freeze ext4 in CentOS with AWS community AMI, fsfreeze worked fine.

This means that the issue was specific to the kernel of the system. It was found that the AMI used to build the system was having a customized kernel without fsfreeze support.

Managed IT Consulting Services

Ready to optimize your Managed Services for the future?