I'm running a centos 7 server.
I want to change the label of the root file system (xfs).
xfs_admin -L "newlabel" /dev/mapper/centos-root fails because it can't operate on a mounted fs.

Is this possible anyhow?
Is there a way to run something like that during boot before the root fs is mounted?


From man xfs_admin

Devices that are mounted cannot be modified. Administrators must unmount filesystems before xfs_admin or xfs_db(8) can convert parameters. A number of parameters of a mounted filesystem can be examined and modified using the xfs_growfs(8) command.

  • I know. That is exactly what I'm trying to find a solution to... This is the root file system so you can't unmount it. This is why I asked in my question if there is a way to run some command/script before the root file system is mounted during boot – csny Nov 22 '15 at 10:51
  • Well, since the documentation says it can't be done, I would say you're searching in vain. – cristi Nov 22 '15 at 11:16

The ability to update the label of a mounted XFS file system was recented added. August 2018 for upstream code and November 2018 for RHEL/CentOS 7 packages.

Update the label like this (as root):

xfs_io -c "label -s MYNEWLABEL" /MNTPOINT

From the xfs_io man page:

label [ -c | -s label ]
On filesystems that support online label manipulation, get, set, or clear the filesystem label. With no options, print the current filesystem label. The -c option clears the filesystem label by setting it to the null string. The -s label option sets the filesystem label to label. If the label is longer than the filesystem will accept, xfs_io will print an error message. XFS filesystem labels can be at most 12 characters long.

For upstream code this required Linux kernel >= 4.18 and xfsprogs >= 4.17.0.

For RHEL / CentOS 7 this required packages kernel >= 3.10.0-957.el7 and xfsprogs >= 4.5.0-17.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.