Welcome to the Linux Foundation Forum!

LFS201 - Chapter 16 Discussion // Questions // Banter

Referring to chapter 16 - Linux Filesystems and the VFS, I created a bash script to run the Demo: Filesystems

The script creates a 512M junk file filled with zeros, then creates a xfs file system inside, then mounts it. It then prints some info, unmounts and deletes the file.

  1. #!/bin/bash
  2. # xfs exercise
  3.  
  4. # Create file "junk" filled with zeros (512 Mbyte)
  5. cmd="dd if=/dev/zero of=junk bs=1M count=512"
  6. echo "$cmd"
  7. ${cmd}
  8. echo -e "\n"
  9.  
  10. # Create a xfs file system inside junk
  11. cmd="sudo mkfs.xfs junk"
  12. echo "$cmd"
  13. ${cmd}
  14. echo -e "\n"
  15.  
  16. # Mount the xfs file system to /mnt
  17. # Note: there is no need for the -o loop option as Linux can figure out the
  18. # loop file system by itself :-)
  19. cmd="sudo mount junk /mnt"
  20. echo "$cmd"
  21. ${cmd}
  22. echo -e"\n"
  23.  
  24. # See if it's mounted
  25. cmd="df"
  26. echo "$cmd"
  27. ${cmd}
  28. echo -e "\n"
  29.  
  30. # Here the output line relating to the xfs file system:
  31. #/dev/loop0 518816 30092 488724 6% /mnt
  32.  
  33. # Let's check if it's really a xfs file system:
  34. cmd="grep xfs /proc/mounts"
  35. echo "$cmd"
  36. ${cmd}
  37. echo -e "\n"
  38.  
  39. # We could now create or copy content to the xfs file system, but we
  40. # unmount
  41. cmd="sudo umount /mnt"
  42. echo "$cmd"
  43. ${cmd}
  44. echo -e "\n"
  45.  
  46. # and delete the file
  47. cmd="rm junk"
  48. echo "$cmd"
  49. ${cmd}

Perhaps you find it useful to play around or file the commands.

Comments

  • Posts: 1,274

    Hi @heiko_s , that's great! Perhaps you could share/demonstrate it with the participants, when we get there.

    Many regards,
    Luis.

  • Posts: 916

    We've tended not to apply many such scripts for exercises because I have done it in other courses and found students would run the scripts and think they understand the subject, but not (at their fingertips, or easily researched) be able to do the same steps on their own. (i.e., learning is more difficult but more solid when you do things. I did not look in detail at the script you supplied but it looks quite nice and I'm sure some students will find it quite useful. However, I encourage them to study it, and reproduce many of the steps by hand!

    BTW, I'm not sure if all distributions have xfs and its tools installed by default. RHEL/CentOS/Fedora do as they have it as a default filesystem, but I'm not sure about Ubuntu or OpenSUSE. -- I just checked xfs-tools is installed on Ubuntu 20.04 and the kernel knows xfs, so OK there.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training