MBR (MASTER BOOT RECORD)



Похожие документы
Gli Extended file system di Linux (Ext2/Ext3/Ext4)

Struttura del Micro Filesystem (µfs)

Il Software. Il software del PC. Il BIOS

FoLUG Forlì Linux User Group. Partizionamento

Sistemi Operativi Il Sistema Operativo Windows (parte 3)

Capitolo Silberschatz

Sistemi Operativi. Interfaccia del File System FILE SYSTEM : INTERFACCIA. Concetto di File. Metodi di Accesso. Struttura delle Directory

Sistemi Operativi IMPLEMENTAZIONE DEL FILE SYSTEM. D. Talia - UNICAL. Sistemi Operativi 9.1

File system II. Sistemi Operativi Lez. 20

IL MULTIBOOT. Un sistema multiboot consiste nella possibilità di caricare più sistemi operativi sullo stesso computer.

Sistemi Operativi IMPLEMENTAZIONE DEL FILE SYSTEM. Implementazione del File System. Struttura del File System. Implementazione

Il Sistema Operativo: il File System

Il sistema operativo LINUX Il file system. Indice. Blocchi logici. Indice. Super block. G. Di Natale, S. Di Carlo

Modulo 4: Gestore del File System (Memoria secondaria) Componenti

Il file system. meccanismi di accesso e memorizzazione delle informazioni (programmi e dati) allocate. in memoria di massa

Il sistema operativo: interazione con l utente

Assembler di Spim. Assembler di SPIM. Struttura di un programma assembler. Direttive

Il File System. Il file system

Installazione LINUX 10.0

NT OS Loader + Linux mini-howto

Sistemi Operativi. 12 LEZIONE REALIZZAZIONE DEL FILE SYSTEM CORSO DI LAUREA TRIENNALE IN INFORMATICA. Sistemi Operativi 2007/08

L installer di Torinux

12. Implementazione di un File System Struttura a livelli Allocazione contigua

Il web server Apache Lezione n. 3. Introduzione

Mac Application Manager 1.3 (SOLO PER TIGER)

Samsung Auto Backup FAQ

Sequenza di avvio di Linux:

L hard disk. L amministrazione dei dischi puo essere riassunta nelle seguenti operazioni di base: La formattazione. Il partizionamento

Concetti fondamentali

Organizzazione di Sistemi Operativi e Reti

Sistemi Operativi GESTIONE DELLA MEMORIA SECONDARIA. D. Talia - UNICAL. Sistemi Operativi 11.1

Sistemi Operativi. Memoria Secondaria GESTIONE DELLA MEMORIA SECONDARIA. Struttura del disco. Scheduling del disco. Gestione del disco

Il SOFTWARE DI BASE (o SOFTWARE DI SISTEMA)

Se mi lasci ti cancello: Cancellazione sicura asincrona su ext3

Terza lezione: Directory e File system di Linux

Corso di Informatica

Lezione 1: L architettura LC-3 Laboratorio di Elementi di Architettura e Sistemi Operativi 10 Marzo 2014

TECNICHE AVANZATE DI I/O. Al loro livello più basso, tutti i file scritti sull hard disk. Training per esperti SU FILE

Introduzione alla programmazione in C

SharePoints è attualmente disponibile in Inglese, Italiano e Francese.

Uso del Computer e Gestione dei File. Uso del Computer e Gestione dei File. Federica Ricca

Guida all uso di Java Diagrammi ER

Come installare Ubuntu Linux

Risolvere i problemi di avvio di Windows XP

LaCie Ethernet Disk mini Domande frequenti (FAQ)

Il formato BITMAP. Introduzione. Il formato BITMAP

A G DL P. I permessi NTFS e di condivisione. Il File System NTFS. Il File System NTFS. La strategia A G DL P. Il File System NTFS. Il File System NTFS

D R O P B O X COS È DROPBOX:

INDICE Introduzione: tipologie di backup 1.Accesso al software 2.Selezione files e cartelle 3.Specificare unità di memoria 4.

Sistemi Operativi. Organizzazione logica ed implementazione di un File System

Web Storage, Sharing e Backup. Progetto di Sistemi Web-Based Prof. Luigi Laura, Univ. Tor Vergata, a.a. 2010/2011

Il Sistema Operativo (1)

Esercitazione su Windows. Introduzione al calcolatore Introduzione a Windows

I file di dati. Unità didattica D1 1

IL SISTEMA OPERATIVO IL SISTEMA OPERATIVO INTERFACCE TESTUALI INTERFACCE TESTUALI FUNZIONI DEL SISTEMA OPERATIVO INTERFACCE GRAFICHE

Appunti di Sistemi Operativi. Enzo Mumolo address web address :

costruttori e distruttori

Sistema Operativo di un Router (IOS Software)

ATOLLO BACKUP GUIDA INSTALLAZIONE E CONFIGURAZIONE

Organizzazione della memoria

Paragon HFS+ per Windows

Il microprocessore 8086

ACRONIS TRUE IMAGE. Guida del programma:

Controllo di processi

Schema Tipologia a Stella

5-1 FILE: CREAZIONE NUOVO DOCUMENTO

GUIDA ALLE SOLUZIONI

Excel. A cura di Luigi Labonia. luigi.lab@libero.it

Istruzioni per l installazione del software per gli esami ICoNExam (Aggiornate al 15/01/2014)

Modulo 3: Gestione delle Periferiche (Dispositivi di input/output)

B+Trees. Introduzione

Fate doppio click sul file con nome postgresql-8.0.msi e impostate le varie voci come riportato nelle immagini seguenti:

Organizzazione degli archivi

Groups vs Organizational Units. A cura di Roberto Morleo

Identificare le diverse parti di una finestra: barra del titolo, barra dei menu, barra degli strumenti, barra di stato, barra di scorrimento.

CONTENT MANAGEMENT SY STEM

Il software impiegato su un computer si distingue in: Sistema Operativo Compilatori per produrre programmi

Manuale per riparare e recuperare dati sul hard disk

Sistemi Operativi (modulo di Informatica II)

Consiglio regionale della Toscana. Regole per il corretto funzionamento della posta elettronica

