Filesystem Attributes Name Ownership Type Position Size - - PowerPoint PPT Presentation

filesystem
SMART_READER_LITE
LIVE PREVIEW

Filesystem Attributes Name Ownership Type Position Size - - PowerPoint PPT Presentation

Calcolatori Elettronici e Sistemi Operativi File Logical unit of storage usually persistent shareable among processes and users Filesystem Attributes Name Ownership Type Position Size Allocated size


slide-1
SLIDE 1

Filesystem

Calcolatori Elettronici e Sistemi Operativi

File

Logical unit of storage

– usually persistent – shareable among processes and users

Attributes

– Name – Type – Size – Permissions – Dates and times

modification creation access

– Ownership – Position – Allocated size

File

Operations

– create – delete – open / close – read / write – seek – resize

Access

– sequential – random

Structure

– none

sequence of bytes

– sequence of records

record: ordered set of “fields”

– complex structure

formatted documents, databases, etc.

– indexes, hash tables, search trees

usually imposed at user level

Directory

Set of files and directories Operations

– inspect directory content – create / delete files/directories – rename files/directories – traversal

slide-2
SLIDE 2

Directory

Organization

– Tree – Acyclic graph – Generic graph

symbolic links hard links

dir1 dir2 fileA fileB dir3 fileC fileD dir4 fileE fileF fileG fileH fileI

Directory

Organization

– Tree – Acyclic graph – Generic graph

symbolic links hard links

dir1 dir2 fileA fileB dir3 fileC fileD dir4 fileE fileF fileG fileH

Allows sharing

Directory

Organization

– Tree – Acyclic graph – Generic graph

symbolic links hard links

dir1 dir2 fileA fileB dir3 fileC fileD dir4 fileE fileF fileG dir

Links

Symbolic link

– just a string to identify the target file/directory

accessing to symlink is translated to accessing the target deleting symlink has no effect on file deleting file “breaks” the symlink can cross filesystems

/ | +-dir1 | | | +-file | +-dir2 | +-symlink

/dir1/file

slide-3
SLIDE 3

Links

Hard link

– another access point to the same file on disk

accessing the hard link is accessing the target file deleting the hard link (or the file) decreases the reference count

– when count=0 the file is actually deleted

cannot cross filesystems

/ | +-dir1 | | | +-file | +-dir2 | +-hardlink

Mount / Unmount

"Modular" hierarchy Connection directory: mount point

Filesystem implementation

Superblock (or boot record, or boot sector) Allocation structures

– FAT, inode tables

Clusters (or blocks)

– Contiguous, fixed size, sets of sectors – Allocation unit

Directories Files

File allocation

Goals:

– minimize access time – reduce management overhead – reduce space wasted

Contiguous

– suitable for read only filesystems (e.g., iso9660)

Linked list

– example: FAT

Indexed

– example: ext2

slide-4
SLIDE 4

Contiguous allocation

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

file pos len test 0 6 doc.txt 6 2 src.tar 8 10 directory

Contiguous allocation

Simple Fragmentation Limited resizing support

– Tradeoff management/efficiency

Unused space between files File reallocation (copy data in the new position)

Need for compaction

– Deleted files holes

Previous issues do not occur on read-only filesystems

Linked list allocation

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

file start len test 0 6 doc.txt 2 2 src.tar 10 10 directory

0 6 22 23 38 33 2 8 10 15 25 26 32 37 36 35 30 20

list1: list2: list3:

Linked list allocation

Simple dynamic management

– tail adding of free blocks in the list

No fragmentation Seek time: O(n) List: critical structure

– A single pointer loss can destroy lot of data

Multiple copies

slide-5
SLIDE 5

Linked list allocation example: FAT

name size start cluster Directory entry 13 16 17

EOF

10 11 12 13 14 15 16 17 18 19 10 11 12 13 14 15 16 17 18 19

