Week 4
File Systems
Building the Root File System
2
The Master Boot Record
3
MBR
Partition 1
(ext3)
Partition 2
(swap)
Partition 3
(NTFS)
Partition 4
(FAT32)
Address | Description | Size (Bytes) | |
Hex | Dec. | ||
0x000 | 0 | Bootstrap code area | 446 |
0x1BE | 446 | Partition Entry #1 | 16 |
0x1CE | 462 | Partition Entry #2 | 16 |
0x1DE | 478 | Partition Entry #3 | 16 |
0x1EE | 494 | Partition Entry #4 | 16 |
0x1FE | 510 | Magic Number | 2 |
| | Total: | 512 |
Includes the starting LBA and length of the partition
Disk 1
MBR
Partition 1
(NTFS)
Disk 2
Extended Partitions
4
Partition 1
(ext3)
Partition 2
(swap)
Partition 3
(Extended Partition)
Partition 4
(FAT32)
Disk 1
Logical Partition 1
(NTFS)
Logical Partition 2
(NTFS)
MBR
Ext. Part.
Types of Root File Systems
5
[cbw@ativ9 ~] df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda7 39G 14G 23G 38% /
/dev/sda2 296M 48M 249M 16% /boot/efi
/dev/sda5 127G 86G 42G 68% /media/cbw/Data
/dev/sda4 61G 34G 27G 57% /media/cbw/Windows
/dev/sdb1 1.9G 352K 1.9G 1% /media/cbw/NDSS-2013
1 drive, 4 partitions
1drive, 1 partition
Mounting a File System
6
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 127G 86G 42G 68% /media/cbw/Data
/dev/sda4 61G 34G 27G 57% /media/cbw/Windows
/dev/sdb1 1.9G 352K 1.9G 1% /media/cbw/NDSS-2013
Virtual File System Interface
7
VFS Flowchart
8
Kernel
Process 1
Process 2
Process 3
Virtual File System Interface
ext3 Driver
NTFS Driver
FAT32 Driver
ext3 Partition
NTFS Partition
FAT32 Partition
Processes (usually) don’t need to know about low-level file system details
Relatively simple to add additional file system drivers
Mount isn’t Just for Bootup
9
Status Check
10
The Directory Tree
11
home
/ (root)
bin
tmp
python
cbw
amislove
cs5600
Absolute and Relative Paths
12
Files
13
File Extensions
14
Rename
Has the data in the file changed from music to an image?
More File Meta-Data
15
Disk
Mapping Files to Blocks
16
0
2
3
4
5
7
9
1
8
6
[1]
[4, 5, 7, 8]
[6]
List of blocks
0
2
3
4
5
6
8
1
7
9
(1, 1)
(4, 4)
(9, 1)
As (start, length) pairs
Directories
17
/ (root)
bin
python
.
..
“.” self pointer
“..” points the the parents directory
More on Directories
18
Example Directory File
19
2
3
4
5
6
7
8
9
Disk
C:\
Windows
Users
C:\
Name | Index | Dir? | Perms |
. | 2 | Y | rwx |
Windows | 3 | Y | rwx |
Users | 4 | Y | rwx |
pagefile.sys | 5 | N | r |
1
0
pagefile.sys
Directory File Implementation
Name | Index | Dir? | Perms |
. | 2 | Y | rwx |
Windows | 3 | Y | rwx |
Users | 4 | Y | rwx |
pagefile.sys | 5 | N | r |
Unordered List of Entries
Name | Index | Dir? | Perms |
. | 2 | Y | rwx |
pagefile.sys | 5 | N | r |
Users | 4 | Y | rwx |
Windows | 3 | Y | rwx |
Sorted List of Entries
File Allocation Tables (FAT)
21
22
Super Block
Disk
23
2
3
4
5
6
7
8
9
Super Block
Disk
C:\
Windows
Users
2
3
4
5
6
7
8
9
Root directory index = 2
C:\
Name | Index | Dir? | Perms |
. | 2 | Y | rwx |
Windows | 3 | Y | rwx |
Users | 4 | Y | rwx |
pagefile.sys | 5 | N | r |
Fat Table Entries
24
Fragmentation
25
68
67
65
64
63
62
61
60
59
58
57
56
0
61
67
0
58
0
0xFFFF
0
0
65
0
0
68
67
65
64
63
62
61
60
59
58
57
56
FAT
Blocks
Start
End
Possible values for FAT entries:
FAT: The Good and the Bad
26
File Systems for SSDs
27
Copy-on-write
28
Versioning File Systems
29
Thank You
30