linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Fleetwood <mike.fleetwood@googlemail.com>
To: linux-ext4@vger.kernel.org
Subject: Is it supported to change an ext2/3/4 label while mounted?
Date: Fri, 9 Aug 2019 12:01:03 +0100	[thread overview]
Message-ID: <CAMU1PDjZNXr6Y26EUtCSZFnjJfx7MgCLWNWNRgBb9dSN1pdK_g@mail.gmail.com> (raw)

Hi,

For Btrfs and more recently XFS they explicitly support changing the
label while mounted.  Documentation is available saying it can be done
and stracing shows it is using a file system specific ioctl() to make
the change.

However for ext2/3/4 file systems I can't find anything explicitly
documented, and stracing "tune2fs -L" shows that it writes directly to
the block device while the file system is mounted.  That seems unsafe as
I presume the kernel would be expecting to have exclusive access to the
block device while the file system is mounted.  However it always seems
to work.  I am wondering if it is safe and supported to change an
ext2/3/4 file system label while it is mounted?

(I have a old GParted enhancement request for this, hence the question.
https://bugzilla.gnome.org/show_bug.cgi?id=600496)

Thanks,
Mike


# mkfs.btrfs /dev/sdb1
# mount /dev/db1 /mnt/1
# strace btrfs filesystem label /mnt/1 btrfs_label
...
open("/mnt/1", O_RDONLY|O_NOATIME)      = 3
ioctl(3, BTRFS_IOC_SET_FSLABEL, "btrfs_label") = 0


# mkfs.xfs /dev/sdb2
# mount /dev/sdb2 /mnt/2
# strace  xfs_io -c "label -s xfs_label" /mnt/2
...
open("/mnt/2", O_RDONLY)                = 3
...
ioctl(3, BTRFS_IOC_SET_FSLABEL, "xfs_label") = 0


# mkfs.ext2 /dev/sdb3
# mount /dev/sdb3 /mnt/3
# strace tune2fs -L ext2_label /dev/sdb3
...
open("/dev/sdb3", O_RDWR)               = 3
...
lseek(3, 134217728, SEEK_SET)           = 134217728
write(3, "\0\200\0\0\0\0\2\0\231\31\0\0\217\367\1\0\365\177\0\0\0\0\0\0\2\0\0\0\2\0\0\0"...,
1024) = 1024
lseek(3, 402653184, SEEK_SET)           = 402653184
write(3, "\0\200\0\0\0\0\2\0\231\31\0\0\217\367\1\0\365\177\0\0\0\0\0\0\2\0\0\0\2\0\0\0"...,
1024) = 1024
fsync(3)                                = 0
lseek(3, 1072, SEEK_SET)                = 1072
write(3, "\vM", 2)                      = 2
lseek(3, 1144, SEEK_SET)                = 1144
write(3, "ext2_label", 10)              = 10
fsync(3)                                = 0
close(3)

                 reply	other threads:[~2019-08-09 11:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMU1PDjZNXr6Y26EUtCSZFnjJfx7MgCLWNWNRgBb9dSN1pdK_g@mail.gmail.com \
    --to=mike.fleetwood@googlemail.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).