FTP NAV - Guida tecnica FTP NAV - Technical Guide

HBase Data Model. in più : le colonne sono raccolte in gruppi di colonne detti Column Family; Cosa cambia dunque?

APRIRE UN PROGRAMMA DI FOGLIO ELETTRONICO

Guida all installazione degli Hard Disk SATA ed alla configurazione del RAID

Automatizzare i compiti ripetitivi. I file batch. File batch (1) File batch (2) Visualizzazione (2) Visualizzazione

Installare Ubuntu su macchina virtuale

Cominciamo dalla barra multifunzione, ossia la struttura a schede che ha sostituito la barra dei menu e la barra delle icone (Figura 1).

Portale Materiali Grafiche Tamburini. Grafiche Tamburini Materials Portal

Транскрипт:

Guida al Filesystem Questo tutorial è nato per il fatto che,navigando in Internet, non ho trovato nessuna guida più o meno completa sull'argomento; la maggior parte delle informazioni sono state prese da articoli italiani o stranieri ma, poichè ho copiato il loro contenuto in un file di testo, non sono in grado di esporre i nomi degli autori o dei siti su cui sono stati pubblicati. Tutto il contenuto di questo file è protetto da copyleft, cioè siete liberi di copiarlo, modificarlo e divulgarlo a vostro piacere. La maggior parte (praticamente tutti) i comandi per gestire i filesystem sono comandi Linux, visto che non ho trovato un gran numero di informazioni su guide per windows/dos. Per capire bene il funzionamento dei fs è necessario conoscere anche la struttura dell' hard disk in generale. HARD DISK Ora analizzeremo l' hard disk al livello più basso possibile, escludendo, quindi, quando è possibile, le differenze che riguardano sistemi operativi diversi. L' hd (Hard Disk) è diviso in tre parti principali: - MBR; - BOOT SECTOR; - FILESYSTEM. MBR (MASTER BOOT RECORD) Il MBR è il primo settore dell' hd, ovvero il settore 1 sotto la testina 0, e contiene il codice con le prime operazioni di boot (dal byte 0 al 1DD cerca la partizione da avviare e lancia la partizione) e la tabella delle partizioni (al massimo 4 primarie). Esso è così strutturato: - [da 0 a 1BD] = routine d'avvio; - [da 1BE a 1CD] = partizione 1; - [da 1CE a 1CD] = partizione 2; - [da 1DE a 1ED] = partizione 3; - [da 1EE a 1FD] = partizione 4; - [55 AA] = codice finale dell'mbr. VEDI APPENDICE. BOOT SECTOR Ogni partizione inizia con un settore che contiene le informazioni sull'unità, sul fs, ed avvia il sistema operativo, se la partizione è avviabile. Il Boot Sector modificato a seconda del fs in uso, quindi non tutti sono uguali. VEDI APPENDICE.

FILESYSTEM Un filesystem (che chiameremo,per comodità, fs) contiene i metodi e le strutture che un sistema operativo utilizza per gestire i files e le directory sul disco fisso. I programmi che possono gestire i fs sono i bootmanager, che, per lo più, servono per gestire i conflitti tra diversi sistemi operativi; state attenti quando usate questi programmi:per modificare un fs va cancellato quello precedente e sovrascritto con uno nuovo, quindi i bootmanager vi elimineranno il fs vecchio per sostituirlo con uno nuovo creato da loro. Esistono fs di diverso tipo, per sistemi operativi diversi o per dischi diversi, come i CD-ROM, ed ognuno deve avere, in alcuni casi, una partizione propria. Qui sotto ho inserito un elenco con i principali fs: FAT,FAT16,FAT32 : fs dei sistemi DOS/Windows; EXT,EXT2 : il più completo ed il più usato dei fs in Linux; NTFS : fs di Windows NT; MINIX : il fs per Unix più vecchio; XIA : versione modificata e non molto conosciuta del precedente; UMSDOS : estende il driver msdos sotto Linux; NFS : fs di rete che permette la condivisione dei files; HFS : è il filesystem per Macintosh; ISO9660 : fs standard per i CD-ROM. FAT,FAT16,FAT32 Il fs FAT, che prende il nome dalla sua componente principale, è quello usato,normalmente, per windows 95/98/ME/XP. Solitamente di sente parlare di FAT32, che è una modifica del fs precedente rilasciato con la release 2 di windows Boot95, esso permette di gestire partizioni superiori ai 2 Gb. Il fs FAT è costituita da 4 parti: - FAT : File Allocation Table, ovvero la tabella di allocazione dei blocchi. - ROOT DIRECTORY : La directory di livello gerarchico più elevato. - CLUSTERS : Sono i blocchi che contengono i dati dei files. - FILES E DIRECTORY : le directory di livello inferiore. FAT La FAT è la struttura principale che permette l'accesso ai files. E' costituita da una tabella i cui elementi identificano i cluster di dati corrispondenti. Se ad esempio il file X ha come elementi 3,7,5 ciò significa che è formato dai cluster 3,7,5 (i primi due cluster, 0 e 1, sono riservati, pertanto si comincia dal numero 2). DIRECTORY Le directory sono anch'esse memorizzate in files e sono così strutturate: - [00] nome del file (8 bit per il nome + 3 bit per l'estensione = 11 bit totali); - [0B] attributi (1 bit); - bit 0 = sola lettura; - bit 1 = file nascosto; - bit 2 = file di sistema; - bit 3 = label di volume; - bit 4 = directory; - bit 5 = file archivio. - [0C] 8 bit riservati per FAT32; - [14] 2 bit per la parte alta del primo cluster del file; - [16] data di creazione ed aggiornamento del file; - bit 0/4 = secondi; - bit 5/10 = minuti; - bit 11/16 = ore. - [18] data di creazione ed aggiornamento del file; - bit 0/4 = giorni; - bit 5/8 = mesi; - bit 9/16 = anni. - [1A] parte bassa del primo cluster del file; - [1C] dimensioni del file in byte;