{ { { {

Fat entries Clusters

Each FAT entry maps one cluster FATs are allocated in a reserved area

Indexed allocation

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

file idx_tbl len test 0 6 doc.txt 5 2 src.tar 12 10 directory

1 1 38 2 27 3 28 4 29 5 20

idx block

Table 0 3 1 6

idx block

Table 5 15 1 17 2 16 3 22 4 23 5 24

idx block

6 30 7 31 8 33 9 34 Table 12

Indexed allocation

Seek time: O(0) No fragmentation Maximum file size is fixed

– The size of the index table must be defined at creation

Multi-level indexing Linked list of index tables

Maximum number of files is fixed

– Room for the index tables must be allocated at creation

Overhead

– Unused index tables are allocated

Indexed list allocation example: ext2

1 2 3 4 5 idx block ptr 6 7 8 9 10

data blocks data blocks indirect block double indirect block data blocks indirect block double indirect block indirect block triple indirect block data blocks Inside the inode

  • 11

Inodes are allocated in a reserved area. Indirect, double-indirect, and triple indirect blocks are allocated in the data area (they are data blocks among data blocks allocated for files)

slide-6
SLIDE 6

Block size: 4096 bytes Pointer size: 4 bytes Direct pointers: 12 Indirect pointers: 4096/4 = 210 Double indirect pointers: 1024 x 4096/4 = 220 Triple indirect pointers: 220 x 4096/4 = 230 Total allocable blocks: 12 + 210 + 220 + 230 Maximum file size: ~ 4096 x 230 = 242 = 4 TB

Indexed list allocation example: ext2

Actually bounded by nblocks (232) x sector size (512) = 241 = 2TB

Directory

Linear list of entries

– Simple – Search time: O(n)

Hash table

– Search time: O(1) – Collisions

Free blocks

Bitmap

– Reserved disk area: each bit store info on 1 block – Very efficient if buffered – Easy to identify contiguous free blocks – Overhead

Linked list

– No overhead

It can be viewed as a “special” file

Grouping

– As linked list, but each node is a group of blocks

Counting

– As linked list

Each node is the first free block of a free area In each node there is the counter of the following free blocks

Journaled filesystem

Changes are transactions

– Transactions are recorded in a log (special area on disk) – A transaction is complete when completely recorded in log – Recorded transactions are written on filesystem

asynchronously

– Wrote transitions are removed from log

Pending operations can be restored in case of system crash Seeks can be optimized on a very large amount

slide-7
SLIDE 7

Virtual filesystem

Single, uniform file system interface to user processes. Defines a common file model

– filesystem's general feature and behavior. – assumes that files are objects in a computer's mass storage

same basic properties (regardless of the target file system)

– unique name – owner – protection information – can be created, deleted, read, written

Needs a mapping module to the real filesystem

Virtual filesystem

User process

syscall interface VFS ext2 FAT iso9660 NTFS NFS cramfs disk cache device drivers

HW

Operating system

Typical Unix file structure

bin boot dev etc home root user1 user2 lib mnt

  • pt

proc root sbin srv sys tmp usr bin doc include info lib local sbin share src var backups cache lib local lock log mail

  • pt

run spool tmp

VFS – example: linux /proc

1 10 1229 ... acpi asound buddyinfo bus cmdline cpuinfo crypto devices diskstats dma driver execdomains fb filesystems fs ide interrupts iomem ioports irq kallsyms kcore key-users kmsg loadavg locks meminfo misc modules ... sys debug dev fs kernel acct acpi_video_flags bootloader_type cad_pid ... domainname hostname ...

  • srelease

... threads-max unknown_nmi_panic version net vm cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 15 ... cat /proc/ide/ide0/hda/geometry physical 16383/16/63 logical 16383/255/63 cat /proc/sys/kernel/hostname www cat /proc/sys/kernel/osrelease 2.6.28-686

system information (examples)

slide-8
SLIDE 8

Filesystem examples: FAT32 Ext2

Calcolatori Elettronici e Sistemi Operativi

FAT filesystem structure

BS BS2 BS BS2 FAT (1) FAT (2) Root directory DATA (files and directories)

in FAT32 Identical copies File Allocation Table: linked lists of used clusters (a list for each file/directory) Each entry represents a cluster and indicates the next cluster of file/directory In a fixed position for FAT12 and FAT16. Dynamic size for FAT32 Cluster: one or more sectors (cluster size is specified in BS) Clusters 0 and 1 do not exist Cluster 2 is just after FATs

FAT32 Boot record

0000 EB 5A 90 4D 53 57 49 4E 34 2E 31 00 02 01 3E 00 .Z.MSWIN4.1..@>. 0010 02 00 00 00 00 F8 00 00 3F 00 FF 00 3F 00 00 00 ........?...?... 0020 FC 8A 38 01 C5 09 00 00 00 00 00 00 02 00 00 00 ..8..........2.. 0030 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0040 80 00 29 F4 22 B5 94 4E 4F 20 4E 41 4D 45 20 20 ..)."..NO NAME 0050 20 20 46 41 54 33 32 20 20 20 F1 7D FA 33 C9 8E FAT32 .}.3.. 0060 D1 BC F8 7B 8E C1 BD 78 00 C5 76 00 1E 56 16 55 ...{...x..v..V.U 0070 BF 22 05 89 7E 00 89 4E 02 B1 0B FC F3 A4 8E D9 ."..~..N........ 0080 BD 00 7C C6 45 FE 0F 8B 46 18 88 45 F9 FB 38 66 ..|.E...F..E..8f 0090 40 7C 04 CD 13 72 4E BF 02 00 83 7E 16 00 75 71 @|...rN....~..uq 00A0 66 83 7E 24 00 74 6A 8B 46 1C 8B 56 1E B9 03 00 f.~$.tj.F..V.... 00B0 49 40 75 01 42 BB 00 7E E8 90 00 73 2A B0 F8 4F I@u.B..~...s*..O 00C0 74 21 8B 46 32 33 D2 B9 03 00 3B C8 77 43 8B 76 t!.F23....;.wC.v 00D0 0E 3B CE 73 3C 2B F1 3B C6 77 36 03 46 1C 13 56 .;.s<+.;.w6.F..V 00E0 1E EB CD 73 2C EB 49 66 81 BE 00 02 52 52 61 41 ...s,.If....RRaA 00F0 75 CC 66 81 BE FC 03 00 00 55 AA 75 C1 66 81 BE u.f......U.u.f.. 0100 FC 05 00 00 55 AA 75 B6 83 7E 2A 00 77 03 E9 EF ....U.u..~*.w... 0110 02 BE 80 7D FB AC 98 03 F0 AC 84 C0 74 17 3C FF ...}........t.<. 0120 74 09 B4 0E BB 07 00 CD 10 EB EE BE 83 7D EB E4 t............}.. 0130 BE 81 7D EB DF 33 C0 CD 16 5E 1F 8F 04 8F 44 02 ..}..3...^....D. 0140 CD 19 00 00 00 00 00 00 00 00 00 50 52 51 91 92 ...........PRQ.. 0150 33 D2 F7 76 18 91 F7 76 18 42 87 CA F7 76 1A 8A 3..v...v.B...v.. 0160 F2 8A 56 40 8A E8 D0 CC D0 CC 0A CC B8 01 02 CD ..V@............ 0170 13 59 5A 58 72 09 40 75 01 42 03 5E 0B E2 CC C3 .YZXr.@u.B.^.... 0180 03 18 01 27 0D 0A 49 6E 76 61 6C 69 64 20 73 79 ...'..Invalid sy 0190 73 74 65 6D 20 64 69 73 6B FF 0D 0A 44 69 73 6B stem disk...Disk 01A0 20 49 2F 4F 20 65 72 72 6F 72 FF 0D 0A 52 65 70 I/O error...Rep 01B0 6C 61 63 65 20 74 68 65 20 64 69 73 6B 2C 20 61 lace the disk, a 01C0 6E 64 20 74 68 65 6E 20 70 72 65 73 73 20 61 6E nd then press an 01D0 79 20 6B 65 79 0D 0A 00 49 4F 20 20 20 20 20 20 y key...IO 01E0 53 59 53 4D 53 44 4F 53 20 20 20 53 59 53 80 01 SYSMSDOS SYS.. 01F0 00 57 49 4E 42 4F 4F 54 20 53 59 53 00 00 55 AA .WINBOOT SYS..U. 0000: 0003: 000b: 000d: 000e: 0010: 0011: 0013: 0015: 0016: 0018: 001a: 001c: 0020: 0024: 0028: 002a: 002c: 0030: 0032: 0034: 0040: 0041: 0042: 0043: 0047: 0052: 005a: 01fe: 0200: 0204: 03e4: 03e8: 03ec: 03f0: 03fe: jump : system id : sector size : sects per clust: reserved1 : nfats : dir entries : nsectors : media : sects per fat : sects per track: heads : hidden sects : total sects : fat32_length : flags : version : root_cluster : info_sector : backup_boot : reserved2 : drive id : reserved3 : ext_boot sign : volume serial : volume label : fs_id : bootcode : br signature : signature1 : reserved1 : signature2 : free_clusters : next_cluster : reserved2 : br signature : <3 bytes> MSWIN4.1 512 1 62 2 0xf8 63 255 63 20482812 2501 0x0000 0x0000 2 1 6 <12 bytes> 0x80 0x00 0x29 0x94b522f4 NO NAME FAT32 <420 bytes> 0xaa55 RRaA <480 bytes> rrAa 0x0004bd24 0x00000001 <14 bytes> 0xaa55 (Jump to bootstrap code) (Name) (bytes per sector (def: 512)) (sectors per cluster) (reserved sectors) (number of FATs (def: 2)) (root directory entries (unused for FAT32)) (number of sectors (unused for FAT32)) (media type) (sectors per FAT (unused for FAT32)) (sectors per track) (heads) (hidden sectors) (number of sectors (if sectors == 0)) (sectors per FAT) (bit 7: fat mirroring – bits 3-0: n. of active fats) (filesystem version) (first cluster of root directory) (sector number of the filesystem info sector) (boot sector backup) (unused) (physical drive id (first hd: 0x80)) (reserved) (extended boot signature) (volume serial number) (volume label (a string)) (filesystem id (FAT32 )) (bootstrap code) (bootrecord signature (0xAA55)) (2nd sectore signature1 "RRaA") (reserved) (2nd sectore signature2 "rrAa") (free_clusters) (next available cluster) (reserved) (bootrecord signature (0xAA55))

