Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

Linux Disks: lsblk, blkid, fdisk, parted, mkfs, mount, /etc/fstab and swap Explained

A new disk was attached to your server. How do you find it, split it, format it, mount it, and make sure it comes back after reboot? This chapter walks through the whole story: lsblk and blkid to see disks and IDs, fdisk and parted to create partitions, mkfs to make a filesystem, mount and umount, /etc/fstab for permanent mounts, growing a partition and filesystem, and swap.

In this chapter

  • Find disks and partitions with lsblk and blkid
  • Create partitions with fdisk and parted
  • Make filesystems with mkfs (ext4, xfs)
  • Mount, unmount and use /etc/fstab safely
  • Grow partitions and filesystems
  • Add and manage swap

1. An everyday example: a new cupboard at home

You buy a new cupboard. First you find a place for it. Then you fit shelves (sections). You line each shelf so things can be kept. You put a label on the door so everyone knows what is inside, and you write in the house notebook which room it is in, so nobody forgets.

Cupboard = disk (lsblk). Shelves = partitions (fdisk/parted). Lining = filesystem (mkfs). Label = UUID/LABEL (blkid). Room = mount point (mount). House notebook = /etc/fstab.

From new disk to permanent mountlsblk: find the new disk (no partitions, no mount)parted or fdisk: create a GPT label and a partitionmkfs.xfs or mkfs.ext4: make the filesystemblkid: copy the UUIDmkdir and mount: test itAdd a UUID line to /etc/fstab and run mount -a to check
Never skip the mount -a test: a bad fstab line can stop the next boot.

2. lsblk: see all block devices

Read the lsblk tree before touching a disk. A disk is a block device. A partition is a selected range inside that device. A filesystem organises files within a device or a partition. A mount point is the folder through which you see those files. Indentation in lsblk connects the disk to its partitions. A slash in the mount point column tells you which filesystem holds the running operating system. Compare the lab volume’s size and serial with the attachment record, then identify the separate branch where you will work.

Before touching a disk you must be sure which one is new and empty. Formatting the wrong disk destroys data.

lsblk shows disks (TYPE disk), partitions (part), LVM (lvm) and their mount points as a tree. -f adds filesystem type, label and UUID. -o NAME,SIZE,TYPE,MOUNTPOINTS picks columns. Cloud NVMe disks look like nvme1n1; older ones xvdf or sdb.

  1. The tree.
lsblk

Output:

NAME        SIZE TYPE MOUNTPOINTS
nvme0n1      20G disk
└─nvme0n1p1  20G part /
nvme1n1     100G disk

nvme1n1 is the expected lab volume in this example. Confirm the device against your own lab attachment before writing to it.

  1. With filesystems.
lsblk -f

Output:

NAME       FSTYPE LABEL UUID                                 MOUNTPOINTS
nvme0n1p1  xfs    /     3f1c...a2  /
nvme1n1

No FSTYPE on nvme1n1.

  1. Choose columns.
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS

Output:

(same tree, chosen columns)

Good for scripts and tickets.

3. blkid: UUIDs and filesystem types

Device names like sdb can change between boots. In fstab use the filesystem UUID from blkid so the mount follows the filesystem if the device name changes. Check the UUID again after reformatting. A block-level clone can also carry the same UUID as the original, so verify both IDs before attaching both filesystems to the same host.

blkid prints UUID, TYPE and LABEL for each filesystem. blkid /dev/nvme1n1p1 for one. blkid -s UUID -o value DEV prints only the UUID. findfs UUID=... finds the device for a UUID.

  1. All.
sudo blkid

Output:

/dev/nvme0n1p1: LABEL="/" UUID="3f1c...a2" TYPE="xfs"
/dev/nvme1n1p1: UUID="7b9e...44" TYPE="xfs"

Two filesystems.

  1. Only the UUID.
sudo blkid -s UUID -o value /dev/nvme1n1p1

Output:

7b9e1c2d-...-44

Ready for fstab.

4. fdisk: create MBR or GPT partitions

You may want one disk split into parts, or a single partition so tools know the disk is in use.

