0

According to https://unix.stackexchange.com/a/501454/674,

parted's resizepart does not care about the filesystem at all. It just changes the partition table to specify a new location where the partition now ends. It does not overwrite anything at or near that location. After modifying the partition table, it will signal the kernel that the partition table has been changed. The kernel will read the new table and apply it if possible.

How does resize2fs change the size of a file system? Does it also do it in a similar way to parted resizepart? Specially:

https://unix.stackexchange.com/a/231623/674 says it extends a file system, by

writing additional filesystem metadata to the newly available storage.

What filesystem metadata does it write to "the newly available storage"? Does writing to "the newly available storage" in the sense of writing zeros all over "the newly available storage"? Or does it change some value stored in the superblock of the file system only?

https://unix.stackexchange.com/a/231623/674 says it shrinks a file system

by moving both filesystem metadata and your data around.

Does it not write some "filesystem metadata" to somewhere?

Thanks.

0

1 Answer 1

2

What filesystem metadata does it write to "the newly available storage"?

Whatever it needs for that particular filesystem to make the space usable.

For, say ext4, the filesystem is split into block groups, with each group containing a number of data blocks, plus a number of inodes, plus the free/used bitmaps for both the blocks and the inodes. (and perhaps some other bookkeeping data.)

Then, there's the main data structures of the filesystem that are needed to know how large the filesystem is to begin with, etc. They also need to be updated.

Does writing to "the newly available storage" in the sense of writing zeros all over "the newly available storage"?

Probably not. Though mkfs.ext4 does discard the unused blocks on the filesystem, it's possible that the same is done for the part where the filesystem extends to.

5
  • Thanks. "Then, there's the main data structures of the filesystem that are needed to know how large the filesystem is to begin with, etc. They also need to be updated." By "the main data structures of the filesystem", do you mean in-kernel data structures, or on-disk data structures?
    – Tim
    Feb 20, 2019 at 13:40
  • Moreover, here is a post created after your reply unix.stackexchange.com/questions/501883/…
    – Tim
    Feb 20, 2019 at 15:17
  • @Tim, on-disk ones. I was thinking of the case where the filesystem is not mounted at the time. ext4 supports online extending, too, but then it's the filesystem driver in the kernel that does the dirty work and not a separate userspace process (it has to be the driver so that it can deal with regular filesystem operations at the same time without conflicts). When resizing mounted filesystems, I suppose resize2fs just asks the kernel driver to do it.
    – ilkkachu
    Feb 20, 2019 at 15:28
  • What is "the main data structures of the filesystem that are needed to know how large the filesystem is to begin with, etc"? Do you mean superblock?
    – Tim
    Feb 20, 2019 at 20:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .