Home ๐Ÿ’พ [Operating System] File System ๐Ÿ’พ
Post
Cancel

๐Ÿ’พ [Operating System] File System ๐Ÿ’พ

๐Ÿ’พ File

File์ด๋ž€ HDD๋‚˜ SSD์™€ ๊ฐ™์€ ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜์— ์ €์žฅ๋œ ๊ด€๋ จ ์ •๋ณด์˜ ์ง‘ํ•ฉ์„ ๋งํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ File์€ ์˜๋ฏธ์žˆ๊ณ  ๊ด€๋ จ์žˆ๋Š” ์ •๋ณด๋ฅผ ๋ชจ์€ ๋…ผ๋ฆฌ์  ๋‹จ์œ„๋ฅผ ์˜๋ฏธํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.

๋˜ํ•œ File์„ ๋‹ค๋ฃจ๋Š” ๋ชจ๋“  ์ž‘์—…์€ OS(System Call)์— ์˜ํ•ด์„œ ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.

File์˜ Attribute๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

File AttributeDefinition Or Example
์œ ํ˜•(Type)Excution File(.exe, .com, .bin)
Object File(.obj, .o)
Source Code File(.c, .cpp, .java, .py)
Word Processor File(.xml, .doc)
Library File(.lib, .dll)
MulitiMedia File(.mpeg, .mov, .mp3)
Backup File(.rar, .zip, .tar)
ํฌ๊ธฐ(Size)File์˜ ํ˜„์žฌ ํฌ๊ธฐ์™€ ํ—ˆ์šฉ ๊ฐ€๋Šฅํ•œ ์ตœ๋Œ€ ํฌ๊ธฐ๋ฅผ ๋‚˜ํƒ€๋ƒ„
๋ณดํ˜ธ(Protection)์–ด๋–ค ์‚ฌ์šฉ์ž๊ฐ€ ํ•ด๋‹น File์„ ์ฝ๊ณ , ์“ฐ๊ณ , ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋Š”์ง€๋ฅผ ๋‚˜ํƒ€๋ƒ„
์ƒ์„ฑ ๋‚ ์งœ(Created Time)File์ด ์ƒ์„ฑ๋œ ๋‚ ์งœ
๋งˆ์ง€๋ง‰ ์ ‘๊ทผ ๋‚ ์งœ(Las Accessed Time)File์— ๋งˆ์ง€๋ง‰์œผ๋กœ ์ ‘๊ทผํ•œ ๋‚ ์งœ
๋งˆ์ง€๋ง‰ ์ˆ˜์ • ๋‚ ์งœ(Last Modified Time)File์ด ๋งˆ์ง€๋ง‰์œผ๋กœ ์ˆ˜์ •๋œ ๋‚ ์งœ
์ƒ์„ฑ์ž(Author)File์„ ์ƒ์„ฑํ•œ ์‚ฌ์šฉ์ž
์†Œ์œ ์ž(Owner)File์„ ์†Œ์œ ํ•œ ์‚ฌ์šฉ์ž
์œ„์น˜(Location)File์˜ ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜์ƒ์˜ ํ˜„์žฌ ์œ„์น˜

๐Ÿ’พ Directory

OS๋Š” ๋งŽ์€ File๋“ค์„ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ Tree-Structured Directory๋ฅผ ์‚ฌ์šฉํ•˜๋ฉฐ Directory์™€ ๊ด€๋ จ๋œ ์ž‘์—…๋“ค์€ File๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ OS(System Call)์— ์˜ํ•ด์„œ ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.

File์˜ ์œ„์น˜๋ฅผ ํŠน์ • ์ง“๊ธฐ ์œ„ํ•œ ์ •๋ณด๋กœ Absolute Path์™€ Relative Path๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

Absolute PathRelative Path
Root Directory๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋Š” ๊ฒฝ๋กœํ˜„์žฌ Directory๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋Š” ๊ฒฝ๋กœ
/home/juny/image.jpg./juny.image.jpg

๐Ÿ’พ Directory Table

Directory๋Š” ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜์— Directory Table์„ ๋‹ด์•„ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

Directory Table์— ์ €์žฅ๋œ ํ•˜๋‚˜์˜ ํ–‰์„ Directory Entry๋ผ ํ•˜๋ฉฐ ์ €์žฅ๋˜๋Š” ์ •๋ณด๋Š” File System๋งˆ๋‹ค ์ฐจ์ด๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ’พ File Allocation

ํ•˜๋‚˜์˜ File์ด ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜์— ์ €์žฅ๋  ๋•Œ๋Š” OS๊ฐ€ ํ•˜๋‚˜ ์ด์ƒ์˜ Sector๋ฅผ Block์ด๋ผ๋Š” ๋‹จ์œ„๋กœ ๋ฌถ์€ ๋’ค ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