CLUSTER Il cluster è l'unità logica in cui viene suddiviso un file registrato sull' hd. I cluster della FAT32 sono di 8 Kb. Il fs FAT assegna un codice ad ogni cluster per definirne le proprietà: CODICE PROPRIETA' ------------ ------------- 00000000 libero 0FFFFFF0/6 riservato 0FFFFFF7 danneggiato 0FFFFFF8 fine del file --------------------------- FILES E DIRECTORY L'area vera e propria dei dati,ovvero dove sono memorizzati i cluster, inizia per la FAT 16 ad inizio della root, mentre per la FAT32 alla fine; il primo cluster della FAT32 si trova nella posizione 14H:1AH. Importante:quando i files vengono "cancellati", in realtà, viene inserito il codice 0E5H all'inizio del file, che rimarrà presente sull' hard disk finchè, per recuperare spazio, il sistema non deciderà di cancellarlo; ci sono,però, programmi che risolvono questo problema sovrascrivendo sul file una sequenza casuale di bit (ad esempio il PGP). EXT, EXT2 Il fs extended 2 (ext2) è il più usato attualmente sui sistemi Linux; esso è, in pratica, la modifica dei fs per Unix, quindi mantiene la struttura classica: - SUPER BLOCK; - INODES; - DIRECTORY; - FILES. SUPER BLOCK Il super block, organizzato come un array di blocchi logici della dimensione, per lo più, di 1024 bytes, contiene tre tipi principali di informazioni: - CARATTERISTICHE DEL FS (struttura, dimensione, etc.); - PARAMETRI MODIFICABILI (maximal mount count, error behaviour, etc.); - VARIABILI DI STATO (mount count, free blocks, etc.). VEDI APPENDICE. Nel super block dell'ext2 manca totalmente ogni informazione sulla struttura fisica e sul tipo di partizione in cui è ospitato. CYLINDER GROUPS Il fs è suddiviso logicamente in più parti che vengono gestite separatamente, pur facendo parte dello stesso fs, queste sono dette cylinder groups. Lo scopo di ciò è, in un primo luogo, che se un cylinder group viene danneggiato, l'errore non colpisce il fs intero; mentre il secondo motivo è che, allocando inodes e blocchi nello stesso cylinder group, si riduce il tempo di accesso ai files. Ogni cylinder group è descritto dal blocco group descriptor che è così strutturato : struct ext2_group_desc { u32 bg_block_bitmap; /* Blocks bitmap block */ u32 bg_inode_bitmap; /* Inodes bitmap block */ u32 bg_inode_table; /* Inodes table block */ u16 bg_free_blocks_count; /* Free blocks count */ u16 bg_free_inodes_count; /* Free inodes count */ u16 bg_used_dirs_count; /* Directories count */ u16 bg_pad; u32 bg_reserved[3]; }; Le block bitmap sono una parte del cylinder group che indica quali blocchi di esso sono stati allocati a files o a directory. Le inode maps, invece, indicano quali inode risultano allocati; la inode table, infine, contiene gli inode appartenenti al cylinder group.

INODE Gli inode (index node) sono la risorsa principale dell'ext2, in quanto ad ogni file o directory è associato un inode che ne riassume le caratteristiche e indica sono allocati fisicamente. Gli inode sono numerati a partire dal numero 1; il kernel utilizza questi numeri per accedere a loro. VEDI APPENDICE. I moduli della struttura dell'inode sono: - I_MODE contiene i permessi; - I_UID e I_GIG contengono l'userid ed il groupid; - I_SIZE contiene le dimensioni del file; - I_ATIME, I_CTIME, I_MTIME e I_DTIME contengono rispettivamente le date di accesso, creazione, modifica e cancellazione del file espressi nello standard Linux; - I_LINKS_COUNT ha il numero di hard link puntati all'inode; - I_BLOCKS indica il numero di blocchi occupati dai files; - I_FLAGS contiene flags aggiuntivi che indicano particolari caratteristiche del file; - I_FILE_ACL,I_DIR_ACL,I_FADDR,I_I_FRAG e I_I_FSIZE non sono attualmente usati; Alcuni fra gli inodes sono riservati, essi sono: - BAD BLOCKS INODE = contiene la lista dei settori difettosi; - ROOT INODE = è l'inode della directory root; - ACL INDEX INODE = attualmente non usato; - ACL DATA INODE = attualmente non usato; - BOOT LOADER INODE = può contenere un programma in codice macchina per caricare il sistema operativo; - UNDELETE DIRECTORY INODE = attualmente non usato; - Altri 4 inodes che attualmente non sono usati. DIRECOTRY Le directory non sono altro che comuni files, ma vengono gestite in modo particolare dal fs. Questa è la struttura di una directory entry : #define EXT2_NAME_LEN 255 struct ext2_dir_entry { u32 inode; /* Inode number */ u16 rec_len; /* Directory entry length */ u16 name_len; /* Name length */ char name[ext2_name_len]; /* File name */ }; NTFS Il fs NTFS è quello usato per WindowsNT/2000, fu progettato e realizzato da Gary Kumura e Tom Miller per l'uscita di Windows NT 3.1; può contenere, in teoria, fino a 16 exabytes, o 18,446,744,073,709,551,616 bytes. Esso è diviso in : - MFT(Master File Table); - MFT 2; - LOG FILE; - VOLUME; - ATTRIBUTE DEFINITION TABLE; - ROOT FILENAME INDEX; - CLUSTER BITMAP; - PARTITION BOOT SECTOR; - BAD CLUSTER FILE; - QUOTA TABLE; - UPCASE TABLE. MFT, MFT2, LOG FILE e VOLUME La Master File Table, che ha come nome $Mft, è una lista di tutti i contenuti del Volume. La MFT 2, $MtfMirr, è una copia della MFT e si trova nel mezzo dell'hard disk, fra lo spazio destinato ai files. Il LOG FILE, $LogFile, è la lista degli spostamenti dei files e serve per recuperare, in caso di danneggiamento, il NTFS. Il VOLUME, $Volume, contiene parecchie informazioni (versione del fs, etichetta del VOLUME, etc.). ATTRIBUTE DEFINITION TABLE, ROOT FILENAME INDEX, CLUSTER BITMAP L'Attribute Definition Table, $AttrDef, contiene gli elementi riguardanti i files come il nome, le informazioni di sicurezza, le date, e tutti gli