sudo fdisk /dev/DISK opens a menu: p print, g new GPT table, o new MBR (DOS) table, n new partition, t type, d delete, w write, q quit without saving. Nothing changes until w. fdisk -l lists partition tables. Use GPT for disks over 2 TB.

KeyAction
pPrint table
g / oNew GPT / MBR
nNew partition
dDelete
wWrite and exit
qQuit, no changes
  1. List.
sudo fdisk -l /dev/nvme1n1

Output:

Disk /dev/nvme1n1: 100 GiB
Disklabel type: (none)

Empty.

  1. Interactive steps.
sudo fdisk /dev/nvme1n1
  g
  n  (Enter, Enter, Enter)
  w

Output:

Created a new GPT disklabel.
Created a new partition 1 of type 'Linux filesystem' and of size 100 GiB.
The partition table has been altered.

One partition: nvme1n1p1.

  1. Kernel did not see it.
sudo partprobe /dev/nvme1n1 && lsblk /dev/nvme1n1

Output:

nvme1n1    100G disk
└─nvme1n1p1 100G part

Now visible.

5. parted: scriptable partitioning

In automation (cloud-init, Ansible) you cannot answer menus. parted runs in one command line.

sudo parted -s DISK mklabel gpt creates a GPT table. mkpart NAME FS START END makes a partition (use 0% 100% for alignment). print shows it. resizepart N 100% grows a partition. -s means script mode (no questions).

  1. One line.
sudo parted -s /dev/nvme2n1 mklabel gpt mkpart data xfs 0% 100%

Output:

(no output)

Done.

  1. Print.
sudo parted /dev/nvme2n1 print

Output:

Partition Table: gpt
Number Start  End    Size   File system Name
 1     1049kB 53.7GB 53.7GB             data

Aligned at 1 MiB.

  1. Two partitions.
sudo parted -s /dev/sdc mklabel gpt mkpart logs ext4 0% 30% mkpart data xfs 30% 100%

Output:

(no output)

30/70 split.

6. mkfs: make a filesystem

A partition is raw space. A filesystem is what lets you store files and folders on it.

mkfs.xfs DEV (RHEL default, great for big files, can grow but not shrink). mkfs.ext4 DEV (Ubuntu default, can grow and shrink offline). -L LABEL sets a label. -f forces over an old filesystem (careful). mkfs erases everything on the device.

xfsext4
GrowOnlineOnline
ShrinkNoOffline
Default onRHEL, Amazon LinuxUbuntu, Debian
Grow toolxfs_growfsresize2fs
  1. XFS.
sudo mkfs.xfs -L data /dev/nvme1n1p1

Output:

meta-data=/dev/nvme1n1p1 isize=512 agcount=4, agsize=6553536 blks

Filesystem ready.

  1. ext4.
sudo mkfs.ext4 -L logs /dev/sdc1

Output:

Creating filesystem with 7864320 4k blocks
Writing superblocks and filesystem accounting information: done

Ready.

  1. Safety stop.
sudo mkfs.xfs /dev/nvme1n1p1

Output:

mkfs.xfs: /dev/nvme1n1p1 appears to contain an existing filesystem (xfs).
mkfs.xfs: Use the -f option to force overwrite.

Stop and double check.

7. mount and umount

A filesystem is only usable after it is attached to a folder in the tree.

sudo mkdir -p /data && sudo mount DEV /data. mount -o ro, noexec, nosuid set options. findmnt /data or findmnt -T PATH shows what is mounted where. umount /data detaches; 'target is busy' means a process uses it (find with lsof +f -- /data or fuser -vm /data).

  1. Mount.
sudo mkdir -p /data && sudo mount /dev/nvme1n1p1 /data && df -h /data

Output:

Filesystem      Size Used Avail Use% Mounted on
/dev/nvme1n1p1  100G 746M 100G   1% /data

Ready to use.

  1. Show mounts.
findmnt /data

Output:

TARGET SOURCE         FSTYPE OPTIONS
/data  /dev/nvme1n1p1 xfs    rw,relatime

Options shown.

  1. Busy.