FAT32 Boot record

0200 52 52 61 41 00 00 00 00 00 00 00 00 00 00 00 00 RRaA............ 0210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0260 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0270 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0290 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 02A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 02B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 02C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 02D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 02E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 02F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0330 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0370 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0380 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0390 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 03A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 03B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 03C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 03D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 03E0 00 00 00 00 72 72 41 61 24 BD 04 00 01 00 00 00 ....rrAa$....... 03F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ..............U. 0000: 0003: 000b: 000d: 000e: 0010: 0011: 0013: 0015: 0016: 0018: 001a: 001c: 0020: 0024: 0028: 002a: 002c: 0030: 0032: 0034: 0040: 0041: 0042: 0043: 0047: 0052: 005a: 01fe: 0200: 0204: 03e4: 03e8: 03ec: 03f0: 03fe: jump : system id : sector size : sects per clust: reserved1 : nfats : dir entries : nsectors : media : sects per fat : sects per track: heads : hidden sects : total sects : fat32_length : flags : version : root_cluster : info_sector : backup_boot : reserved2 : drive id : reserved3 : ext_boot sign : volume serial : volume label : fs_id : bootcode : br signature : signature1 : reserved1 : signature2 : free_clusters : next_cluster : reserved2 : br signature : <3 bytes> MSWIN4.1 512 1 62 2 0xf8 63 255 63 20482812 2501 0x0000 0x0000 2 1 6 <12 bytes> 0x80 0x00 0x29 0x94b522f4 NO NAME FAT32 <420 bytes> 0xaa55 RRaA <480 bytes> rrAa 0x0004bd24 0x00000001 <14 bytes> 0xaa55 (Jump to bootstrap code) (Name) (bytes per sector (def: 512)) (sectors per cluster) (reserved sectors) (number of FATs (def: 2)) (root directory entries (unused for FAT32)) (number of sectors (unused for FAT32)) (media type) (sectors per FAT (unused for FAT32)) (sectors per track) (heads) (hidden sectors) (number of sectors (if sectors == 0)) (sectors per FAT) (bit 7: fat mirroring – bits 3-0: n. of active fats) (filesystem version) (first cluster of root directory) (sector number of the filesystem info sector) (boot sector backup) (unused) (physical drive id (first hd: 0x80)) (reserved) (extended boot signature) (volume serial number) (volume label (a string)) (filesystem id (FAT32 )) (bootstrap code) (bootrecord signature (0xAA55)) (2nd sectore signature1 "RRaA") (reserved) (2nd sectore signature2 "rrAa") (free_clusters) (next available cluster) (reserved) (bootrecord signature (0xAA55))