attributi. La directory di root, $., si chiama Root Filename Index. La Cluster Bitmap, $Bitmap, che è una rappresentazione del VOLUME, mostra i cluster in uso. PARTITION BOOT SECTOR, QUOTA TABLE e UPCASE TABLE La Partition Boot Sector, $Boot, ovvero la parte riguardante il boot, è suddivisa in questo modo : BYTE OFFSET (HEX) DIMENSIONE SIGNIFICATO ------------------- ----------- ----------------------------- 00 3 bytes istruzioni di partenza 03 8 bytes identificatore OEM 0B 25 bytes BIOS Parameter Block 24 38 bytes Extended BIOS Parameter Block 54 426 bytes codice del BootStrap 1FE WORD fine del settore -------------------------------------------------------------- La Quota Table, $Quota, momentaneamente non è usata. La Upcase Table, $Upcase, serve per convertire i caratteri minuscoli in maiuscoli (se ho capito bene). MINIX Il fs Minix è il più vecchio per Unix, e forse il più affidabile, ma ha alcune limitazioni che non ne consentono una larga diffusione (la partizione non può superare 1 Gb, i nomi dei files devono essere corti, etc.) La sua struttura è la solita di un fs per Unix : - BOOT BLOCK : istruzioni di boot; - SUPER BLOCK : caratteristiche del fs, parametri, etc.; - INODE BITMAP : la mappa degli inode; - ZONE BITMAP : (???); - INODES : dove ci sono gli inodes; - DATA BLOCKS : blocco dei dati. XIA Nonostante le molte ricerche tutto ciò che sono riuscito a capire è che questa è la versione modificata del minix e che, sebbene funzioni bene, non è entrata in uso per il fatto che l'ext2 si è confermato come fs leader per Linux. UMSDOS Il fs UMSDOS permette, rispettando la struttura di un fs DOS, di vedere tutti i files come se fossero stati creati da Linux, con nomi estesi, proprietari e diritti d'accesso. Con la distribuzione minilinux (sono 4 floppy da 1.44 Mb), la quale, però, non funziona sugli ultimi modelli di computer, viene installato Linux nella cartella C:\Linux come se fosse un normale programma; non c'è bisogno, perciò, di partizionare il disco, di far uso di bootmanager come LILO etc. Questa distribuzione è ideale per chiunque voglia provare linux senza dover sconvolgere l' hd. Vi sono però alcuni difetti:uno è che, se si modifica una cartella con il DOS, le variazioni non vengono visualizzate subito da Linux. L'altro difetto un po' fastidioso è che, in ogni directory, vi sarà un file chiamato --linux-.---, che è invisibile quando si usa Linux, ma visibile da DOS; se si elimina il file la directory non potrà più essere gestita da Linux. NFS Il fs NFS permette di condividere files sui sistemi Linux. Il settaggio del fs si differenzia per quanto riguarda il lato server ed il lato client e per poterlo usare occorre includere il supporto nel kernel 13.5.14. LATO SERVER Dal lato server devono essere messi in funzione, oltre al portmapper, anche i daemon mountd e nfsd ed il file /etc/exports deve essere stato settato correttamente.

LATO CLIENT Per il lato client basta che il kernel sia stato predisposto per questo e che esista il mount. HFS Il fs hfs (Hierarchical File System) è quello usato dai sistemi macintosh sia per gli hd sia per i CD-ROM. Questo formato è nato nel 1985 per sostituire il MFS (Macintosh Filing System), usato per accedere ai floppy da 400 Kb. Permette di gestire fino a 32767 files per ogni directory e due terabytes in totale. I cluster sono di dimensione variabile, stabilita durante la formattazione. I files dell hfs non hanno l estensione, ma vengono divisi in due parti, o forks: - DATA FORK : è equivalente ad un file classico; - RESOURCE FORK : questa parte contiene attributi, tipo, date, icona del file. Gli unici due inconvenienti del fs hfs sono che il numero di files massimo su una partizione è di 65536, e che al crescere delle dimensioni della partizione, cresce anche la partizione interna. ISO9660 Il fs ISO9660 (conosciuto anche come ECMA 119)è lo standard per i cd di dati, e viene letto normalmente da linux, macintosh e windows. I nomi dei files non possono superare i 32 caratteri, e non c è distinzione tra maiuscolo e minuscolo. La struttura delle directory dell ISO9660 è sostanzialmente come quella dei fs dos/windows. Il CD-ROM è diviso in settori, ognuno da 2048 bytes, ed i primi 16 sono vuoti, si pensa che vengano riservati al boot da CD. Dal settore n 16 cominciano ad esserci alcuni settori che contengono una serie di VOLUME DESCRIPTOR. Il più importante è, forse, il primo: length in bytes contents -------- --------------------------------------------------------- 1 1 6 67, 68, 48, 48, 49 and 1, respectively (same as Volume Descriptor Set Terminator) 1 0 32 system identifier 32 volume identifier 8 zeros 8 total number of sectors, as a both endian double word 32 zeros 4 1, as a both endian word [volume set size] 4 1, as a both endian word [volume sequence number] 4 2048 (the sector size), as a both endian word 8 path table length in bytes, as a both endian double word 4 number of first sector in first little endian path table, as a little endian double word 4 number of first sector in second little endian path table, as a little endian double word, or zero if there is no second little endian path table 4 number of first sector in first big endian path table, as a big endian double word 4 number of first sector in second big endian path table, as a big endian double word, or zero if there is no second big endian path table 34 root directory record, as described below 128 volume set identifier 128 publisher identifier 128 data preparer identifier 128 application identifier 37 copyright file identifier 37 abstract file identifier 37 bibliographical file identifier 17 date and time of volume creation 17 date and time of most recent modification 17 date and time when volume expires