sudo umount /data

Output:

umount: /data: target is busy.

Someone is inside.

  1. Who?
sudo fuser -vm /data

Output:

USER PID ACCESS COMMAND
/data: ravi 3301 ..c.. bash

Your own shell: cd out.

8. /etc/fstab: permanent mounts

Read one fstab row from left to right. A UUID identifies the filesystem, then a folder such as /data says where it belongs. The type tells Linux how to read the filesystem, and the options describe how to mount it. The last two numbers are for dump and boot-time filesystem checks. Before the next boot, verify the lab row, mount the intended filesystem and run findmnt /data. Read the SOURCE and TARGET together so you can tell the disk and folder actually match the rule you wrote.

mount is temporary. Without fstab the disk is not mounted after reboot and the app fails.

Six fields: device (UUID=...), mount point, type, options, dump (0), fsck order (0 for xfs, 2 for ext4 data). Add nofail for non-root disks in the cloud so boot does not hang if the disk is missing. Test with sudo mount -a and findmnt --verify.

FieldExample
1 deviceUUID=7b9e...
2 mount point/data
3 typexfs
4 optionsdefaults,nofail
5 dump0
6 fsck0 (xfs) / 2 (ext4)
  1. Add a line.
echo "UUID=$(sudo blkid -s UUID -o value /dev/nvme1n1p1) /data xfs defaults,nofail 0 0" | sudo tee -a /etc/fstab

Output:

UUID=7b9e...44 /data xfs defaults,nofail 0 0

Permanent.

  1. Test it.
sudo umount /data && sudo mount -a && findmnt /data

Output:

/data /dev/nvme1n1p1 xfs rw,relatime

fstab works.

  1. Verify syntax.
sudo findmnt --verify

Output:

Success, no errors or warnings detected

Safe to reboot.

  1. Reload systemd.
sudo systemctl daemon-reload

Output:

(no output)

systemd builds mount units from fstab.

9. Growing a partition and filesystem

Imagine requesting a disk increase from 20 GiB to 30 GiB. First see whether lsblk reports the larger disk. If the filesystem sits inside a partition, read its size too: the outer disk can already show 30 GiB while the partition still shows 20 GiB. Next compare df -hT, which reports the mounted filesystem’s usable size and type. Follow the layers in that order to see where the resize stopped. After growing the appropriate layers, repeat the same measurements and confirm you can still read a lab file.

In the cloud you can make a volume bigger, but Linux does not use the new space until you grow the partition and the filesystem.

1 resize the volume in the cloud. 2 lsblk shows the disk bigger. 3 sudo growpart DISK N grows partition N (from cloud-utils-growpart). 4 grow the filesystem: xfs_growfs MOUNTPOINT for xfs, resize2fs DEV for ext4. All online.

  1. Disk is bigger.
lsblk /dev/nvme0n1

Output:

nvme0n1     40G disk
└─nvme0n1p1 20G part /

Partition still 20G.

  1. Grow partition.
sudo growpart /dev/nvme0n1 1

Output:

CHANGED: partition=1 start=4096 old: size=41938911 end=41943007 new: size=83881951

Partition 40G.

  1. Grow xfs.
sudo xfs_growfs / && df -h /

Output:

data blocks changed from 5242363 to 10485243
/dev/nvme0n1p1 40G 11G 29G 28% /

Done online.

  1. Grow ext4.
sudo resize2fs /dev/sdc1

Output:

The filesystem on /dev/sdc1 is now 13107200 (4k) blocks long.

ext4 way.

10. Swap: mkswap, swapon, swap file

Small servers can crash with out-of-memory. Swap gives a little slow extra memory so the kernel does not kill the app immediately.

Swap file: fallocate -l 2G /swapfile (or dd), chmod 600, mkswap, swapon. swapon --show and free -h show it. fstab line: /swapfile none swap sw 0 0. vm.swappiness (0-100) controls how eager the kernel is to swap.

  1. Create 2G swap.
sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile

Output:

Setting up swapspace version 1, size = 2 GiB

Active.

  1. Check.
swapon --show; free -h | grep -i swap