slide-9
SLIDE 9

FAT32 directory

0000 41 66 00 69 00 6C 00 65 00 31 00 0F 00 DB 2E 00 Af.i.l.e.1...... 0010 62 00 69 00 6E 00 00 00 FF FF 00 00 FF FF FF FF b.i.n........... 0020 46 49 4C 45 31 20 20 20 42 49 4E 20 18 00 E7 7A FILE1 BIN ...z 0030 E1 3E E1 3E 00 00 E7 7A E1 3E 03 00 DF 00 00 00 .>.>...z.>...... 0040 41 66 00 69 00 6C 00 65 00 32 00 0F 00 DF 2E 00 Af.i.l.e.2...... 0050 62 00 69 00 6E 00 00 00 FF FF 00 00 FF FF FF FF b.i.n........... 0060 46 49 4C 45 32 20 20 20 42 49 4E 20 18 00 E9 7A FILE2 BIN ...z 0070 E1 3E E1 3E 00 00 E9 7A E1 3E 04 00 0C 04 00 00 .>.>...z.>...... 0080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0000: 0020: 0020: 0028: 002b: 002c: 002d: 002e: 0030: 0032: 0034: 0036: 0038: 003a: 003c: 0040: 0060: 0060: 0068: 006b: 006c: 006d: 006e: 0070: 0072: 0074: 0076: 0078: 007a: 007c: longname[1] <LAST>: file1.bin entry02: FILE .BIN A--- 01/07/2011 15:23:14 name : ext : attribute : case : ctime_ms : ctime : cdate : adate : startHi : time : date : start : size : longname[1] <LAST>: file2.bin entry04: FILE .BIN A--- 01/07/2011 15:23:18 name : ext : attribute : case : ctime_ms : ctime : cdate : adate : startHi : time : date : start : size : FILE1 BIN 0x20 0x18 0x7ae7 0x3ee1 0x3ee1 0x7ae7 0x3ee1 3 223 FILE2 BIN 0x20 0x18 0x7ae9 0x3ee1 0x3ee1 0x7ae9 0x3ee1 4 1036 (file name) (file extension) (file attribute) (case of short filename) (creation time, centiseconds [0-199]) (creation time) (creation date) (access date) (start cluster, Hi) (modification time) (modification date) (start cluster) (size)

