linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Is it supported to change an ext2/3/4 label while mounted?
@ 2019-08-09 11:01 Mike Fleetwood
  0 siblings, 0 replies; only message in thread
From: Mike Fleetwood @ 2019-08-09 11:01 UTC (permalink / raw)
  To: linux-ext4

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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-09 11:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-09 11:01 Is it supported to change an ext2/3/4 label while mounted? Mike Fleetwood

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).