Output:

NAME      TYPE SIZE USED PRIO
/swapfile file   2G   0B   -2
Swap: 2.0Gi 0B 2.0Gi

In use.

  1. Permanent.
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Output:

/swapfile none swap sw 0 0

After reboot too.

  1. Less eager.
sudo sysctl vm.swappiness=10

Output:

vm.swappiness = 10

Prefers RAM.

11. Checking and repairing filesystems: fsck, xfs_repair

After a crash or power loss, a filesystem may be marked dirty or refuse to mount.

Never repair a mounted filesystem. ext4: umount, then fsck -f DEV (or e2fsck). xfs: umount, then xfs_repair DEV (xfs_repair -n only checks). For the root filesystem use rescue mode or attach the disk to another server.

  1. Check ext4.
sudo umount /logs && sudo fsck -f /dev/sdc1

Output:

Pass 1: Checking inodes, blocks, and sizes
/dev/sdc1: 11/1966080 files, 167971/7864320 blocks

Clean.

  1. Check xfs without changes.
sudo umount /data && sudo xfs_repair -n /dev/nvme1n1p1

Output:

Phase 1 - find and verify superblock...
No modify flag set, skipping filesystem flush and exiting.

Read-only check.

12. Real examples from many industries

The same Linux skill shows up in every kind of company. Seeing it in many places helps you remember it.

Each row is a made-up team. It shows who uses this and how.

Team and cityHow they use itCommand
Pooja, analytics, PuneAdds data disks with UUID fstab linesblkid -s UUID -o value DEV
Liam, media, SydneyGrows root volumes onlinegrowpart /dev/nvme0n1 1 && xfs_growfs /
Hana, robotics, SeoulScripts partitions with partedparted -s DISK mklabel gpt mkpart data xfs 0% 100%
Diego, retail, LimaAdds swap on small instancesfallocate -l 2G /swapfile
Grace, hospital, AccraUses nofail for extra disksdefaults,nofail 0 0
Sagar, school ERP, SolapurTests fstab before rebootmount -a && findmnt --verify

13. Common errors and how to fix them

Everyone hits these errors. Knowing the cause saves hours.

Read the exact message first. Then match it to a row below.

Error you seeWhy it happensHow to fix
mount: wrong fs type, bad option, bad superblockNo filesystem yet, or wrong typeCheck with lsblk -f; mkfs if new.
lsblk -f
umount: target is busyA process uses the mountFind and stop it.
sudo fuser -vm /data
Boot stops in emergency modeBad /etc/fstab lineFix fstab from the emergency shell; use nofail.
findmnt --verify
mkfs: appears to contain an existing filesystemDisk already has dataConfirm it is the right disk before -f.
lsblk -f
Re-reading the partition table failed: Device or resource busyKernel did not reload tableRun partprobe.
sudo partprobe /dev/nvme1n1
NOCHANGE: partition 1 is size ... it cannot be grownVolume not resized yetResize in the cloud first.
lsblk
df still shows old sizeFilesystem not grownRun xfs_growfs or resize2fs.
sudo xfs_growfs /
swapon: /swapfile: insecure permissions 0644Swap file readable by otherschmod 600.
sudo chmod 600 /swapfile
mount point /data does not existDirectory missingCreate it.
sudo mkdir -p /data
xfs_growfs: is not a mounted XFS filesystemPassed device or wrong pathPass the mount point.
sudo xfs_growfs /data

14. Troubleshooting step by step

When a disk is missing or full of surprises, check from bottom to top.

Go top to bottom. Stop at the first step that shows the problem.

  1. Is the disk seen?
lsblk
  1. Partition and filesystem?
lsblk -f
  1. UUID?
sudo blkid
  1. Mounted where?
findmnt -T /data
  1. fstab valid?
sudo findmnt --verify
  1. Kernel messages?
dmesg -T | tail -20

15. Lab 1: Add a disk end to end with a loop device

Practise the full flow safely using a file as a disk.

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

  1. Make a 1G file disk.
truncate -s 1G /tmp/disk.img && sudo losetup -fP --show /tmp/disk.img

