570 likes | 711 Views
Lecture 2 – Booting and Files. Views of Operating Systems OS Files Booting iNodes Links Compression. OS Definitions By View. An “OS” is somewhat nebulous to define Various groups emphasize different pieces. OS - Functionality.
E N D
Lecture 2 – Booting and Files • Views of Operating Systems • OS Files • Booting • iNodes • Links • Compression
OS Definitions By View • An “OS” is somewhat nebulous to define • Various groups emphasize different pieces
OS - Functionality From the book by Silbershatz and others: "What are the three main purposes of an operating system? • To provide an environment for a computer user to execute programs on computer hardware in a convenient and efficient manner. • To allocate the separate resources of the computer as needed to solve the problem given. The allocation process should be as fair and efficient as possible. • As a control program it serves two major functions: (a) supervision of the execution of user programs to prevent errors and improper use of the computer, and (b) management of the operation and control of I/O devices."
OS - Components • An OS consists of: • Virtual Machine • File Manager • Process Manager • Network • Input/Output • User Manager • Booting • System programs
OS - Components • An alternative view: • Kernel (“core” of the OS) • RAM disk (memory) • Drivers (programs to talk to hardware) • Interrupt handlers (software to deal with interrupts)
OS - Components • These are NOT parts of the OS: • GUIs (KDE, Windows Explorer) • CLIs (bash, cmd, powershell) • IE, Word, Acrobat Reader, Netbeans, notepad
OS – System Calls • “What can it do?” • cd, chown, writev, tanf, stdrup, printf, mctl, … • http://technet.microsoft.com/en-us/library/cc754234.aspx
OS - Files • Linux • /boot/grub: the bootloader • Vmlinuz: the kernel (“linked”) • Initrd.gz: system files needed for booting • /lib/modules: Dynamically loadable modules for kernel
OS - Files • Linux • /sbin: system programs • /usr/sbin: more system progs • Swap space (separate partition) • /bin, /usr/bin, …: Not part of OS
OS - Files • Windows • Ntldr: the bootloader • Ntoskrnl: the kernel • Bunch of DLLs • Hal.dll: hardware abstraction layer • Pagefile.sys: virtual memory bookkeeper
Booting the OS • Very complex • http://www.pcguide.com/ref/mbsys/bios/bootSequence-c.html
OS on USB • Installation of Windows and/or Linux on a flash drive • 2 Ways to install • “Regular” install: Install as normal, but select drive as target • “Manual” install: Boot into OS; copy content onto flash drive; install bootloader; close eyes and hope it works
OS on USB • Installation of Windows and/or Linux on a flash drive • 2 Ways to install • “Regular” install: Install as normal, but select drive as target • “Manual” install: Boot into OS; copy content onto flash drive; install bootloader; close eyes and hope it works
Hard Drive Layout Dear students, Please give the bearded man a moment to draw pretty pictures. They will help you! Your Instructor
Hard Drive Layout • /dev/sda1 • /dev/ • sd • a • 1
Partitions • RVH’s number game • Use 1000111001 • Vfat vs. ntfs vs. ext2/3/4
Hard Drive Layout • Partitions • Divisions of hard drive • Volume • Different from partitions • Can expand multiple partitions
Overview • Partition the USB drive • Make file volume (format) • Mount • Copy OS files • Install GRUB
Lab Notes • Our installation is identical, except: • Smaller (probably) • Slower • Slower than HDD • Might not be swap partition • Used compressed read-only file • Read-only
Files • Usually stored on non-volatile medium • Sequence of bytes • RVH’s number game
Files • Usually stored on non-volatile medium • Consist of name & content • Content is of bytes • RVH’s number game • Every file has a structure • Some file types impose a rigid structure • Others are loosely defined
Filenames • Base name • Usually pretty open character set (a-Z, 0-9, #, ~, (, ), etc) • Extension • Usually 3 characters • Usually indicates file type • Windows relies heavily on ext. • Linux is a bit smarter (magic number)
Filenames • Base + extension • Length usually limited by OS • Total path of no more than X bytes • Some conventions • Backup files ( .:~ ) • Autosave files ( #:.:# ) • Convention…not requirement
Contents of a File • Text files (printable characters) • Binary files (nothing to see here) • Mixed/Heterogeneous files
iNodes • OS doesn’t use “file names” • It uses a magic thing called an iNode • We talk about it here, but CEG433 will explain in detail
iNodes Dear students, Please give the bearded man a moment to draw pretty pictures. They will help you! Your Instructor
iNodes • Has: • Location on hard drive - block number(s) • File size • Last modification time • etc • Doesn’t have: • Content • File name (coming up)
iNumbers • iNumber is an index into the array of iNodes • Every file has iNumber • File A and File B have different iNumbers • 0th iNumber is conventionally vacant
Directory • It IS a file…it’s just special • Unless noted, “file” will NOT include directories. • 2-column table • Name (here it is!) • iNumber
Directories • Row-order is irrelevant • We care about keeping association of file names and file content.
Special Directory Files • Every directory knows itself • “ . ” • Every directory has a parent directory • “ .. ”
Special Directory Files • Every directory knows itself • “ . ” • Every directory has a parent directory • “ .. ” • Who is the root’s parent directory?
Special Directory Files • Every directory knows itself • “ . ” • Every directory has a parent directory • “ .. ” • Itself!
Directory Tree • We exclude 2 things when we draw the tree
Directory Tree • We exclude 2 things when we draw the tree • “ . “ and “ .. “
Directory Tree • We exclude 2 things when we draw the tree • “ . “ and “ .. “ • Hard/Soft links • Hang on...we’ll get there!
Directory Tree • Root • Linux • “/” • Windows • Kinda, sorta hidden a bit • Usually refer to its contents directly • C: , D: , etc
Links • Has other meanings outside of “file” scope • i.e., not just hyperlinks • A link is (essentially) a pointer • One copy, lots of references
Links • Every file MUST have at least one [hard]1 link • What happens when we don’t? • Files can have multiple links! 1. Ignore this word until we get to the next slide
Links • Every file MUST have at least one [hard]1 link • What happens when we don’t? • “Floating data” • Files can have multiple links! 1. Ignore this word until we get to the next slide
Hard Links • Hard link count = 1 • New [hard] links increment • How do we get these? • “ln origFile.txt newFile.txt” • What does this do?
Hard Links • Hard link count = 1 • New [hard] links increment • How do we get these? • “ln origFile.txt newFile.txt” • What does this do? • “One copy…multiple references”
Hard Links • When hard link count = 0: • No one needs the file • Delete it
Soft Links • “Symbolic links” or “symlinks” • They are “Windows shortcuts” • We open the single original file • We assume the original file is there • If not, the link is “broken”
Linux-Specific Links • Hard links must stay on partition & drive • Hard links cannot point to directories; soft links can
Window-Specific Links • No hard links • “Junctions” are symlinks to directories • Soft links • “shortcuts” • Have extension of “lnk”
File Types • Windows “needs” extensions • Linux is all grown up
File Type Examples TXT C CPP PDF JAVA CLASS PY ODT HTM/HTML SO DLL O OBJ ZIP TAR GZ BZ2
Interoperability • I made a file on Windows • Can I use it in Linux? • I made a file on Linux • Can I use it in Window? • Do MacOS-generated files play with anyone else?
Interoperability • I made a file on Windows • Can I use it in Linux? • I made a file on Linux • Can I use it in Window? • Do MacOS-generated files play with anyone else? Maybe