15 8 4 5 day month year-1980 9 Date format:

Attribute flags:

0x01 read-only 0x02 hidden 0x04 system 0x08 volume-label 0x10 directory 0x20 archived

15 4 5 sec/2 11 10 minute hour Time format:

FAT32 File Allocation Table

0000 F8 FF FF 0F FF FF FF 0F F8 FF FF 0F FF FF FF 0F ................ 0010 05 00 00 00 06 00 00 00 FF FF FF 0F 00 00 00 00 ................ 0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0000: 0004: 0008: 000c: 0010: 0014: 0018: 001c: Cluster 0 : Cluster 1 : Cluster 2 : Cluster 3 : Cluster 4 : Cluster 5 : Cluster 6 : Cluster 7 : 0x0ffffff8 0x0fffffff 0x0ffffff8 0x0fffffff 0x5 0x6 0x0fffffff 0x0 (reserved) (reserved) (next cluster of file) (next cluster of file) (next cluster of file) (next cluster of file) (next cluster of file) (next cluster of file)

Special markers:

0x0 empty cluster 0x0fff fff7 bad cluster 0x0fff ffff end of file

Ext2/Ext3 filesystem structure

SB block bitmap inode bitmap inode table DATA BLOCKS (files and directories) Group Descriptor Table SB block bitmap inode bitmap inode table DATA BLOCKS (files and directories) Group Descriptor Table

Group 0 Group 1

backup copies

SB

1 bit for each block (1: block used - 0: block free) 1 bit for each inode (1: inode used - 0: inode free)

block 0 block 1 ... block 11 ind block double ind block triple ind block type (regular/directory/...) user group mode size ctime atime mtime ... Group Descriptor Table

boot area Reserved inodes: 1: bad blocks 2: root directory 5: boot loader 6: undelete directory 7: reserved group descriptors 8: journal

Group Descriptor Table: 1 entry for each group

  • start of block bitmap
  • start of inode bitmap
  • start of inode table
  • free blocks in group
  • free inodes in group
  • num. of dirs in group

Ext2 superblock