Output:

/dev/loop0
  1. Partition.
sudo parted -s /dev/loop0 mklabel gpt mkpart lab ext4 0% 100%

Output:

(no output)
  1. Filesystem.
sudo mkfs.ext4 -L lab /dev/loop0p1

Output:

done
  1. Mount.
sudo mkdir -p /mnt/lab && sudo mount /dev/loop0p1 /mnt/lab && df -h /mnt/lab

Output:

/dev/loop0p1 974M ... /mnt/lab
  1. Clean up.
sudo umount /mnt/lab && sudo losetup -d /dev/loop0

Output:

(no output)

16. Lab 2: Swap file and fstab test

Add a 512M swap file and prove fstab entries with mount -a.

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

  1. Create.
sudo fallocate -l 512M /swaplab && sudo chmod 600 /swaplab && sudo mkswap /swaplab

Output:

Setting up swapspace
  1. Enable.
sudo swapon /swaplab && swapon --show

Output:

/swaplab file 512M
  1. Verify fstab.
sudo findmnt --verify

Output:

Success
  1. Disable.
sudo swapoff /swaplab

Output:

(no output)
  1. Remove.
sudo rm /swaplab

Output:

(no output)

Ravindra Bagale's Tip

In /etc/fstab always use UUID= and, for any disk except root, add nofail. Then run sudo mount -a and sudo findmnt --verify before you reboot. These three habits prevent the classic 'server will not boot after adding a disk' outage.

17. Frequently asked questions

Q. fdisk or parted?

fdisk for interactive work; parted -s for scripts and large disks.

Q. xfs or ext4?

Use the distro default; xfs cannot shrink, ext4 can offline.

Q. Do I need a partition at all?

Not strictly, but a partition makes it clear the disk is used.

Q. Why UUID in fstab?

Device names can change; UUIDs do not.

Q. What is nofail?

Boot continues even if that disk is missing.

Q. How much swap?

Small servers: 1-2G; large memory servers often little or none.

Q. Can I grow root without reboot?

Yes: growpart then xfs_growfs or resize2fs.

Q. What is a loop device?

A file used as a disk, good for practice.

18. Interview questions and answers

Beginner level

Q. List disks?

lsblk.

Q. Show UUIDs?

blkid.

Q. Make xfs filesystem?

mkfs.xfs DEV.

Q. Make mounts permanent?

Add to /etc/fstab.

Mid level level

Q. Test fstab without reboot?

mount -a and findmnt --verify.

Q. umount says busy?

fuser -vm or lsof to find the process.

Q. Grow root after EBS resize?

growpart DISK 1 then xfs_growfs /.

Q. Add swap file?

fallocate, chmod 600, mkswap, swapon, fstab.

Senior level

Q. Server stuck in emergency mode after disk change?

Boot rescue, fix fstab (UUID, nofail), findmnt --verify, reboot.

Q. Need to shrink an xfs volume?

Not possible; create smaller, copy data, switch.

Q. Automate data disk setup?

cloud-init or Ansible with parted -s, mkfs, fstab with UUID and nofail.

Q. NVMe names change order on Nitro, how to handle?

Use UUIDs or /dev/disk/by-id symlinks.

Try at home

  1. Do Lab 1 again with xfs instead of ext4 and add the fstab line with nofail, then test with mount -a.
  2. Draw your server's disk tree from lsblk -f on paper and label every part.

Practise this chapter

Interview questions and answers

The cloud console shows a larger disk, but df is unchanged. Explain the next checks.

Use lsblk to check the local device and partition sizes. If there is LVM, check the logical volume too. Then check the type and size of the mounted filesystem. Grow the required layers in order and repeat the same checks. Verify a test read at the application path.

Check your understanding

Choose an answer, then compare your reasoning with the explanation.

0 of 3 answered correctly
1. What is the mount point in a storage diagram?

Answer and explanation

B. A directory through which a filesystem is accessed

A mount supplies access to the filesystem at that directory. UUID identifies the filesystem and partitions divide the device.

2. What does a blank FSTYPE in lsblk prove before formatting?

