Linux File System Flashcards

1
Q

Key Fundamental of Unix

A

Everything is a file, including:
- pipes
- sockets
- processes
- USB ports
- printers
- hard drives
- kernel data structures
This allows us to use syscalls on everything.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Representation of File Systems in Linux

A

Users can see the file systems as a tree-like structure, the logical representation (abstraction).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Top Level Directories

A

Each Linux file system has certain top level directories. Some examples include:
/root
/boot
/dev
/home
/proc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

/root directory

A

Home directory of the root user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

/boot directory

A

Files needed while the system is booting

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

/dev directory

A

Virtual files mapped to physical devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

/home directory

A

Home directories for every user on the system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

/proc directory

A

Virutal files mapped to running processes (including housekeeping)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

EXT4 File System

A

Common file system for linux.
High performance, limited required maintenance.
Disk size being 1 exabyte.
Individual files being 16 TB.
Standard disk block being 4 KB up to 64KB.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

EXT4 Disk Format

A

Super Block -> EXT4 settings and flags (housekeeping).
Group Descriptors -> block locations of data bitmap, inode bitmap and inode table.
Reserved Space -> free space allowing more groups to be added to group descriptors.
Data Bitmap -> freelist for blocks.
Inode Bitmap -> free inode list for inodes.
Inode Table -> table of inode data (metadata).
Data Blocks -> physical data for files.
(note that data bitmap, inode bitmap and inode table can be repeated).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Inode Information

A

Every file has an inode associated with it, which includes:
- size
- owner
- group
- octal permissions value
- type of inode (normal file, directory, symbolic link etc)
- timestamps (created, modified)
- start and end block numbers of actual data
Filenames are stored in directory files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Nested Directories

A

Since directories can be nested, some of the inodes listed in the directory block could point to other directory blocks.
For example, we could have a directory /home/scap21/work/file3.c. We first then look at home directory, and find out that scap21 has information, or metadata, which is stored on inode 34.We then read inode 34, which contains start and end block numbers which represents the data of scap21. We then go to where this start block number is, and read the blocks/file until the end block number. Now lets say this block contains information on work, specifically the location of work’s inode. We, again, to the work’s inode, find where the block is, and find where file3.c’s inode is, and then its block.

Remember, we can have multiple sections of blocks. We can have two start and ends blocks, but then this is still read normally and in order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Symbolic Link (hard and soft)

A

A symbolic link can be used to references a file/directory. There are two ways of doing this:
Hard Link -> gives files a second filename with the ln command. It creates a new directory entry that points to the same inode as the original file or directory, giving two points of reference for the same directory.
For example, let’s say you have a file named “file1.txt” in your home directory, and you want to create a hard link to it called “file2.txt” in the same directory. We use ln file1.txt file2.txt which creates this, and points both of these at the same inode.
Soft Link -> creates a new file and stores the original file’s name in it.
For example, let’s say you have a file named “file1.txt” in your home directory, and you want to create a soft link to it called “file2.txt” in the same directory. We use ln -s file1.txt file2.txt, which points file2.txt at file1.txt.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Scattering

A

New files are spread evenly across disk, allowing contiguous growth and reduces defragmentation of files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Delayed Allocation

A

Creates virtual blocks in memory while file is written, and commits to physical blocks when file size is known. This allows system to find contiguous free space on disk, but lost data could occur if memory is eventually not written on disk.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Journaling

A

Part of the disk is used to store a journal of changes made to inodes and data blocks, which makes writing slightly slower but helps recovery from crash.

17
Q

Persistent pre-allocation

A

A syscall can be used to preserve space, with blocks being allocated before data arrives. Can be used to guarantee a contiguous set of blocks for a file as well as improving read/write speeds for media streaming and database applications.

18
Q

Standard Streams

A

stdin -> standard input
stdout -> standard output
stderr -> standard error
Programs use these syscalls to access the standard streams, for example, in java we use System.out, for python we use sys.stdout etc.

19
Q

File Descriptors

A

Every open file has a file descriptor, which is a unique integer value used by syscalls instead of file names which represents the open file. These are used by processes to interact with these open files.