0000 60 8D 06 00 75 15 0D 00 79 A7 00 00 67 B7 0B 00 `...u...y...g... 0010 D0 57 06 00 00 00 00 00 02 00 00 00 02 00 00 00 .W.............. 0020 00 80 00 00 00 80 00 00 20 3E 00 00 64 18 14 4A ........ >..d..J 0030 9C 19 14 4A 02 00 16 00 53 EF 01 00 01 00 00 00 ...J....S....... 0040 75 2D D6 49 00 4E ED 00 00 00 00 00 01 00 00 00 u-.I.N.......... 0050 00 00 00 00 0B 00 00 00 80 00 00 00 34 00 00 00 ............4... 0060 02 00 00 00 03 00 00 00 BD 6F F7 CC B5 57 4B AE .........o...WK. 0070 BE 8E 4E 82 26 58 22 36 00 00 00 00 00 00 00 00 ..N.&X"6........ 0080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D1 00 ................ 00D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00E0 08 00 00 00 00 00 00 00 00 00 00 00 1C 3B F2 EB .............;.. 00F0 2A 0E 4D DA 9C 73 BB CE 12 92 0C BC 02 01 00 00 *.M..s.......... 0100 00 00 00 00 00 00 00 00 75 2D D6 49 CC 02 00 00 ........u-.I.... 0110 CD 02 00 00 CE 02 00 00 CF 02 00 00 D0 02 00 00 ................ 0120 D1 02 00 00 D2 02 00 00 D3 02 00 00 D4 02 00 00 ................ 0130 D5 02 00 00 D6 02 00 00 D7 02 00 00 D8 02 00 00 ................ 0140 D9 06 00 00 00 00 00 00 00 00 00 00 00 00 00 04 ................ 0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0160 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0000: 0004: 0008: 000c: 0010: 0014: 0018: 001c: 0020: 0024: 0028: 002c: 0030: 0034: 0036: 0038: 003e: 0040: 0044: 0048: 004c: 0050: 0052: 0054: 0058: 005a: 005c: 0060: 0064: 0068: 0078: 0088: 00c8: 00cc: 00cd: 00ce: 00d0: 00e0: 00e4: 00e8: 00ec: 00fc: 00fd: 00fe: 429408 857461 42873 767847 415696 12 12 32768 32768 15904 20/05/2009 16:49:08 20/05/2009 16:54:20 2 22 0xEF53 03/04/2009 17:38:29 15552000 (6 months) Linux 1 (dynamic) 0 (user root) 0 (group root) 11 128 0x00000034 0x00000002 0x00000003 bd6ff7cc-b557-... <none> <not available> 209 00000000-0000-... 8 1c3bf2eb-2a0e-... 2 (tea) inodes_count : blocks_count : r_blocks_count : free_blocks_count : free_inodes_count : first_data_block : log_block_size : log_frag_size : blocks_per_group : frags_per_group : inodes_per_group : mtime : wtime : mnt_count : max_mnt_count : magic : minor_rev_level : lastcheck : checkinterval : creator_os : rev_level : def_resuid : def_resgid : first_ino : inode_size : block_group_nr : feature_compat : feature_incompat : feature_ro_compat : uuid : volume_name : last_mounted : algo_usage_bitmap : prealloc_blocks : preall_dir_blocks : reserv_gdt_blocks : journal_uuid : journal_inum : journal_dev : last_orphan : hash_seed : def_hash_version : reserved_char_pad : reserved_word_pad : (inodes count) (blocks count) (reserved blocks count) (free blocks count) (free inodes count) (first data block) (block size) (fragment size) (# blocks per group) (# fragments per group) (# inodes per group) (mount time) (write time) (mount count) (maximal mount count) (magic signature) (minor revision level) (time of last check) (max. time between checks) (os) (revision level) (default uid for reserved blocks) (default gid for reserved blocks) (first non-reserved inode) (size of inode structure) (block group # of this superblock) (compatible feature set) (incompatible feature set) (readonly-compatible feature set) (128-bit uuid for volume) (volume name) (directory where last mounted) (for compression) (nr of blocks to try to preallocate) (nr to preallocate for dirs) (GDT blocks) (uuid of journal superblock) (inode number of journal file) (device number of journal file) (start of list of inodes to delete) (htree hash seed) (default hash version to use)

slide-10
SLIDE 10

Ext2 superblock

0000 60 8D 06 00 75 15 0D 00 79 A7 00 00 67 B7 0B 00 `...u...y...g... 0010 D0 57 06 00 00 00 00 00 02 00 00 00 02 00 00 00 .W.............. 0020 00 80 00 00 00 80 00 00 20 3E 00 00 64 18 14 4A ........ >..d..J 0030 9C 19 14 4A 02 00 16 00 53 EF 01 00 01 00 00 00 ...J....S....... 0040 75 2D D6 49 00 4E ED 00 00 00 00 00 01 00 00 00 u-.I.N.......... 0050 00 00 00 00 0B 00 00 00 80 00 00 00 34 00 00 00 ............4... 0060 02 00 00 00 03 00 00 00 BD 6F F7 CC B5 57 4B AE .........o...WK. 0070 BE 8E 4E 82 26 58 22 36 00 00 00 00 00 00 00 00 ..N.&X"6........ 0080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D1 00 ................ 00D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00E0 08 00 00 00 00 00 00 00 00 00 00 00 1C 3B F2 EB .............;.. 00F0 2A 0E 4D DA 9C 73 BB CE 12 92 0C BC 02 01 00 00 *.M..s.......... 0100 00 00 00 00 00 00 00 00 75 2D D6 49 CC 02 00 00 ........u-.I.... 0110 CD 02 00 00 CE 02 00 00 CF 02 00 00 D0 02 00 00 ................ 0120 D1 02 00 00 D2 02 00 00 D3 02 00 00 D4 02 00 00 ................ 0130 D5 02 00 00 D6 02 00 00 D7 02 00 00 D8 02 00 00 ................ 0140 D9 06 00 00 00 00 00 00 00 00 00 00 00 00 00 04 ................ 0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0160 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0100: 0104: 0108: 010c: 0150: 0154: 0158: 015c: 015e: 0160: 0164: 0166: 0168: 0170: 0174: 0175: 0176: 0178: 0x00000000 03/04/2009 17:38:29 <68 bytes> 0x1 <648 bytes> default_mount_opts: first_meta_bg : mkfs_time : jnl_blocks : blocks_count_hi : r_blocks_count_hi : free_blks_count_hi: min_extra_isize : want_extra_isize; : flags : raid_stride : mmp_interval : mmp_block : raid_stripe_width : log_grps_per_flex : reserved_char_pad2: reserved_pad : reserved[162] : (first metablock block group) (when the filesystem was created) (backup of the journal inode) (blocks count) (reserved blocks count) (free blocks count) (all inodes have at least # bytes) (new inodes should reserve # bytes) (miscellaneous flags) (raid stride) (# seconds to wait in mmp checking) (block for multi-mount protection) (blocks on all data disks: n*stride) (flex_bg group size) (padding to the end of the block)