Answer and explanation

A. Only that no filesystem type was reported for that row

Confirm identity, partitions, signatures and intended use before formatting. A blank type is incomplete evidence.

3. Which check shows the current device mounted at /data?

Answer and explanation

C. findmnt /data

findmnt reports the active mount source and target. The directory listing and saved mount table do not prove what is mounted now.

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

Milan Furniture is a furniture business in Milan. Giulia Rossi looks after its IT and cloud work. They count money in EUR and run their AWS resources in the eu-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 18

Easy Filesystems in tree

Disks hold everything BIZ stores.

Show /dev/xvdg with filesystem type and UUID.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy One disk

Disks hold everything BIZ stores.

Show only /dev/xvdg in the tree.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy UUID of one

Disks hold everything BIZ stores.

Show blkid info for /dev/xvdg1.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy List partitions

Disks hold everything BIZ stores.

List the partition table of /dev/xvdg with fdisk.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Make xfs

Disks hold everything BIZ stores.

Make an xfs filesystem on /dev/xvdh1 with label media.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Make ext4

Disks hold everything BIZ stores.

Make an ext4 filesystem on /dev/xvdg1.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Mount it

Disks hold everything BIZ stores.

Mount /dev/xvdh1 on /media.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy What is mounted

Disks hold everything BIZ stores.

Show what is mounted on /media.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Test fstab

Disks hold everything BIZ stores.

Mount everything in fstab and print each result.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Script a GPT label

Disks hold everything BIZ stores.

Create a GPT label on /dev/xvdh with parted in script mode.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Reload table

Disks hold everything BIZ stores.

Tell the kernel to re-read partitions of /dev/xvdh.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Read-only mount

Disks hold everything BIZ stores.

Mount /dev/xvdg1 read-only on /mnt/old.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Who is busy

Disks hold everything BIZ stores.

Show which processes use the /media mount.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Verify fstab

Disks hold everything BIZ stores.

Check /etc/fstab for errors without mounting, with full details.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Show swap

Disks hold everything BIZ stores.

Show active swap areas with sizes in bytes.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Disable a swap file

Disks hold everything BIZ stores.

Turn off swap file /swap2.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Grow partition 2

Disks hold everything BIZ stores.

Grow partition 2 of /dev/xvda to fill the disk.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Grow ext4

Disks hold everything BIZ stores.

Grow the ext4 filesystem on /dev/xvdg1.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

In short

  1. lsblk and blkid find disks and UUIDs.
  2. fdisk (menu) and parted -s (script) make partitions.
  3. mkfs.xfs and mkfs.ext4 create filesystems.
  4. mount, findmnt, umount, fuser.
  5. fstab with UUID, nofail; test with mount -a.
  6. growpart + xfs_growfs/resize2fs; swap with mkswap/swapon.

Revision, comparison and interview cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

New disk in 4 steps. Find it: lsblk. Partition, then mkfs. Mount and add to fstab by UUID. Test fstab.
Revision card: New disk in 4 steps · Download PNG · Open card page
Swap file in 4 steps. Extra memory on disk. fallocate, chmod 600. mkswap, swapon. Check.
Revision card: Swap file in 4 steps · Download PNG · Open card page
ext4 vs xfs. Can grow and shrink. / Can only grow.
Comparison: ext4 vs xfs · Download PNG · Open card page
fdisk vs parted. Interactive menu. / Scriptable commands.
Comparison: fdisk vs parted · Download PNG · Open card page
Why UUID in fstab?. Device names can change. UUID stays the same. Find it.
Interview card: Why UUID in fstab? · Download PNG · Open card page
umount: target is busy?. A process uses it. Find and stop it. Who?
Interview card: umount: target is busy? · Download PNG · Open card page
Grow a cloud disk?. Resize the volume. growpart, then grow the fs. XFS.
Interview card: Grow a cloud disk? · Download PNG · Open card page
fdisk vs parted?. fdisk: interactive. parted: scriptable, big GPT. List.
Interview card: fdisk vs parted? · Download PNG · Open card page

More cards: Ravi Sir's Cards.