Skip to content

Linux & shell: Storage, mounts & LVM

10 Linux & shell commands: Storage, mounts & LVM. Click a command to see what each part does.

Index
10 items
Click a command to see what each part does.

Storage, mounts & LVM10

  • lsblk -fDisks, partitions and filesystems

    What each part does

    1. lsblkblock devices as a tree: disks, partitions, LVM volumes
    2. -fadd filesystem type, label, UUID and mount point
  • sudo mount <device> <mount-point>Mount a filesystem

    What each part does

    1. mount <device>e.g. /dev/sdb1 or /dev/mapper/vg-data
    2. <mount-point>existing empty directory, e.g. /mnt/data
  • sudo findmnt --verify && sudo mount -aTest /etc/fstab before rebooting

    What each part does

    1. findmnt --verifycheck fstab syntax, devices and filesystem types
    2. mount -amount everything in fstab now; a typo here would otherwise stop the next boot
  • sudo umount <mount-point> || sudo lsof +f -- <mount-point>Unmount, and find what keeps it busy

    What each part does

    1. umountunmount
    2. lsof +f -- <mount-point>processes with files open there (target is busy)
  • sudo mkfs.ext4 -L <label> <device>Create a filesystem on a new diskDestructive

    What each part does

    1. mkfs.ext4format as ext4 (mkfs.xfs for XFS): erases the device
    2. -L <label>filesystem label
  • sudo growpart <disk> <partition-number> && sudo resize2fs <partition>Grow a partition and filesystem after enlarging a cloud diskCaution

    What each part does

    1. growpart /dev/xvda 1extend partition 1 to fill the disk (cloud-guest-utils)
    2. resize2fs <partition>grow an ext4 filesystem; for XFS: xfs_growfs <mount-point>
  • sudo pvs; sudo vgs; sudo lvsLVM overview

    What each part does

    1. pvsphysical volumes (disks in LVM)
    2. vgsvolume groups and their free space
    3. lvslogical volumes and sizes
  • sudo lvextend -r -L +<size>G /dev/<vg>/<lv>Extend a logical volume and its filesystemCaution

    What each part does

    1. lvextendgrow a logical volume
    2. -ralso resize the filesystem in one step
    3. -L +<size>Gadd this much (or -l +100%FREE for all free space)
  • swapon --show; sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfileShow swap, and add a swap file

    What each part does

    1. swapon --showactive swap devices and usage
    2. fallocate -l 2G /swapfilecreate a 2 GB file
    3. chmod 600only root may read it
    4. mkswap / swaponformat it as swap and enable it (add to fstab to keep it)
  • df -iOut of inodes? (disk full with free space left)

    What each part does

    1. df -iinode usage per filesystem; 100% means no new files even if space is free (millions of tiny files)

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…