Ext2 directory

0000 81 F8 00 00 0C 00 01 02 2E 00 00 00 02 00 00 00 ................ 0010 0C 00 02 02 2E 2E 00 00 82 F8 00 00 0C 00 03 01 ................ 0020 63 61 74 00 83 F8 00 00 10 00 06 01 7A 65 67 72 cat.........zegr 0030 65 70 00 00 84 F8 00 00 10 00 05 01 63 68 67 72 ep..........chgr 0040 70 00 00 00 85 F8 00 00 10 00 05 01 7A 64 69 66 p...........zdif 0050 66 00 00 00 86 F8 00 00 10 00 05 01 65 67 72 65 f...........egre 0060 70 00 00 00 87 F8 00 00 10 00 05 01 67 7A 65 78 p...........gzex 0070 65 00 00 00 88 F8 00 00 0C 00 04 01 73 74 74 79 e...........stty 0080 89 F8 00 00 14 00 09 01 72 75 6E 2D 70 61 72 74 ........run-part 0090 73 00 00 00 8A F8 00 00 10 00 07 01 62 75 73 79 s...........busy 00A0 62 6F 78 00 8B F8 00 00 10 00 05 01 72 6D 64 69 box.........rmdi 00B0 72 00 00 00 8C F8 00 00 0C 00 03 01 64 69 72 00 r...........dir. 00C0 8D F8 00 00 0C 00 04 01 6B 69 6C 6C 8E F8 00 00 ........kill.... 00D0 10 00 06 01 62 7A 6D 6F 72 65 00 00 8F F8 00 00 ....bzmore...... 00E0 0C 00 02 01 64 66 00 00 90 F8 00 00 10 00 05 01 ....df.......... 00F0 6C 6F 67 69 6E 00 00 00 91 F8 00 00 10 00 05 07 login........... 0100 72 6E 61 6E 6F 00 00 00 92 F8 00 00 0C 00 02 01 rnano........... 0110 73 75 00 00 93 F8 00 00 10 00 08 01 74 65 6D 70 su..........temp 0120 66 69 6C 65 94 F8 00 00 0C 00 04 01 65 63 68 6F file........echo 0130 95 F8 00 00 0C 00 04 01 6E 61 6E 6F 96 F8 00 00 ........nano.... 0140 10 00 06 01 75 6D 6F 75 6E 74 00 00 97 F8 00 00 ....umount...... 0150 10 00 06 01 6D 74 2D 67 6E 75 00 00 98 F8 00 00 ....mt-gnu...... 0160 10 00 05 01 63 68 6D 6F 64 00 00 00 99 F8 00 00 ....chmod....... 0170 10 00 07 01 62 7A 66 67 72 65 70 00 9A F8 00 00 ....bzfgrep..... 0180 0C 00 02 01 6C 73 00 00 9B F8 00 00 0C 00 02 01 ....ls.......... 0190 6D 76 00 00 9C F8 00 00 0C 00 02 07 6D 74 00 00 mv..........mt.. 01A0 9D F8 00 00 10 00 05 01 62 7A 63 6D 70 00 00 00 ........bzcmp... 01B0 9E F8 00 00 0C 00 03 01 73 65 64 00 9F F8 00 00 ........sed..... 01C0 10 00 05 01 62 7A 69 70 32 00 00 00 A0 F8 00 00 ....bzip2....... 01D0 0C 00 04 01 63 70 69 6F 85 F8 00 00 0C 00 04 01 ....cpio........ 01E0 7A 63 6D 70 A1 F8 00 00 0C 00 03 01 70 77 64 00 zcmp........pwd. 01F0 A2 F8 00 00 10 00 05 01 6D 6B 64 69 72 00 00 00 ........mkdir... x: x+4: x+6: x+7: x+8: 63637 12 4 regular nano inode : entry_len : name_len : file_type : name : (inode number) (directory entry length) (name length) (unkn/reg/dir/chrdev/blkdev/fifo/sock/symlink) (file name)

