Server Management (Unmanaged)

Advanced Guide to Linux File System Management

By the Domain India teamPublished 5 min read
Knowledge base article
Contents (7 sections)

Once you know df, du, fsck and chmod, the next layer of Linux storage work is LVM, swap, mount options and special permissions. This page covers those advanced tasks for a VPS or server where you have root access, and points to the main guide for the basics.

Key takeaways

For the essentials (disk space, inodes, filesystem checks, adding a disk, permissions), read the main Linux file system guide. This page adds: growing an LVM volume with lvextend -r, creating a swap file safely, hardening mounts with noexec,nosuid,nodev, and what setuid, setgid and the sticky bit really do. xfs_check no longer exists; use xfs_repair -n. Always take a backup before changing partitions.

Start with the main guide

Disk usage, fsck and xfs_repair, adding a disk, /etc/fstab by UUID and normal permissions are covered in the Comprehensive guide to Linux file system management. Everything here needs root access on your own VPS or server; on shared hosting you cannot partition disks or change mounts.

1. What changed since older guides

  • xfs_check is gone. It was removed from xfsprogs years ago. Use xfs_repair -n for a read-only check on an unmounted XFS filesystem.
  • XFS cannot shrink. You can grow it with xfs_growfs, never make it smaller. ext4 can shrink, but only unmounted.
  • Never delete and recreate a partition you want to keep; resize with growpart or parted.

2. LVM: grow a logical volume

LVM puts physical volumes (disks or partitions) into a volume group, then carves logical volumes from it. Check whether your server uses it:

bash
sudo pvs; sudo vgs; sudo lvs

If the volume group has free space, grow a volume and its filesystem in one step. The -r flag runs resize2fs or xfs_growfs for you:

bash
sudo lvextend -r -L +5G /dev/myvg/mylv

To add a new disk to the group first: sudo pvcreate /dev/vdb, then sudo vgextend myvg /dev/vdb. Many VPS images do not use LVM at all; then a bigger disk is grown with growpart and the filesystem tool, as shown in Cloning and resizing your VPS.

3. Create a swap file

bash
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048   # 2 GB
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap defaults 0 0' | sudo tee -a /etc/fstab
swapon --show

chmod 600 matters: a world-readable swap file can leak memory contents. Remove it with sudo swapoff /swapfile, delete the fstab line, then the file.

4. Mount options that harden a server

OptionEffectGood for
noexecPrograms on this filesystem cannot run/tmp, upload and backup disks
nosuidsetuid and setgid bits are ignored/tmp, /home, removable media
nodevDevice files are not interpretedAnything that is not the root filesystem
noatimeReading a file does not write its access timeBusy data disks; less disk writing
roRead-onlyArchives, recovery work

A hardened fstab line for a data disk, mounted by UUID:

text
UUID=your-uuid  /data  ext4  defaults,noatime,nosuid,nodev,nofail  0 2

Test with sudo findmnt --verify and sudo mount -a before you reboot; an fstab mistake can stop the server booting.

For SMB shares, keep the password in a root-only credentials file (credentials=/root/.smbcred), never in fstab, and add _netdev to network mounts.

5. Special permissions: setuid, setgid and sticky

BitCommandOn a fileOn a directory
setuidchmod u+sRuns as the file's ownerNo effect on Linux
setgidchmod g+sRuns as the file's groupNew files inherit the directory's group
stickychmod +tNo effect todayOnly a file's owner can delete it, as on /tmp

setgid on a shared project folder is the useful one: sudo chgrp -R developers /srv/project then sudo chmod 2775 /srv/project keeps every new file in the developers group. Avoid setting setuid on your own scripts; it is ignored for scripts and risky on binaries.

6. Failing disks and backups

On a VPS the hardware is not yours to test, so badblocks and SMART checks apply only to physical servers. If a VPS logs I/O errors in journalctl -k, open a ticket. For backups, rsync -aH --delete /data/ backuphost:/backups/data/ copies only changes; keep backups off the server.

Frequently asked questions

What replaced xfs_check?

xfs_repair with the -n option. Unmount the filesystem and run xfs_repair -n for a read-only check; xfs_check was removed from xfsprogs.

How do I extend an LVM volume and its filesystem together?

Run lvextend with the -r flag, for example lvextend -r -L +5G /dev/myvg/mylv. It grows the logical volume and then resizes the ext4 or XFS filesystem on it.

What does setgid do on a directory?

New files and folders created inside it inherit the directory's group instead of the creator's main group, which makes shared project folders work.

Can I use these commands on shared hosting?

No. LVM, swap, mounts and quotas need root access on a VPS or your own server. On shared hosting the disks are managed for you.

Ready for root access? Read the main file system guide, compare VPS plans, or open a ticket if a disk problem on your VPS needs our help.

Get a server of your own

KVM VPS plans with full root access and NVMe storage, self-managed and ready for your own setup.

See VPS plans

Ready when you are

Get VPS from ₹552.65/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app