File์„ ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜์— ์ €์žฅํ•˜๋Š” ๋ฐฉ๋ฒ•์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒƒ๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค.

File Allocation์ •์˜์žฅ์ ๋‹จ์ 
Contiguous Allocation(์—ฐ์† ํ• ๋‹น)๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜ ๋‚ด ์—ฐ์†์ ์ธ Block์— File์„ ์ €์žฅํ•˜๋Š” ๋ฐฉ์‹๊ตฌํ˜„์ด ๋‹จ์ˆœ์™ธ๋ถ€ ๋‹จํŽธํ™”
Linked Allocation(์—ฐ๊ฒฐ ํ• ๋‹น)๊ฐ Block ์˜ ์ผ๋ถ€์— ๋‹ค์Œ Block์˜ ์ฃผ์†Œ๋ฅผ ์ €์žฅํ•˜์—ฌ ๊ฐ Block์ด ๋‹ค์Œ Block์„ ๊ฐ€๋ฆฌํ‚ค๋Š” ํ˜•ํƒœ๋กœ ํ• ๋‹นํ•˜๋Š” ๋ฐฉ์‹์™ธ๋ถ€ ๋‹จํŽธํ™” ํ•ด๊ฒฐโ€ข ๋ฐ˜๋“œ์‹œ ์ฒซ ๋ฒˆ์งธ Block๋ถ€ํ„ฐ ํ•˜๋‚˜์”ฉ ์ฐจ๋ก€๋Œ€๋กœ ์ฝ์–ด์•ผ ํ•จ
โ€ข H/W ๊ณ ์žฅ์ด๋‚˜ ์˜ค๋ฅ˜ ๋ฐœ์ƒ์‹œ ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” Block ์ดํ›„์— ์žˆ๋Š” Block์—๋Š” ์ ‘๊ทผํ•  ์ˆ˜ ์—†์Œ
Indexed Allocation(์ƒ‰์ธ ํ• ๋‹น)File์˜ ๋ชจ๋“  Block ์ฃผ์†Œ๋ฅผ Index Block์ด๋ผ๋Š” ํ•˜๋‚˜์˜ Block์— ๋ชจ์•„ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ์‹ย ย 

๐Ÿ’พ Contiguous Allocation(์—ฐ์† ํ• ๋‹น)

๐Ÿ’พ Linked Allocation(์—ฐ๊ฒฐ ํ• ๋‹น)

๐Ÿ’พ Indexed Allocation(์ƒ‰์ธ ํ• ๋‹น)

๐Ÿ’พ File System

File System์ด๋ž€ File๊ณผ Directory๋ฅผ ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜์— ์ผ๋ชฉ์š”์—ฐํ•˜๊ฒŒ ์ €์žฅํ•˜๊ณ  ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” OS ๋‚ด๋ถ€ ํ”„๋กœ๊ทธ๋žจ์ž…๋‹ˆ๋‹ค.

File System์—์„œ ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” Partitioning๊ณผ Formatting์ด ๋จผ์ € ์ง„ํ–‰๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  • Partitioning: ์ €์žฅ ์žฅ์น˜์˜ ๋…ผ๋ฆฌ์ ์ธ ์˜์—ญ์„ ๊ตฌํšํ•˜๋Š” ์ž‘์—…
  • Low-Level Formatting: ์ €์žฅ ์žฅ์น˜๋ฅผ ์ƒ์„ฑํ•  ๋‹น์‹œ ๊ณต์žฅ์—์„œ ์ˆ˜ํ–‰๋˜๋Š” ๋ฌผ๋ฆฌ์ ์ธ Formatting
  • High-Level Formatting: File System์„ ์ƒ์„ฑํ•˜๋Š” Formatting

File System์˜ ์ข…๋ฅ˜๋กœ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒƒ๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค.

File SystemOSJournaling ์ง€์› ์œ ๋ฌด
FAT File SystemUSB, SD ์นด๋“œ ๋“ฑ ์ €์šฉ๋Ÿ‰ ์ €์žฅ ์žฅ์น˜โญ•
Unix File SystemUnix ๊ณ„์—ด OSโญ•
NTFS(NT File System)Window OSโญ•
ext File SystemLinux OSโญ•
  • Journaling: ์ž‘์—… Log๋ฅผ ํ†ตํ•ด System Crash๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ๋•Œ ๋น ๋ฅด๊ฒŒ ๋ณต๊ตฌํ•˜๊ธฐ ์œ„ํ•œ ๋ฐฉ๋ฒ•
  • System Crash: File System์„ ๋ณ€๊ฒฝํ•˜๋Š” ๋„์ค‘์— ์ „์›์ด ๋‚˜๊ฐ€๊ฑฐ๋‚˜ ์น˜๋ช…์ ์ธ ์˜ค๋ฅ˜๋กœ ์ธํ•ด ์ปดํ“จํ„ฐ๊ฐ€ ๊ฐ•์ œ๋กœ ์ข…๋ฃŒ๋˜์–ด ๋ฒ„๋ฆฌ๋Š” ์ƒํ™ฉ

