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.
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.
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_checkis gone. It was removed from xfsprogs years ago. Usexfs_repair -nfor 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
growpartorparted.
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:
sudo pvs; sudo vgs; sudo lvsIf 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:
sudo lvextend -r -L +5G /dev/myvg/mylvTo 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
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 --showchmod 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
| Option | Effect | Good for |
|---|---|---|
| noexec | Programs on this filesystem cannot run | /tmp, upload and backup disks |
| nosuid | setuid and setgid bits are ignored | /tmp, /home, removable media |
| nodev | Device files are not interpreted | Anything that is not the root filesystem |
| noatime | Reading a file does not write its access time | Busy data disks; less disk writing |
| ro | Read-only | Archives, recovery work |
A hardened fstab line for a data disk, mounted by UUID:
UUID=your-uuid /data ext4 defaults,noatime,nosuid,nodev,nofail 0 2Test 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
| Bit | Command | On a file | On a directory |
|---|---|---|---|
| setuid | chmod u+s | Runs as the file's owner | No effect on Linux |
| setgid | chmod g+s | Runs as the file's group | New files inherit the directory's group |
| sticky | chmod +t | No effect today | Only 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.
KVM VPS plans with full root access and NVMe storage, self-managed and ready for your own setup.
See VPS plans