17 date and time when volume is effective 1 1 1 0 512 reserved for application use (usually zeros) 653 zeros Dopo ogni VOLUME DESCRIPTOR vi è, solitamente, una PATH TABLE, che ha la funzione di rendere più veloce l accesso ai files. Ogni PATH TABLE ha diversi campi per ogni directory; il formato di un campo è il seguente: length in bytes contents -------- --------------------------------------------------------- 1 N, the name length (or 1 for the root directory) 1 0 [number of sectors in extended attribute record] 4 number of the first sector in the directory, as a double word 2 number of record for parent directory (or 1 for the root directory), as a word; the first record is number 1, the second record is number 2, etc. N name (or 0 for the root directory) 0 or 1 padding byte: if N is odd, this field contains a zero; if N is even, this field is omitted APPENDICE In questa appendice ho messo soprattutto molto codice riguardante i filesystem e la struttura dell' hard disk. Alcune parti (tante) non sono state tradotte a causa della mia pigrizia, se volete farlo voi... CODICE ASSEMBLER DI UNA MBR STANDARD ; Standard MBR = Master Boot Record ; ; These 512 bytes (excluding the last 16*4+2=66 bytes containing ; the partition table) are written to the t0h0s1 of drive #0 ; by the DOS command 'FDISK /MBR'. ; ; The BIOS code after executing POST (Power On Self Test) loads ; this sector to memory at 0000:7C00 then executes it (JMP 0000:7C00). ; ; This code first copies itself to 0000:0600. This is necessary ; because the boot sector of the active partition will be loaded ; to 0000:7C00 too. 7C00 FA CLI 7C01 33C0 XOR AX,AX 7C03 8ED0 MOV SS,AX 7C05 BC007C MOV SP,7C00 ; stack top at 0000:7C00 7C08 8BF4 MOV SI,SP ; copy from here 7C0A 50 PUSH AX 7C0B 07 POP ES 7C0C 50 PUSH AX 7C0D 1F POP DS 7C0E FB STI 7C0F FC CLD 7C10 BF0006 MOV DI,0600 ;... to 0000:0600... 7C13 B90001 MOV CX,0100 ; 512 bytes (= 256 words) 7C16 F2 REPNZ 7C17 A5 MOVSW 7C18 EA1D060000 JMP 0000:061D ; The original location of the following code was 0000:7C1D. ; As the routine above copies the whole stuff to 0000:0600, ; and runs it there, I rewrote the addresses according the new ; location.

; The following piece finds the first active (bootable) partition ; entry, and checks if there is only ONE active partition among ; the four possible partitions (the first byte of the partition ; entry decides whether a partition is bootable: ; 0x80 means bootable, 0x00 means not). 061D BEBE07 MOV SI,07BE ; start of partition table 0620 B304 MOV BL,04 ; 4 entries max. 0622 803C80 CMP BYTE PTR [SI],80 ; bootable? 0625 740E JZ 0635 0627 803C00 CMP BYTE PTR [SI],00 ; it can be only 0x00 or 0x80 062A 751C JNZ 0648 ; -> "Invalid partition table" 062C 83C610 ADD SI,+10 ; next entry 062F FECB DEC BL 0631 75EF JNZ 0622 ; all entries processed? 0633 CD18 INT 18 ; none of the partitions ; were bootable so ; start ROM-BASIC (where avail.) ; Now we check the remaining partition entries: all of them ; must be non-bootable (first byte = 0x00): 0635 8B14 MOV DX,[SI] ; drive/head 0637 8B4C02 MOV CX,[SI+02] ; cylinder/sector 063A 8BEE MOV BP,SI ; save offset of active entry 063C 83C610 ADD SI,+10 ; next entry 063F FECB DEC BL ; this was the last? 0641 741A JZ 065D ; -> boot 0643 803C00 CMP BYTE PTR [SI],00 ; is non-bootable? 0646 74F4 JZ 063C ; yes, skip to next ; This routine prints an error message (pointed to by SI). ; After printing the ASCIIZ string (0x00-terminated), it ; gets to an infinite loop: 0648 BE8B06 MOV SI,068B ; -> "Invalid partition table" 064B AC LODSB 064C 3C00 CMP AL,00 064E 740B JZ 065B 0650 56 PUSH SI 0651 BB0700 MOV BX,0007 0654 B40E MOV AH,0E 0656 CD10 INT 10 ; write character in AL to screen 0658 5E POP SI 0659 EBF0 JMP 064B 065B EBFE JMP 065B ; press reset to continue... ; Now we load the first sector of the active partition. ; The first two words of the partition entry are the drive/head, ; and cylinder/sector numbers of the first partition sector. ; These data are in the format required by the respective INT 0x13 ; calls. 065D BF0500 MOV DI,0005 ; retry 5 times 0660 BB007C MOV BX,7C00 ; load boot sector to 0000:7C00 0663 B80102 MOV AX,0201 ; read 1 sector 0666 57 PUSH DI 0667 CD13 INT 13 0669 5F POP DI 066A 730C JNB 0678 ; no error? 066C 33C0 XOR AX,AX ; else 066E CD13 INT 13 ;...reset drive 0670 4F DEC DI 0671 75ED JNZ 0660 ; try again 0673 BEA306 MOV SI,06A3 ; -> "Error loading operating system" 0676 EBD3 JMP 064B

