Managing Linux Filesystems

Rank and File

Expanding and Shrinking

Before expanding or shrinking the filesystem, you should make a backup. If problems arise unexpectedly, this reduces the risk of data loss.

You can expand an ext4 filesystem in an LVM environment in a single step using the lvextend command. The prerequisite is that the corresponding LVM volume group still have enough free disk space. If you add the -r option, after the LVM logical volume expands, the ext4 resize2fs command is executed, thus expanding the underlying filesystem as well. Expansion is also possible on the fly, which means the filesystem can remain mounted.

You can also shrink an ext4 filesystem in an LVM environment in a single step using the lvreduce command. Again the -r switch causes resize2fs to be run before shrinking the LVM logical volume:

umount /mnt/ext4fs
lvreduce -L -10G -r /dev/vg00/ext4fs

Shrinking is only possible offline; the filesystem must not be mounted.

Customizing ext4

With the ext4 tune2fs tool, you can view (with -l switch) and tweak all the adjustable parameters of an ext4 filesystem. A point of interest is the reserved block count, which indicates how many blocks of the filesystem are reserved for files belonging to the root user. On a filesystem that is filling up, for example, this ensures that logfiles can still be written. By default, the reserve is five percent of the filesystem size, which is reasonable for the root filesystem. For other uses, a smaller reserve is fine, and for a filesystem for backups, you can set the reserve to zero percent:

tune2fs -m 0 /dev/mapper/vg00-ext4fs

as shown in the preceding command.

Filesystem in Userspace

The previous section dealt with block-based filesystems, but the Linux storage stack also offers other types of filesystems. Filesystems in userspace (FUSE) is an interesting option that lets users create filesystems in userspace that do without root privileges and kernel code.

For a long time, this simple approach to managing a filesystem in userspace was not possible. Until FUSE hit the scene, filesystems had to be implemented in the kernel, with all the complexity that entails. This prompted the development of a kernel module (fuse.ko) that fields virtual filesystem requests and a library (libfuse) that passes them on to the filesystem in userspace.

If you have an innovative idea for a new filesystem, your best bet is to use FUSE. For easier programming in userspace, you have countless API bindings, from C, through Perl and Python, to Ruby, at your disposal. Before you start a new FUSE project, however, take a look at existing FUSE implementations, including prominent representatives such as NTFS-3G, EncFS, SSHFS, or ZFS.

Buy ADMIN Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs

Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>


		<div class=