๐Ÿ’พ FAT File System

FAT File System์€ Linked Allocation์˜ ๋‹จ์ ์„ ๋ณด์™„ํ•œ File System์œผ๋กœ ๊ฐ Block์— ํฌํ•จ๋˜์–ด ์žˆ๋˜ ๋‹ค์Œ Block์˜ ์ฃผ์†Œ๋“ค์„ FAT(File Allocation Table)์— ๋ชจ์•„ ํ•œ ๋ฒˆ์— ๊ด€๋ฆฌํ•˜๋Š” File System์ž…๋‹ˆ๋‹ค.

FAT File System์€ ๋ฒ„์ „์— ๋”ฐ๋ผ FAT$12$, FAT$16$, FAT$32$๋กœ ๋‚˜๋ˆ„์–ด์ง€๋ฉฐ $12$, $16$, $32$๋Š” Block์„ ํ‘œํ˜„ํ•˜๋Š” Bit ์ˆ˜์ž…๋‹ˆ๋‹ค.

HDD์˜ ํ•œ Partition์„ FAT$12$์œผ๋กœ Formattingํ•˜๋ฉด ํ•ด๋‹น Partition์€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค.

๐Ÿ’พ Unix File System

Unix File System์€ Indexed Allocation ๊ธฐ๋ฐ˜์˜ File System์ž…๋‹ˆ๋‹ค.

i-node(Index Block)์—๋Š” File Attribute ์ •๋ณด์™€ 15๊ฐœ์˜ Block ์ฃผ์†Œ๊ฐ€ ์ €์žฅ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Unix File System์—๋Š” File๋งˆ๋‹ค i-node๊ฐ€ ์žˆ๊ณ  i-node๋งˆ๋‹ค ๋ฒˆํ˜ธ๊ฐ€ ๋ถ€์—ฌ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  HDD์˜ ํ•œ Partition์„ Unix File System์œผ๋กœ Formattingํ•˜๋ฉด ํ•ด๋‹น Partition์€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค.

Unix File System์—์„œ i-node์— ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” Block์€ 15๊ฐœ๋กœ ์ œํ•œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— Blcok์„ ๋” ๋งŽ์ด ํฌํ•จํ•˜๋„๋ก ํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

Block ์ฃผ์†Œ์ €์žฅ
$0$๋ฒˆ ~ $11$๋ฒˆDirect Block(์ง์ ‘ ๋ธ”๋กœ) ์ฃผ์†Œ๋ฅผ ์ €์žฅ
$12$๋ฒˆSingle Indirect Block(๋‹จ์ผ ๊ฐ„์ ‘ ๋ธ”๋ก)์„ ์ €์žฅ
$13$๋ฒˆDouble Indirect Block(์ด์ค‘ ๊ฐ„์ ‘ ๋ธ”๋ก)์„ ์ €์žฅ
$14$๋ฒˆTriple Indirect Block(์‚ผ์ค‘ ๊ฐ„์ ‘ ๋ธ”๋ก)์„ ์ €์žฅ
  • Single Indirect Block(๋‹จ์ผ ๊ฐ„์ ‘ ๋ธ”๋ก): File์ด ์ €์žฅ๋œ Block์ด ์•„๋‹Œ File์„ ์ €์žฅํ•œ Block์˜ ์ฃผ์†Œ๊ฐ€ ์ €์žฅ๋œ Block
  • Double Indirect Block(์ด์ค‘ ๊ฐ„์ ‘ ๋ธ”๋ก): Single Indirect Block์„ ์ €์žฅํ•˜๋Š” Block
  • Triple Indirect Block(์‚ผ์ค‘ ๊ฐ„์ ‘ ๋ธ”๋ก): Double Indirect Block์„ ์ €์žฅํ•˜๋Š” Block
This post is licensed under CC BY 4.0 by the author.

๐Ÿ’พ [Operating System] Virtual Memory ๐Ÿ’พ

๐ŸŒ [Network] About Network ๐ŸŒ