; By now we have the boot sector in memory, we ought to ; check whether it's a valid boot sector. We can accomplish this ; by checking the last word, it must be the magic number 0xAA55. 0678 BEC206 MOV SI,06C2 067B BFFE7D MOV DI,7DFE ; last word of sector 067E 813D55AA CMP WORD PTR [DI],AA55 ; signature check 0682 75C7 JNZ 064B ; -> "Missing operating system" 0684 8BF5 MOV SI,BP ; SI = BP = offset of active partition entry 0686 EA007C0000 JMP 0000:7C00 ; jump to boot sector 0680 49 6E 76 61 6C Inval 0690 69 64 20 70 61 72 74 69-74 69 6F 6E 20 74 61 62 id partition tab 06A0 6C 65 00 45 72 72 6F 72-20 6C 6F 61 64 69 6E 67 le.error loading 06B0 20 6F 70 65 72 61 74 69-6E 67 20 73 79 73 74 65 operating syste 06C0 6D 00 4D 69 73 73 69 6E-67 20 6F 70 65 72 61 74 m.missing operat 06D0 69 6E 67 20 73 79 73 74-65 6D 00 ing system. ; Finally, here is a possible partition table: 07B0 80 01.. 07C0 01 00 06 3F 3F C4 3F 00-00 00 81 1E 0C 00 00 00...??.?... 07D0 01 C5 05 3F 7F 47 C0 1E-0C 00 40 0F 08 00 00 00...?.G...@... 07E0 41 48 82 3F 7F 53 00 2E-14 00 00 BD 00 00 00 00 AH.?.S... 07F0 41 54 83 3F BF 0F 00 EB-14 00 00 91 0B 00 55 AA AT.?...U. ; Note: ; ; We need a 0xAA55 signature at the end of the partition table ; too, because the BIOS checks it. If it's not there, we ; get a "Drive not ready" message (or similar). STRUTTURA DI UN INODE DELL'EXT2 struct ext2_inode { u16 i_mode; /* File mode */ u16 i_uid; /* Owner Uid */ u32 i_size; /* Dimensione in bytes */ u32 i_atime; /* Data di accesso */ u32 i_ctime; /* Data di creazione */ u32 i_mtime; /* Data di modifica */ u32 i_dtime; /* Data di cancellazione */ u16 i_gid; /* Group Id */ u16 i_links_count; /* Links count */ u32 i_blocks; /* Blocks count */ u32 i_flags; /* File flags */ union { struct { u32 l_i_reserved1; } linux1; struct { u32 h_i_translator; } hurd1; struct { u32 m_i_reserved1; } masix1; } osd1; /* OS dependent 1 */ u32 i_block[ext2_n_blocks];/* Pointers to blocks */ u32 i_version; /* File version (for NFS) */ u32 i_file_acl; /* File ACL */ u32 i_dir_acl; /* Directory ACL */ u32 i_faddr; /* Fragment address */ union { struct { u8 l_i_frag; /* Fragment number */ u8 l_i_fsize; /* Fragment size */

}; u16 i_pad1; u32 l_i_reserved2[2]; } linux2; struct { u8 h_i_frag; /* Fragment number */ u8 h_i_fsize; /* Fragment size */ u16 h_i_mode_high; u16 h_i_uid_high; u16 h_i_gid_high; u32 h_i_author; } hurd2; struct { u8 m_i_frag; /* Fragment number */ u8 m_i_fsize; /* Fragment size */ u16 m_pad1; u32 m_i_reserved2[2]; } masix2; } osd2; /* OS dependent 2 */ STRUTTURA DEL SUPER BLOCK DELL'EXT2 struct ext2_super_block { u32 s_inodes_count; /* Inodes count */ u32 s_blocks_count; /* Blocks count */ u32 s_r_blocks_count; /* Reserved blocks count */ u32 s_free_blocks_count; /* Free blocks count */ u32 s_free_inodes_count; /* Free inodes count */ u32 s_first_data_block; /* First Data Block */ u32 s_log_block_size; /* Block size */ s32 s_log_frag_size; /* Fragment size */ u32 s_blocks_per_group; /* # Blocks per group */ u32 s_frags_per_group; /* # Fragments per group */ u32 s_inodes_per_group; /* # Inodes per group */ u32 s_mtime; /* Mount time */ u32 s_wtime; /* Write time */ u16 s_mnt_count; /* Mount count */ s16 s_max_mnt_count; /* Maximal mount count */ u16 s_magic; /* Magic signature */ u16 s_state; /* File system state */ u16 s_errors; /* Behaviour when detecting errors */ u16 s_pad; u32 s_lastcheck; /* time of last check */ u32 s_checkinterval; /* max. time between checks */ u32 s_creator_os; /* OS */ u32 s_rev_level; /* Revision level */ u16 s_def_resuid; /* Default uid for reserved blocks */ u16 s_def_resgid; /* Default gid for reserved blocks */ u32 s_reserved[235]; /* Padding to the end of the block */ }; CREARE UN EXT2 SU FLOPPY Per creare un fs, in questo caso su floppy, si devono digitare i seguenti comandi e dovrebbe esserci lo stesso output : $ fdformat -n /dev/fd0h1440 Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kb. Formatting... done $ badblocks /dev/fd0h1440 1440 $>$ bad-blocks $ mkfs -t ext2 -l bad-blocks /dev/fd0h1440 mke2fs 0.5a, 5-Apr-94 for EXT2 FS 0.5, 94/03/10 360 inodes, 1440 blocks 72 blocks (5.00%) reserved for the super user First data block=1 Block size=1024 (log=0) Fragment size=1024 (log=0) 1 block group 8192 blocks per group, 8192 fragments per group

360 inodes per group Writing inode tables: done Writing superblocks and filesystem accounting information: done $ Il floppy viene formattato con l'opzione -n, che permette di non far ricercare i blocchi danneggiati. Prima di poter utilizzare un fs, però, va montato, ed in questo caso le istruzioni sono : $ mount /dev/hda2 /home $ mount /dev/hda3 /usr $ Il comando mount ha come argomenti il file di device corrispondente al disco che contiene il fs e la directory sotto cui va montato. Usando l'opzione -t tipofs si può anche specificare il tipo di fs da montare : $ mount -t msdos /dev/fd0 /floppy $ L'opzione -r, infine, permette di creare un fs di sola lettura : $ mount -r ext2 /dev/fd0 /floppy $ Questo è per montare un fs; e se voleste smontarlo? Si usa, in questo caso, il comando umount che accetta come argomento il file di device o il punto di mount: $ umount /dev/hda2 $ umount /usr $ STRUTTURA DEL BOOT SECTOR DI UN FLOPPY 1.4 Mb FORMATTATO CON FAT32 Offset Hexadecimal code Instruction or data 00 EB 3E 90 03 29 3E 54 29 7D 49 48 43 OEM name and number 0B 00 02 Bytes per sector. The number of bytes per sector is 200h (512). 0D 01 Sectors per cluster There is 1 sector per cluster 0E 01 00 Reserved sectors There is 1 reserved sector. This means that there are no other sectors reserved beside the boot sector. 10 02 Number of FATs There are 2 FATs. This means 1 original and 1 copy. 11 E0 00 Number of root directory entries There are 00E0h (224) entries available in the root directory. 13 40 0B Number of logical sectors in the volume There are 0B40h (2880) logical sectors on the disk. The capacity of the disk is thus 2880*512 = 1474560 bytes. 15 F0 Medium descriptor byte The code F0 stands for a double sided 3"1/2 disk with 80 tracks and 18 sectors per track. This corresponds to a 1.44 Mb floppy. This gives 2*80*18 = 2880 sectors, which is consistent with the number written at offset 13h 16 09 00 Sectors per FAT Each FAT occupies 9 sectors. As there are 2 FATs, 18 sectors are used to store them. 18 12 00 Sectors per track There are 0012h (18) sectors per track. This

