Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
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
Archives
Today
Total
관리 메뉴

컴맹의 CS study

ramfs, rootfs, initramfs 본문

reading

ramfs, rootfs, initramfs

코코블라썸 2017. 5. 20. 18:28



[1] 의 내용을 번역한 것. 

reference의 경우에는 ramfs, tmpfs, initramfs의 순서대로 설명되어 있지만 개인적으로는 거꾸로 읽는게 더 이해에 도움이 되었다. 



initramfs

2.6 이상의 kernel은 rootfs로 extract되는 cpio format의 archive를 가짐

그 archive 가 extract되서 rootfs가 나오면, 그 rootfs에 init 이라는 file이 있는지 찾는데, 찾으면 걔를 PID 1로 실행시킴

찾으면: 그 init이 하는게, locating and mounting the real root device. 

못찾으면, kernel은 old code를 보면서 root partition을 locate and mount하고, /sbin/init의 some variant를 실행


rootfs

rootfs 는 ramfs의 special instance일 뿐

user는 rootfs를 unmount 할 수가 없는데, init process를 못죽이는거나 마찬가지


ramfs

linux의 disk caching mechanism을 dynamically resizable ram-based filesystem으로 export

일반적인 FS에서 pages는 write되면 backing store로 written back하고 marked as clean한 상태로 남거나(and waits for the VM to be reallocated), 그게 아닌 상태에서는 그냥 clean한 상태이지만 data는 여전히 있는 상태(for cache purpose)로 남음

ramfs에서는 backing store가 없어서, write가 일어나도 어디로 written back할 수 없으므로 VM에 의해서 can’t be freed. 

근데 이 ramfs를 implement 하기 위한 코드는 넘 작은데 (왜냐면 어차피 disk caching mechanism을 이용하기 때문에) 그래서 linux build할때 remove할 수 있는 optional component 가 아님  (지워봤자 space saving하는 양이 넘 작아서 노의미). 

다만 문제는, 메모리를 다 썼을때 VM이 free를 할 수 없다는 건데, 그래서 막 쓰면 안되니까(?) root나 allowed user만 ramfs mount된 곳에 쓸수 있음. 


tmpfs

ramfs 유사품인데 size limit, data를 swap space로 옮길 수 있는 ability가 추가된 것.

그래서 normal user역시 tmpfs mount에 쓸 수 있음. 



Reference

[1] https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt


'reading' 카테고리의 다른 글

Denotational Semantics  (0) 2017.10.15
Comments