Ext2 inode

0A00 ED 81 00 00 04 18 02 00 9D 2D D6 49 9D 2D D6 49 .........-.I.-.I 0A10 F8 0C 56 46 00 00 00 00 00 00 01 00 18 01 00 00 ..VF............ 0A20 00 00 00 00 00 00 00 00 D7 58 02 00 D8 58 02 00 .........X...X.. 0A30 D9 58 02 00 DA 58 02 00 DB 58 02 00 DC 58 02 00 .X...X...X...X.. 0A40 DD 58 02 00 DE 58 02 00 DF 58 02 00 E0 58 02 00 .X...X...X...X.. 0A50 E1 58 02 00 E2 58 02 00 E3 58 02 00 00 00 00 00 .X...X...X...... 0A60 00 00 00 00 8E C2 F0 62 00 00 00 00 00 00 00 00 .......b........ 0A70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0A80 ED 89 00 00 50 D1 00 00 9D 2D D6 49 9D 2D D6 49 ....P....-.I.-.I 0A90 85 AD 7B 47 00 00 00 00 00 00 01 00 78 00 00 00 ..{G........x... 0AA0 00 00 00 00 00 00 00 00 FA 58 02 00 FB 58 02 00 .........X...X.. 0AB0 FC 58 02 00 FD 58 02 00 FE 58 02 00 FF 58 02 00 .X...X...X...X.. 0AC0 00 59 02 00 01 59 02 00 02 59 02 00 03 59 02 00 .Y...Y...Y...Y.. 0AD0 04 59 02 00 05 59 02 00 06 59 02 00 00 00 00 00 .Y...Y...Y...... 0AE0 00 00 00 00 8F C2 F0 62 00 00 00 00 00 00 00 00 .......b........ 0AF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0B00 ED 81 00 00 60 7C 00 00 9D 2D D6 49 9D 2D D6 49 ....`|...-.I.-.I 0B10 BC 31 1A 48 00 00 00 00 00 00 01 00 40 00 00 00 .1.H........@... 0B20 00 00 00 00 00 00 00 00 09 59 02 00 0A 59 02 00 .........Y...Y.. 0B30 0B 59 02 00 0C 59 02 00 0D 59 02 00 0E 59 02 00 .Y...Y...Y...Y.. 0B40 0F 59 02 00 10 59 02 00 00 00 00 00 00 00 00 00 .Y...Y.......... 0B50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0B60 00 00 00 00 90 C2 F0 62 00 00 00 00 00 00 00 00 .......b........ 0B60 00 00 00 00 90 C2 F0 62 00 00 00 00 00 00 00 00 .......b........ 0B70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0B80 ED 81 00 00 38 79 00 00 9D 2D D6 49 9D 2D D6 49 ....8y...-.I.-.I 0B90 72 D8 BF 45 00 00 00 00 00 00 01 00 40 00 00 00 r..E........@... 0BA0 00 00 00 00 00 00 00 00 11 59 02 00 12 59 02 00 .........Y...Y.. 0BB0 13 59 02 00 14 59 02 00 15 59 02 00 16 59 02 00 .Y...Y...Y...Y.. 0BC0 17 59 02 00 18 59 02 00 00 00 00 00 00 00 00 00 .Y...Y.......... 0BD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0BE0 00 00 00 00 91 C2 F0 62 00 00 00 00 00 00 00 00 .......b........ 0BF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ x+00: x+02: x+04: x+08: x+0c: x+10: x+14: x+18: x+1a: x+1c: x+20: x+24: x+28: x+64: x+68: x+6c: x+70: x+74: x+75: x+76: x+78: x+7a: x+7c: regular rwxr-xr-x 137220 03/04/2009 17:39:09 03/04/2009 17:39:09 25/05/2007 00:08:56 1 280 0x0 0x0 <60 bytes> 1659945614 mode : uid : size : atime : ctime : mtime : dtime : gid : links_count : nblocks : flags : reserved1 : blocks[] : generation : file_acl : dir_acl : faddr : frag : fsize : pad1 : uid_high : gid_high : reserved2 : (file mode) (low 16 bits of Owner Uid) (size in bytes) (access time) (creation time) (modification time) (deletion Time) (low 16 bits of Group Id) (links count) (blocks count) (file flags) (reserved) (pointers to blocks) (file version [for NFS]) (file ACL) (directory ACL) (fragment address) (fragment number) (fragment size) (reserved)