There are 0012h (18) sectors per track. This is consistent with the Medium Descriptor Byte 1A 02 00 Number of heads There are 2 heads. This is consistent with the Medium Descriptor Byte. 1C 00 00 00 00 Number of hidden sectors There are no hidden sectors. The length of this field is 4 bytes because the byte at offset 26h is equal to 29h. If it was not the case, this field would be only 2 bytes long. 20 00 00 00 00 This field is only valid if the byte at offset 26h is 29h and if the number of sectors (word at offset 13h) is 0. In this case, it gives the number of sectors in the volume. It is used when the number of sectors is too big to be stored in a word. 24 00 This is the drive number. The DOS boot code uses the value stored here to know if the boot code is located on a floppy disk or on a hard disk. It needs to know this in order to know where to load the IO.SYS file from. The value of 0 here indicates the A: drive. 25 00 Reserved 26 29 Extended Boot Record Signature If the value stored here is 29h, it indicates that the fields at offset 1Eh and above are valid. 27 4D 24 F3 17 This a serial number. It has nothing to do with the serial number of the floppy given by the manufacturer. I don't know what Windows 95 writes here but it changes each time the disk is formatted. 2B 4E 4F 20 4E 41 4D 45 20 20 This is the volume label. In this case, the 20 20 string is "NO NAME". 36 46 41 54 31 32 20 20 20 This is a string which identifies the filesystem. In this case, the string is "FAT12". 3E F1 7D This word is a pointer to the name of the file which will be loaded by the boot code. As the boot code is loaded at 0000:7C00h, the value 7DF1h points to offset 7DF1h - 7C00h = 1F1h of the boot sector. This is the string : "WINBOOT.SYS". This is the start of the boot code. The short jump at offset 0 points to offset 40h. 40 FA cli 41 33 C9 xor cx,cx 43 8E D1 mov ss,cx 45 BC FC 7B mov sp,7bfc 48 16 push ss 49 07 pop es 4A BD 78 00 mov bp,0078 4D C5 76 00 lds si,[bp] 50 1E push ds 51 56 push si 52 16 push ss 53 55 push bp 54 BF 22 05 mov di,0522 57 89 7E 00 mov [bp],di 5A 89 4E 02 mov [bp+02],cx 5D B1 0B mov cl,0b 5F FC cld 60 F3 A4 rep movsb 62 06 push es 63 1F pop ds 64 BD 00 7C mov bp,7c00 67 C6 45 FE 0F mov [byte ptr di-02],0f

6B 8B 46 18 mov ax,[bp+18] 6E 88 45 F9 mov [di-07],al 71 FB sti 72 38 66 24 cmp [bp+24],ah 75 7C 04 jl 7B 77 CD 13 int 13 79 72 3C jc B7 7B 8A 46 10 mov al,[bp+10] 7E 98 cbw 7F F7 66 16 mul [word ptr bp+16] 82 03 46 1C add ax,[bp+1c] 85 13 56 1E adc dx,[bp+1e] 88 03 46 0E add ax,[bp+0e] 8B 13 D1 adc dx,cx 8D 50 push ax 8E 52 push dx 8F 89 46 FC mov [bp-04],ax 92 89 56 FE mov [bp-02],dx 95 B8 20 00 mov ax,0020 98 8B 76 11 mov si,[bp+11] 9B F7 E6 mul si 9D 8B 5E 0B mov bx,[bp+0b] A0 03 C3 add ax,bx A2 48 dec ax A3 F7 F3 div bx A5 01 46 FC add [bp-04],ax A8 11 4E FE adc [bp-02],cx AB 5A pop dx AC 58 pop ax AD BB 00 07 mov bx,0700 B0 8B FB mov di,bx B2 B1 01 mov cl,01 B4 E8 94 00 call 14B B7 72 47 jc 100 B9 38 2D cmp [di],ch BB 74 19 je D6 BD B1 0B mov cl,0b BF 56 push si C0 8B 76 3E mov si,[bp+3e] C3 F3 A6 repe cmpsb C5 5E pop si C6 74 4A je 112 C8 4E dec si C9 74 0B je D6 CB 03 F9 add di,cx CD 83 C7 15 add di,0015 D0 3B FB cmp di,bx D2 72 E5 jl B9 D4 EB D7 jmp AD D6 2B C9 sub cx,cx D8 B8 D8 7D mov ax,7dd8 DB 87 46 3E xchg [bp+3e],ax DE 3C D8 cmp al,d8 E0 75 99 jne 7B E2 BE 80 7D mov si,7d80 E5 AC lodsb E6 98 cbw E7 03 F0 add si,ax E9 AC lodsb EA 84 C0 test al,al EC 74 17 je 105 EE 3C FF cmp al,ff F0 74 09 je FB F2 B4 0E mov ah,0e F4 BB 07 00 mov bx,0007 F7 CD 10 int 10 F9 EB EE jmp E9

