Filesystem
used to keep track of files and file storage on disk.
-
Windows is recommended to use NTFS Filesystem
-
Ubuntu is recommended to use ext4 Filesystem
-
FAT32 supports reading and wrting data to Windows, Linux, Mac Os
Disk Anatomy
-
Partition -> the piece of disk you can manage.
-
Volume -> when a filesystem is formatted on a partition, it becomes a volume.
-
Partition Table -> tells the OS how the disk is partitioned.
- MBR(Master Boot Record) : traditional partition table, mostly used in Windows. only have 4 primary partitions
- GPT(GUID Partition Table) : new standard for disks. has one type of partition. you can have as many as you want.
-
UEFI -> default BIOS for newer systems. to boot, must use GPT.
-
Mounting -> make something accessible to the computer, like filesystem or hard disk
Windows
- Diskpart -> terminal based tool for managing disks right from the command line.
- list disk : list disks
- select disk 1 : select a disk
- clean : clean the disk
- create partition primary : create partition in selected disk
- select partition 1 : select created parition
- active : make selected partition active
- format FS=NTFS label=my-thumb-drive quick : format disk
Linux
- Parted Tool -> supports both MBR and GPT partitioning
-
Partition a disk
- parted -l : list disks
- parted /dev/sdb : select a disk
- print : show status
- mklable gpt : make lable with string
- mkpart priamry ext4 1MiB 5GiB : make partition with necessary informations.
-
Add Filesystem
- mkfs -t ext4 /dev/sdb1 : add filesystem
-
Mount for use
- mount /dev/sdb1 /my_usb : mount the disk to a directory
- now you can read and write data in the disk
- /etc/fstab : add an entry automatically mount filesystems when the computer boots
- sudo blkid : shows UUID for block device IDs aka storage device IDs.
Swap
- Virtual Memory -> how our OS provides physical memory available in our computer(like RAM) to the application that run on the computer
- swap space -> where we allocate virtual memory on our hard drives
- mkpart primary linux-swap 5GiB 100% -> make swap partition
- sudo mkswap /dev/sdb2 -> make swap space
- sudo swapon /dev/sdb2 -> enable swap on device
Files
when OS handles files
it actually handles
- file data -> actual contents
- file metadata -> owner, permissions, size, location etc..
- file system
Windows
-
MFT -> Master File Table
every file on volume has at least one entry.
-
shortcut -> another file, another entry on MFT. has reference to some destination.
-
symbolic link -> points to the name of another entry or another file. OS treats then like substitutes for the file
Linux
- inode -> we store inodes in an inode table and they help us manage files on our file system.
- softlink -> point to another file
ln -s
- hardlinks -> link to an inode
ln