2026-07-18 14:03

Status:


OS&Y - Module 4 - Filesystems

==Filesystem Types

  • Review of Filesystems:
    • A filesystem is used to keep track of files and file storage on a disk

    • If you have a new storage device like an HDD or even a usb, you need to add in a filesystem for it

    • The two main file systems are NTFS for windows and ext 4 in linux

    • ext 4 can read both NTFS and itself, while NTFS can only read NTFS

    • File systems like FAT 32 are able to support ALL types of operating systems

    • But it does not read files more than 4 GB in space, and the filesystem itself cannot be more than 32 GB in space

  • Supplemental Reading for FAT 32 File System:
    • For more information about the FAT32 File System, please check out the link here.
  • Disk Partitioning and File System Essentials:
    • A storage disk can be divided out into different Partitions

    • Partition- the piece of a disk that you can manage

    • It gives you the illusion of dividing a single disk into multiple disks

    • You can partition your disk into multiple different operating systems and boot into either one, like I currently am, running kubuntu and windows 11

    • Whenever you format a filesystem on a partition, it becomes a volume

    • Partition Table- tells the OS how the disk is partitioned

    • It tells you which partitions you can boot from, how large they are, their order, and other such data

    • Two labels in a partition table are Master Boot Record (MBR) and GUID Partition Table (GPT)

    • MBR has a max volume size of around 2 TB and is used to store primary partitions, with only 4 primary partitions being allowed at a time. If you want more than 4 of these partitions, you need to extend out one of the root 4, and then inside the extended partition, you can make something called a Logical Partition.

    • MBR is unfortunately becoming dated and not used as often

    • GPT is becoming more common, you can have a volume type of 2 TB or greater, it only has one type of partition, and you can make as many different partitions as you wish

    • To use UEFI booting, you basically need to use this GPT partitioning format

  • Windows: Disk Partitioning and Formatting a Filesystem:
    • Disk management software this is how you can manage your disks inside of windows

    • It shows you the type of filesystem that you have, and also things like size and the different partitions that you might have

    • You can change the filesystem that you want as well as it’s name using the format right click inside of the disk management software

    • You can also change the Allocation Unit Size which changes the granular portions of your drive, and the different chunks in which the actual data will be stored

    • You can also allow compression, which will compress your files, but whenever you try to open them it will take more processing power in order to unzip them every time you want them opened

    • You can also do a lot of this from the terminal using a tool called diskpart, which I have a little bit of experience from

  • Windows: Mounting and Unmounting a Filesystem:
    • Mounting- making something accessible to the computer, like a filesystem or a hard disk
    • Windows generally is able to do this for automatically
    • You can also choose to eject things like USBs in order to unmount them
  • Linux: Mounting and Unmounting a Filesystem:
    • The mounted drives exist as files in the /dev directory, and are often referred to by /dev/sdx depending on when they were mounted

    • The sudo parted -l command lists for you all of your mounted drives, their partitions, and a lot of other information about them, like where they start, end, file system, and some flags / name

    • check General Commands For Command Line Interfaces for how to use the parted command to more efficiently change this data

  • Supplemental Reading Mounting and Unmounting a filesystem in Linux:
    • Even though you might have already set up the disk, you are unable to interact with it just yet. In order to do that, you first have to actually mount the disk in a directory to be able to read and write data to it

    • The reason for this is because the /dev/sda files are just that, files, not directories

    • You need to create a directory, and then mount that drive partition over to that directory

    • This is done with the mount command, which takes in the file for the /dev location, as well as then the file you want to mount to

    • Most operating systems generally do this automatically for you though

    • A lot of data about what kinds of mount points you have can be seen inside of the etc/fstab tab of the linux file system

    • Basically, this file helped to automate the mounting processes inside of linux during the boot process

    • Pasted image 20260718151828.png

    • Here are some of the configuration tables for the fstab configuration

      • Column 1 - Device: The universally unique identifier (UUID) or the name of the device to be mounted (sda1, sda2, … sda#).

      • Column 2 - Mount point: Names the directory location for mounting the device. 

      • Column 3 - File system type: Linux file systems, such as ext2, ext3, ext4, JFS, JFS2, VFAT, NTFS, ReiserFS, UDF, swap, and more.

      • Column 4 - Options: List of mounting options in use, delimited by commas. See the next section titled “Fstab options” below for more information.

      • Column 5 - Backup operation or dump: This is an outdated method for making device or partition backups and command dumps. It should not be used. In the past, this column contained a binary code that signified:

        • 0 = turns off backups
        • 1 = turns on backups
      • Column 6 - File system check (fsck) order or Pass: The order in which the mounted device should be checked by the fsck utility:

        • 0 = fsck should not run a check on the file system.
        • 1 = mounted device is the root file system and should be checked by the fsck command first.
        • 2 = mounted device is a disk partition, which should be checked by fsck command after the root file system.
  • Windows: Swap:
    • Virtual Memory- How our OS provides the physical memory available in our computer (like RAM) to the applications that run on the computer

    • Swap memory dedicates a portion of the harddrive in order to be able to read and write to it as though it were basically a stick of RAM, this however is obviously much slower than regular ram

    • The data inside of the HDD is stored in pages, basically how it would have been stored inside of RAM

    • Also, the most commonly used data pages are stored inside of ram, and then those that have not been used in a little while are basically stored on the disk, so they can still be accessed faster than loading them into memory for the first time again

    • Windows uses a program called a Memory Manager in order to take care of virutal memory

    • It takes care of paging and mapping that virtual to physical memory

    • It uses a portion of the partition called the Page File. sys and it uses these page files that it creates and it uses the memory manager to copy pages of memory to be read as needed

  • Linux: Swap:
    • Swap space- In Linux, the dedicated area of the hard drive used for virtual memory
    • This can be created via the disk partitioning tools in the above notes
    • It is recommended to follow linux guidelines for this space however
  • Windows: Files:
    • How does NTFS store and showcase the files on our operating system

    • How does it store file data, and also the file metadata

    • NTF uses the Master Files Table (MFT) in order to keep everything straight

    • It keeps an entry for EVERY single file on the drive, there is usually a one to one correspondence between files and MFT entries, however if a file has a whole bunch of attributes it might have more than one

    • A MFT Entry generally holds the metadata for a file, like it’s name, creation time, compressed, location, etc.

    • Whenever a file is deleted, their entries in the MFT are marked as free so they can be reused, but they still hold all the old metadata (so you are never safe)

    • File record number- this is the entry index inside of the MFT

    • Shortcut- another file that has an entry inside of the MFT, but it basically only stored a reference to another file so it can be opened easily

    • NTFS also provides other ways to create these kinds of shortcuts, hard links, and symbolic links

    • Symbolic Links are like shortcuts but at the file system level. Whenever you create one, you basically create a shortcut, but on that points at another file inside of the MFT table. The OS treats them as a substitute for the file they link to in almost every single meaningful way. Basically letting you use them inside of the cmd

    • Hard Link- an entry is added to the MFT that points to the linked file record number, not the name of the file, meaning that the name can still change, but the shortcut to it will not

  • Supplemental Reading on NTFS File system:
  • Linux: Files:
    • Linux organizes it’s files inside of something called I-Nodes which are similar to the windows MFT records

    • The I-Node does not store the file data or the file name, but it does store all of the other metadata

    • Softlink- works in a similar way to how symbolic links work inside of windows

    • They are great for creating shortcuts to other files on your drive

    • Hardlink- similar to windows, they link to an inode that is stored inside of an inode table on the disk

    • The third field inside of the ls -l command is actually the number of hard links it has

    • If that number is zero, then that file has been completely removed from the computer

  • Windows: Disk Usage:
    • To check your disk usage, you can open up the Computer Management utility inside of windows

    • You can right click the partition you are interested in, and you are able to see the properties of your drive

    • You can also then use a command line tool called Disk Usage which can print out how much space something has, it is basically another tool that lets you see your free or used space in text form

    • There is also a disk cleanup button, which launches the cleanmgr. exe which basically tries it’s best to clean up some space by deleting temp files, compressing rarely used / old files, and then also clearing your recycle bin

    • There is also another thing called defragmentation which takes all the files stored on a given disk, and reorganizes them into neighboring locations, this is primarily a thing for HDD and not SSD drives, SSD drives instead use trim

  • Linux Disk Usage:
    • You can use this via the du -h command, it shows you the disk usage of a specific directory
    • It is good for files inside of a file in a directory
    • Linux does not fragment the same way that Windows does
  • Windows: Filesystem Repair:
    • If do not safely eject a given drive or something like that, you might get an error

    • This is because it might still be reading or writing data over to that drive

    • This is because it is put into a Data Buffer first, which is a region of RAM that is used to temporarily store data while it is being moved around

    • If you do not give the buffer enough time to move the data, then you can corrupt the data you are moving

    • The NTFS data system has some things built in to help prevent against data corruption

    • NTFS Journaling- basically stores the data into an NTFS log, it creates a history of the actions it has taken, and it can see what the current file system should be. So if a crash happens, it can use that log to try and repair what happened

    • Self-Healing- makes changes to minor problems on the disk in the background while windows is running, can be seen with fsutil repair query C:

    • NTFS Check Disk- basically when shit gets really bad

  • Linux: Filesystem Repair:
    • To try and repair a filesystem manually in linux, you can try and use the fsck command, just make sure that the file system is unmounted before hand
  • Supplemental Reading for Linux Filesystem Repair:

==Glossary

Command line mode: When you are able to run commands while still in your current shell

Data: Actual content of a file

Data buffer: A region of RAM that’s used to temporarily store data while it’s being moved around

Defragmentation: A process of taking all the files stored on a given disk and reorganizing them into neighboring locations

Disk Management utility: Native tool for Windows that helps with managing disk space

File record number: The index of the files entry in the MFT

File system: Used to keep track of files and file storage on a disk

Hard link: When created in NTFS, an entry is added to the MFT that points to the linked file record number, not the name of the file. This means the file name of the target can change and the hard link will still point to it

Inode: A file structure for metadata and files

Interactive mode: When the parted tool launches you into a separate program

Master boot record (MBR): a traditional partition table within a storage disk that lets you have volume sizes of 2 terabytes or less and is mostly used in the Windows OS

Master file table (MFT): A way NTFS stores and represents the files you’re working with on your operating system

Memory manager: A Windows OS program that helps manage virtual memory 

Metadata: Tells us everything we need to know about a file, including who created it, when it was last modified, who has access to it, and what type of file it is.

Mounting: Making a file or hard disk accessible to the computer

Partition table: How the disk is partitioned on an OS

Shortcut: An entry in the MFT that has a reference to some destination, so that when you open it up, you get taken to that destination

Softlinks: A shortcut in Linux, that allows us to link to another file using a file name

Swap space: The allocated space where the virtual memory is stored on the hard drive when the amount of physical memory space is used up or full

Symbolic links: Work similarly to shortcuts, but at the file system level. The key difference is that the operating system treats them like substitutes for the file they’re linked to in almost every meaningful way

System properties: A control panel applet that allows you to edit the size and number and location of paging files

Trim: A command to delete unused data blocks so the space can be used for the computer’s storage needs

UEFI: A new standard for BIOS

UUID: Universally Unique ID

Virtual memory: A combination of hard drive space and RAM that acts like memory which our processes can use

Volume: A format for a filesystem on a partition


References