FB BE 83 7D mov si,7d83 FE EB E5 jmp E5 100 BE 81 7D mov si,7d81 103 EB E0 jmp E5 105 33 C0 xor ax,ax 107 CD 16 int 16 109 5E pop si 10A 1F pop ds 10B 8F 04 pop [word ptr si] 10D 8F 44 02 pop [word ptr si+02] 110 CD 19 int 19 112 BE 82 7D mov si,7d82 115 8B 7D 0F mov di,[di+0f] 118 83 FF 02 cmp di,0002 11B 72 C8 jl E5 11D 8B C7 mov ax,di 11F 48 dec ax 120 48 dec ax 121 8A 4E 0D mov cl,[bp+0d] 124 F7 E1 mul cx 126 03 46 FC add ax,[bp-04] 129 13 56 FE adc dx,[bp-02] 12C BB 00 07 mov bx,0700 12F 53 push bx 130 B1 04 mov cl,04 132 E8 16 00 call 14B 135 5B pop bx 136 72 C8 jc 100 138 81 3F 4D 5A cmp [word ptr bx],5a4d 13C 75 A7 jne E5 13E 81 BF 00 02 42 4A cmp [word ptr bx+0200],4a42 144 75 9F jne E5 146 EA 00 02 70 00 jmp 0070:0200 14B 50 push ax 14C 52 push dx 14D 51 push cx 14E 91 xchg cx,ax 14F 92 xchg dx,ax 150 33 D2 xor dx,dx 152 F7 76 18 div [word ptr bp+18] 155 91 xchg cx,ax 156 F7 76 18 div [word ptr bp+18] 159 42 inc dx 15A 87 CA xchg dx,cx 15C F7 76 1A div [word ptr bp+1a] 15F 8A F2 mov dh,dl 161 8A 56 24 mov dl,[bp+24] 164 8A E8 mov ch,al 166 D0 CC ror ah,1 168 D0 CC ror ah,1 16A 0A CC or cl,ah 16C B8 01 02 mov ax,0201 16F CD 13 int 13 171 59 pop cx 172 5A pop dx 173 58 pop ax 174 72 09 jc 17F 176 40 inc ax 177 75 01 jne 17A 179 42 inc dx 17A 03 5E 0B add bx,[bp+0b] 17D E2 CC loop 14B 17F C3 ret 180 03 181 18 182 01 183 27

0D 0A 44 69 73 71 75 65 20 184 6E 6F 6E 20 73 79 73 74 65 6D 65 20 FF 0D 0A 45 72 72 65 75 72 20 19A 64 27 45 2F 53 20 20 FF 0D 0A 52 65 6D 70 6C 61 63 65 7A 2D 6C 65 20 65 74 20 1AB 61 70 70 75 79 65 7A 20 73 75 72 20 75 6E 65 20 74 6F 75 63 68 65 20 20 0D 0A 00 49 4F 20 20 20 20 20 20 53 1D8 59 53 4D 53 44 4F 53 20 20 20 53 1E3 59 53 1EE 80 01 00 57 49 4E 42 4F 4F 54 20 53 1F1 The string : "Disque non systeme" preceeded by a carriage return and followed by FFh The string : "Erreur d'e/s" preceeded by a carriage return and followed by FFh. The string : "Remplacez-le et appuyez sur une touche", preceded by a carriage return and followed by a carriage return and 0. The filename : "IO.SYS" The filename : "MSDOS.SYS" The filename : "WINBOOT.SYS" 59 53 1FC 00 00 55 AA Note : when a jump is made in this table, the value that follows the instruction refers to the offset in the table, you don't have to add this value to the offset of the instruction (i.e. je 48h sends you to offset 48h). STRUTTURA DEL BOOT SECTOR DI UNA PARTIZIONE CON NTFS Adresse Contenu Taille (hexa) (octets) 000 Instruction de saut à la routine de boot 3 003 Nom du fabricant et n version(p.ex.ntfs) 8 00B Octets par secteur (0x200 = 512) 2 00D Secteurs par cluster (variable) 1 00E Nbre secteurs réservés (0x00) 2 010 inutilisé (0x00) 1 011 inutilisé (0x0000) 2 013 inutilisé (0x0000) 2 Descripteur de support (0xF8 pour un disque 015 dur) 1 016 inutilisé (0x0000) 2 018 Nbre de secteurs par piste (variable) 2 01A Nbre de têtes (variable) 2 Distance entre 1er secteur du volume et 1er 01C secteur du support 4 020 inutilisé (0x0000) 4 024 inutilisé (0x0000) 4 028 Nombre total de secteurs 8 N logique de cluster de $MFT (Master File 030 Table) 8 N logique de cluster de $MFTMirr (Miroir de 038 Master File Table) 8 040 Nombre de cluster par segment de fichier 4 044 Nombre de clusters par block d'index 4 N de série du disque (créé au formatage à 048 partir de la date) 8 050 Checksum 4 054 Routine de boot à 1FD 426 AA55 (code d'identification, id.secteur de 1FE partition) 2

STRUTTURA DI UNA DIRECTORY NELL ISO 9660 length in bytes contents -------- --------------------------------------------------------- 1 R, the number of bytes in the record (which must be even) 1 0 [number of sectors in extended attribute record] 8 number of the first sector of file data or directory (zero for an empty file), as a both endian double word 8 number of bytes of file data or length of directory, excluding the extended attribute record, as a both endian double word 1 number of years since 1900 1 month, where 1=January, 2=February, etc. 1 day of month, in the range from 1 to 31 1 hour, in the range from 0 to 23 1 minute, in the range from 0 to 59 1 second, in the range from 0 to 59 (for DOS this is always an even number) 1 offset from Greenwich Mean Time, in 15-minute intervals, as a twos complement signed number, positive for time zones east of Greenwich, and negative for time zones west of Greenwich (DOS ignores this field) 1 flags, with bits as follows: bit value ------ ------------------------------------------ 0 (LS) 0 for a norma1 file, 1 for a hidden file 1 0 for a file, 1 for a directory 2 0 [1 for an associated file] 3 0 [1 for record format specified] 4 0 [1 for permissions specified] 5 0 6 0 7 (MS) 0 [1 if not the final record for the file] 1 0 [file unit size for an interleaved file] 1 0 [interleave gap size for an interleaved file] 4 1, as a both endian word [volume sequence number] 1 N, the identifier length N P identifier padding byte: if N is even, P = 1 and this field contains a zero; if N is odd, P = 0 and this field is omitted R-33-N-P unspecified field for system use; must contain an even number of bytes Se volete contattarmi per critiche, consigli o altro mandatemi un'e-mail a ragnarok85@email.it