際際滷

際際滷Share a Scribd company logo
LinuxFEST 3/2008




               GNU/Linux
                      S炭borov辿 syst辿my



Predn叩邸aj炭ci: Michal Sedl叩k
Email: michal6103 at gmail dot com
厩看糸




     Vizu叩lna t辿ma prezent叩cie je odvoden叩 od
                od t辿my vytvorenej:

            Sakari Koivunen and Henrik Omma
             Released under the LGPL license.




29.3.2008                 LinuxFEST 3           2/48
Obsah

   
       S炭bory
           typy s炭borov, atrib炭ty, pr叩va, pr鱈kazy
   
       o je to s炭borov箪 syst辿m
   
       S炭borov辿 syst辿my
           ext2, ext3, ext4, ReiserFS, UnionFS....
           preo 僓鉛邸庄艶 FS
           rozdiely




29.3.2008                     LinuxFEST 3             3/48
厩看糸




   Na UNIX-ovom syst辿me je v邸etko s炭bor, a
     ak nieo nie je s炭bor, tak je to proces

    V Plan9, Inferno OS je 炭plne v邸etko s炭bor




29.3.2008              LinuxFEST 3              4/48
Typy s炭borov
michal@backup:~/linuxfest$ ls -l
total 172
drwxr-xr-x 2 michal michal   4096 2008-03-28 13:19 adresar
-rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 hl-osnova.odt
-rw-r--r-- 1 michal michal 100462 2008-03-19 19:59 Linuxfest.tar.gz
-rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 osnova.odt
lrwxrwxrwx 1 michal michal     10 2008-03-28 13:19 sl-osnova.odt ->
osnova.odt

   
       d    Directory                    
                                             r     read      list directory
   
       l    Link                         
                                             w write
   
       c    Character special file       
                                             x     execute   recurse directory
   
       s    Socket
   
       p    named Pipe (FIFO)
   
       b    Block device


29.3.2008                            LinuxFEST 3                              5/48
s,S,t,T
   
       t,T - sticky bit
           s炭bor - Linux ignoruje sticky bit na s炭boroch
           adres叩r - s炭bory m担転e maza泥 a
            premenov叩va泥 len vlastn鱈k s炭borov
   
       s,S - Set User ID, Set Group ID
           SUID,SGID s炭bor  s炭bor sa spust鱈 s pr叩vami
            vlastn鱈ka, alebo skupiny s炭boru
           SGID adres叩r  s炭bory vytvoren辿 vo vn炭tri
            adres叩ra budu mat nastaven炭 skupinu ako
            tento adres叩r (zdie直anie s炭borov)

29.3.2008                      LinuxFEST 3                  6/48
d - Adres叩r, prieinok,
 zlo転ka
/bin    programy zdielan辿 u転鱈vate直mi a rootom
/boot   Inicializan辿 s炭bory, kernel, popripade grub a
        jeho nastavenia (vmlinuz, initrd.gz).
/dev    referencie na hardv辿r, reprezentovan箪 s炭bormy
/etc    konfiguran辿 s炭bory - Editable Text
        Configuration Dennis Ritchie tvrd鱈, 転e to je
        skratka "et cetera"
/home u転鱈vate直sk辿 adres叩re
/initrd bootovacie skripty (iba v niektorych distr叩ch)
/lib    kni転nice potrebn辿 na beh programov
/lost+found s炭bory obnoven辿 diagnostick箪mi n叩strojmy
/misc r担zny 炭el
/media pripojen辿 perif辿rie, cd-rom, usb k直炭, mp3 player

29.3.2008                 LinuxFEST 3                7/48
d - Adres叩r, prieinok,
 zlo転ka


/opt        tre泥ostrann箪 softv辿r
/proc       virtu叩lny filesystem s inform叩ciami o
            syst辿mov箪ch zdrojoch
/root       dom叩ci adres叩r u転鱈vate直a root
/sbin       syst辿mov辿 programy
/tmp        doasn辿 s炭bory, ma転e sa pri reboote
/usr        u転鱈vate直sk辿 programy, kni転nice, dokument叩cia
/var        premenliv辿 s炭bory, logy, datab叩zy, print spooler,
            mail queue




29.3.2008                      LinuxFEST 3                 8/48
c - peci叩lne znakov辿 s炭bory

   
       v辰ina je v /dev


  /dev/null      prijme a zru邸鱈 akeko直vek d叩ta
  /dev/full      v転dy pln辿 zariadenie
  /dev/loop      loopback disk device
  /dev/zero      generuje pr炭d n炭l (NUL)
  /dev/random    generuje pseudon叩hodn辿 鱈sla (blok)
  /dev/urandom   generuje pseudon叩hodn辿 鱈sla




29.3.2008                 LinuxFEST 3                  9/48
l  symbolick叩 linka

   
       Soft link
           obsahuje meno a cestu in辿ho s炭boru
           ln -s meno1 meno2
   
       Hard link
           hard link je pointer na inode vo filesyst辿me
           nie je mo転n辿 spravi泥 hardlink na in箪
            filesystem
           ln meno1 meno2


29.3.2008                      LinuxFEST 3                 10/48
hard vs. soft


michal@backup:~/linuxfest$   ls -l
total 172
drwxr-xr-x 2 michal michal     4096   2008-03-28   13:19   adresar
-rw-r--r-- 2 michal michal    32226   2008-03-19   19:59   hardlink-osnova.odt
-rw-r--r-- 1 michal michal   100462   2008-03-19   19:59   Linuxfest.tar.gz
-rw-r--r-- 2 michal michal    32226   2008-03-19   19:59   osnova.odt
lrwxrwxrwx 1 michal michal       10   2008-03-28   13:19   softlink-osnova.odt
-> osnova.odt
michal@backup:~/linuxfest$   ls -lL
total 204
drwxr-xr-x 2 michal michal     4096   2008-03-28   13:19   adresar
-rw-r--r-- 2 michal michal    32226   2008-03-19   19:59   hardlink-osnova.odt
-rw-r--r-- 1 michal michal   100462   2008-03-19   19:59   Linuxfest.tar.gz
-rw-r--r-- 2 michal michal    32226   2008-03-19   19:59   osnova.odt
-rw-r--r-- 2 michal michal    32226   2008-03-19   19:59   softlink-osnova.odt




29.3.2008                            LinuxFEST 3                         11/48
hard vs. soft


michal@backup:~/linuxfest$   ls -l
total 172
drwxr-xr-x 2 michal michal     4096   2008-03-28   13:19   adresar
-rw-r--r-- 2 michal michal    32226   2008-03-19   19:59   hl2-osnova.odt
-rw-r--r-- 2 michal michal    32226   2008-03-19   19:59   hl-osnova.odt
-rw-r--r-- 1 michal michal   100462   2008-03-19   19:59   Linuxfest.tar.gz
lrwxrwxrwx 1 michal michal       10   2008-03-28   13:19   sl-osnova.odt ->
osnova.odt
michal@backup:~/linuxfest$   ls -lL
total 172
drwxr-xr-x 2 michal michal     4096   2008-03-28   13:19   adresar
-rw-r--r-- 2 michal michal    32226   2008-03-19   19:59   hl2-osnova.odt
-rw-r--r-- 2 michal michal    32226   2008-03-19   19:59   hl-osnova.odt
-rw-r--r-- 1 michal michal   100462   2008-03-19   19:59   Linuxfest.tar.gz
?--------- ? ?      ?             ?                    ?   sl-osnova.odt




29.3.2008                            LinuxFEST 3                         12/48
s  domain socket
 p - pipe

   
       sl炭転ia na medzi-procesov炭
       komunik叩ciu(IPC) ponad pr鱈stupov辿 pr叩va
       s炭borov辿ho syst辿mu
#Socket
python> import socket
python> my_scoket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
python> my_socket.bind('/tmp/socket_name')


#pipe
python> import os
python> receive,transmit = os.pipe()




29.3.2008                       LinuxFEST 3                      13/48
S炭borov箪 syst辿m

   
       popisuje ak箪m sp担sobom s炭 ulo転en辿
       d叩ta, HDD, FDD, CD-ROM, sie泥 (SMB,
       NFS), procfs...
   
       nieko直ko vrstiev abstrakcie umo転uj炭cich
       pr鱈stup k 炭dajom
   
       virtu叩lny filesystem m担転e reprezentova泥
       ak辿ko直vek d叩ta (WikipediaFS, procfs)



29.3.2008                LinuxFEST 3             14/48
Metad叩ta

  
      okrem mena s炭boru a jeho obsahu sa
      ukladaj炭 aj in辿 d叩ta
         as vytvorenia
         as posledn辿ho pr鱈stupu
         vlastn鱈k (user, group)
         pr鱈stupov辿 pr叩va
         ve直kos泥
         roz邸鱈ren辿 atrib炭ty (autor dokumentu, k坦dovanie)


29.3.2008                    LinuxFEST 3             15/48
Sch辿ma




29.3.2008   LinuxFEST 3   16/48
i-node

   
       z叩kladn叩 jednotka UNIX FS
   
       ukazuje na 僓鉛邸庄艶 i-nody, alebo bloky d叩t




29.3.2008                LinuxFEST 3           17/48
superblok

   
       邸trukt炭ra obsahuj炭ca z叩kladn辿 inform叩cie
       o disku
           geometria
           vo直n辿 miesto
           umiestnenie prv辿ho i-nodu
   
       nevyhnutn箪 pri boote
   
       k坦pie superbloku v ka転dej skupine blokov



29.3.2008                    LinuxFEST 3     18/48
superblok

backup:/home/michal/linuxfest# dumpe2fs /dev/hda1 | grep -i
superblock
dumpe2fs 1.40-WIP (14-Nov-2006)
  Primary superblock at 1, Group descriptors at 2-2
  Backup superblock at 8193, Group descriptors at 8194-8194
  Backup superblock at 24577, Group descriptors at 24578-24578
  Backup superblock at 40961, Group descriptors at 40962-40962
  Backup superblock at 57345, Group descriptors at 57346-57346
  Backup superblock at 73729, Group descriptors at 73730-73730
  Backup superblock at 204801, Group descriptors at 204802-204802
  Backup superblock at 221185, Group descriptors at 221186-221186




29.3.2008                       LinuxFEST 3                         19/48
貼顎姻稼叩鉛

   
       synchroniz叩cia - race condition
           zmazanie s炭boru
             
                 uvo直nenie miesta na disku
             
                 odstr叩nenie s炭boru zo z叩znamov v prieinku
   
       do 転urn叩lu sa zapisuj炭 bud炭ce oper叩cie
           iba atomick辿 zmeny = ve直a 炭dajov
           Reiser4 zhlukuje atomick辿 zmeny do
            spojit辿ho bloku a t箪m optimalizuje 転urn叩l
           v pr鱈pade p叩du je obnova r箪chlej邸ia ako fsck

29.3.2008                          LinuxFEST 3                20/48
貼顎姻稼叩鉛 nie

   
       niektor辿 FS s炭 st叩le konzistentn辿, resp.
       jedinou nekonzistenciou m担転e by泥
       straten辿 miesto (Unix File System)
           soft updates  obmedz鱈 sa mno転ina
            asynchr坦nnych oper叩ci鱈
           zber smet鱈 je v辰邸inou na pozad鱈 (garbage
            collection)




29.3.2008                     LinuxFEST 3               21/48
S炭borov辿 syst辿my




29.3.2008         LinuxFEST 3   22/48
ext2

   
       1993 - second extended file system
   
       nato直ko r箪chly, 転e sa pou転鱈va na
       benchmarky
   
       /boot, /tmp
      5% pre roota tune2fs -m 1 /dev/sdXY
   
       clean, not clean parameter
      zapnutie 転urn叩lu tune2fs -j /dev/hdXX


29.3.2008                LinuxFEST 3        23/48
ext3

  
      2001 - Third extended file system
  
      ext2 roz邸鱈ren箪 o 転urn叩l
  
      3 re転imy
         Writeback  転urn叩luje iba metad叩ta, ur箪chly
          kontrolu konzistentnosti
         Ordered  akanie na z叩pis d叩t a potom zmena
          metad叩t (metad叩ta zodpovedaj炭 d叩tam)
         Journal  pln箪 転urn叩l, v邸etko rob鱈me 2x
  
       nem叩 undelete  nuluje pointery na bloky v
       i-node zmazan箪ch LinuxFEST 3
29.3.2008
                        s炭borov               24/48
ext3

   
       bez 転urn叩lu r箪chlej邸鱈 ako ext2
   
       邸tandardn箪 FS v mnoh箪ch distr叩ch
   
       転iaden n叩stroj na defragment叩ciu
   
       転iadne kryptovanie
   
       転iadna kompresia
   
       転iadne chekcksumy v 転urn叩le
   
       podpora ACL a extended attributes

29.3.2008                 LinuxFEST 3      25/48
ext4

   
       nestabiln箪, 2.6.19
   
       ve直k辿 disky 1024 pebibytes
   
       sp辰tne aj dopredne kompatibiln箪 s ext3
   
       mo転nos泥 predbe転nej alok叩cie s炭visl箪ch blokov
   
       viac ako 32000 adres叩rov
   
       journal checksum
   
       online defragment叩cia
   
       rozl鱈邸enie timestempu 1ns

29.3.2008                   LinuxFEST 3               26/48
ext2,3,4
  Max file size                      2 TiB
  Max filename size                  255 characters
  Max volume size                    16 TiB
  Allowed characters in filenames    Any byte except NUL and '/'



  Max file size                      16GiB  2TiB
  Max filename size                  255 bytes
  Max volume size                    2TiB  32TiB
  Allowed characters in filenames    All bytes except NUL and '/'



  Max file size                      16 TiB
  Max filename size
  Max volume size                    1024 PiB = 1 EiB
  Allowed characters in filenames    All bytes except NUL and '/'


29.3.2008                           LinuxFEST 3                     27/48
Ako je to s fragment叩ciou
 Ext2, Ext3, Ext4

   
       Ext2-4 sa fragmentuje
   
       hlavne ke je na disku m叩lo miesta
   
       priemern叩 fragment叩cia je minim叩lna
           prejavuje sa na vy泥a転en箪ch serveroch
           m辿diacentr叩ch s obrovsk箪mi d叩tov箪mi tokmi
   
       Ako to funguje?




29.3.2008                    LinuxFEST 3            28/48
ReiserFS

   
       2001 - prv箪 s podporou 転urn叩lu v kernely
   
       vysok箪 v箪kon
           efekt鱈vne ukladanie mal箪ch s炭borov
             
                 ukladanie koncov do jedn辿ho bloku
             
                 viac s炭borov v jednom bloku
           ve直k辿 mno転stvo s炭borov v adres叩ry
   
       vhodn箪 na http cache, mail cache, db
Max file size          8 TiB
Max number of files 232 (~4 billion)
Max volume size                   16 TiB
Allowed characters in filenames   All bytes except NUL and '/'
29.3.2008                          LinuxFEST 3                   29/48
JFFS2 - Journalling Flash
 File System verzia 2

   
       navrhnut箪 pre flash pam辰te
           vyu転鱈vanie cel辿ho adresn辿ho priestoru
           neprepisovanie t箪ch ist箪ch miest
   
       routery, CF karty, USB k直炭e
   
       podporuje hard linky
   
       kompresia  zlib, rubin, rtime
   
       podpora NAND flash (sekvenn辿 鱈tanie)
   
       garbage collector na pozad鱈
29.3.2008                     LinuxFEST 3           30/48
JFFS2 - Journalling Flash
 File System verzia 2

   
       ned叩 sa poveda泥 ko直ko miesta je free
   
       pri pripojen鱈 je nutn辿 skontrolova泥 v邸etky
       inode-i (relat鱈vne pomal辿 pripojenie)



   
       n叩stupca je LogFS uren箪 pre ve直k辿
       flashov辿 pam辰te


29.3.2008                LinuxFEST 3            31/48
SQUASHFS

   
       pre flash disky
   
       read only (firmv辿ry, kiosky, LiveCD...)
   
       r箪chla kompresia  LZMA, GZIP
   
       RW v kombin叩ci鱈 s UnionFS
           Slax, BackTrack
           OpenWRT
   
       mksquashfs, unsquashfs


29.3.2008                     LinuxFEST 3        32/48
UnionFS

   
       umo転uje vytvori泥 RW filesystem ponad
       RO z叩klad, stack-ovac鱈 FS
   
       CD + HDD = jeden filesyst辿m
   
       zapisovate直n叩 vetva ma v辰邸iu prioritu
   
       mazanie z RO m辿dia cez .wh. s炭bory,
       alebo vlastn箪 oddiel na RW part鱈ci鱈
   >mount -t unionfs -o dirs=/media/cdrom,/tmp none /home/cdrw




29.3.2008                        LinuxFEST 3                     33/48
XFS

   
       najstar邸鱈 転urn叩lovac鱈 FS
   
       pre high-end servery
   
       podpora pre multiprocesorov辿 po鱈tae
   
       転urn叩l  navrnut箪 tak aby mal minim叩lny
       dopad na v箪kon




29.3.2008                LinuxFEST 3           34/48
Btrfs v0.1

   
       iba vo v箪voji, in邸pirovan箪 ZFS
   
       efekt鱈vna pr叩ca s mal箪mi aj velk箪mi s炭bormi
       (rozsahy  転iadne zoznamy inodov)
   
       snapshotting (aj sn鱈mky s炭 転iv辿 a m担転u by泥
       upraven辿), ve直mi r箪chle
   
       copy-on-write
   
       kontroln辿 s炭ty v邸etk辿ho
   
       nie je potrebn箪 転urn叩l
   
       r箪chla kontrola (online kontrola v pl叩ne)

29.3.2008                   LinuxFEST 3              35/48
Btrfs v0.1
   
       online zmeny ve直kosti
   
       sub-oddiely  viac oddielov v jedno
       filesyst辿me (konverzia Ext3 -> Btrfs)
   
       nesk担r:
           storage polls  viac zariaden鱈
           mirroring a stripping
           inkrement叩lne z叩lohy
Max file size             16 EiB
Max number of files       264
Max filename size         255 bytes
Max volume size           16 EiB
Allowed characters in filenames    All bytes except NUL and '/'
29.3.2008                       LinuxFEST 3                       36/48
tmpfs

   
       Pseudo filesyst辿m, ktor箪 uchov叩va v邸etky
       s炭bory v RAM



$mount none /mnt/xyz -t tmpfs -o size=100m




29.3.2008                 LinuxFEST 3        37/48
/sys

   
       pseudo filesyst辿m umo転uj炭ci pr鱈stup ku
       vn炭torn箪m premenn箪m kernelu
   
       napr鱈klad zoznam modulov
           ls /sys/module
   
       umo転nil vznik udev




29.3.2008                    LinuxFEST 3     38/48
/dev

   
       pseudo filesyst辿m s dynamick箪m
       zoznamom zariaden鱈
   
       ka転d辿 zariadenie m叩 s炭bor v /dev
   
       minor, major 鱈slo (2.7 dynamick辿)
   
       udev
           mimo kernel, v userspace
           dynamick辿 vytv叩ranie polo転iek



29.3.2008                    LinuxFEST 3    39/48
/proc

   
       pseudo filesystem zobrazuje inform叩cie o
       procesoch
   
       /proc/pid
           /proc/PID/cmdline pr鱈kaz ktor箪 proces spustil
           /proc/PID/cwd symlink na pracovny adres叩r
           /proc/PID/exe symlink na spustite直n箪 s炭bor
           /proc/PID/root cesta ku koreov辿mu
            adres叩ru


29.3.2008                     LinuxFEST 3                40/48
/proc

           /proc/PID/status obsahuje aktu叩lny stav
            procesu, stav pou転itej pam辰te...
           /proc/PID/task adres叩r obsahuj炭ci hardlinky
            na ak辿ko直vek 炭lohy ktor辿 tento proces spustil
           /proc/PID/maps mapa pam辰te ukazuj炭ca
            ktor辿 adresy s炭 vidite直n辿
   
       /proc/cpuinfo
   
       /proc/meminfo
   
       ........

29.3.2008                     LinuxFEST 3              41/48
loop

   
       s炭bor ako blokov辿 zariadenie
   
       napr鱈klad pripojenie image




29.3.2008                LinuxFEST 3   42/48
loop
  
      Vytvor鱈me 10 MB s炭bor
$ dd if=/dev/zero of=file.img bs=1k count=10000
  


  
      Sprav鱈me asoci叩ciu file.img a /dev/loop0
$ losetup /dev/loop0 file.img
  


  
      Vytvor鱈me filesystem
$ mke2fs -c /dev/loop0 10000
 
mke2fs 1.35 (28-Feb-2004)
max_blocks 1024000, rsv_groups = 1250, rsv_gdb = 39
Filesystem label=
 
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
2512 inodes, 10000 blocks
500 blocks (5.00%) reserved for the super user
...
29.3.2008                       LinuxFEST 3           43/48
loop

   
       Pripoj鱈me FS
  $ mkdir /mnt/point1
  $ mount -t ext2 /dev/loop0 /mnt/point1
  $ ls /mnt/point1
   
  lost+found




29.3.2008                  LinuxFEST 3     44/48
僓鉛邸庄艶

   
       sie泥ov辿
           sshfs
           nfs_fs
           smb_fs
           9p_fs
   
       in辿 virtu叩lne
           gnome-vfs
           gvfs
           kio-vfs
29.3.2008               LinuxFEST 3   45/48
Zdroje a odkazy

http://linuxbasics.org/course/book/index
http://linuxfest.sk
http://www.debian.org
http://www.ubuntu.com
http://en.wikipedia.org/wiki/Filesystem
http://en.wikipedia.org/wiki//dev/random
http://www.ibm.com/developerworks/linux/library/l-linux-filesystem/
http://www.cyberciti.biz/tips/understanding-unixlinux-filesystem-superblock.html
http://geekblog.oneandoneis2.org/index.php/2006/08/17/why_doesn_t_linux_need_d
http://tldp.org/HOWTO/SquashFS-HOWTO/
http://en.wikipedia.org/wiki/Procfs
http://en.wikipedia.org/wiki/Sysfs
http://www.abclinuxu.cz/clanky/system/sysfs-brana-do-jadra
http://www.abclinuxu.cz/clanky/jaderne-noviny/jaderne-noviny-23.-1.-2008
http://www.abclinuxu.cz/clanky/system/suborove-systemy-i
http://www.linux.com/articles/22150
http://www.ibm.com/developerworks/linux/library/l-linux-filesystem/


29.3.2008                           LinuxFEST 3                         46/48
永看僓一看厩温稼庄艶




            akujem V叩m za pozornos泥




29.3.2008             LinuxFEST 3      47/48
Kontakt




            Na pr鱈padn辿 ot叩zky r叩d odpoviem

            email: michal6103 at gmail dot com




29.3.2008                  LinuxFEST 3           48/48
LinuxFest podporuj炭




29.3.2008   LinuxFEST 3   49/48

More Related Content

Linux: Filesystems

  • 1. LinuxFEST 3/2008 GNU/Linux S炭borov辿 syst辿my Predn叩邸aj炭ci: Michal Sedl叩k Email: michal6103 at gmail dot com
  • 2. 厩看糸 Vizu叩lna t辿ma prezent叩cie je odvoden叩 od od t辿my vytvorenej: Sakari Koivunen and Henrik Omma Released under the LGPL license. 29.3.2008 LinuxFEST 3 2/48
  • 3. Obsah S炭bory typy s炭borov, atrib炭ty, pr叩va, pr鱈kazy o je to s炭borov箪 syst辿m S炭borov辿 syst辿my ext2, ext3, ext4, ReiserFS, UnionFS.... preo 僓鉛邸庄艶 FS rozdiely 29.3.2008 LinuxFEST 3 3/48
  • 4. 厩看糸 Na UNIX-ovom syst辿me je v邸etko s炭bor, a ak nieo nie je s炭bor, tak je to proces V Plan9, Inferno OS je 炭plne v邸etko s炭bor 29.3.2008 LinuxFEST 3 4/48
  • 5. Typy s炭borov michal@backup:~/linuxfest$ ls -l total 172 drwxr-xr-x 2 michal michal 4096 2008-03-28 13:19 adresar -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 hl-osnova.odt -rw-r--r-- 1 michal michal 100462 2008-03-19 19:59 Linuxfest.tar.gz -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 osnova.odt lrwxrwxrwx 1 michal michal 10 2008-03-28 13:19 sl-osnova.odt -> osnova.odt d Directory r read list directory l Link w write c Character special file x execute recurse directory s Socket p named Pipe (FIFO) b Block device 29.3.2008 LinuxFEST 3 5/48
  • 6. s,S,t,T t,T - sticky bit s炭bor - Linux ignoruje sticky bit na s炭boroch adres叩r - s炭bory m担転e maza泥 a premenov叩va泥 len vlastn鱈k s炭borov s,S - Set User ID, Set Group ID SUID,SGID s炭bor s炭bor sa spust鱈 s pr叩vami vlastn鱈ka, alebo skupiny s炭boru SGID adres叩r s炭bory vytvoren辿 vo vn炭tri adres叩ra budu mat nastaven炭 skupinu ako tento adres叩r (zdie直anie s炭borov) 29.3.2008 LinuxFEST 3 6/48
  • 7. d - Adres叩r, prieinok, zlo転ka /bin programy zdielan辿 u転鱈vate直mi a rootom /boot Inicializan辿 s炭bory, kernel, popripade grub a jeho nastavenia (vmlinuz, initrd.gz). /dev referencie na hardv辿r, reprezentovan箪 s炭bormy /etc konfiguran辿 s炭bory - Editable Text Configuration Dennis Ritchie tvrd鱈, 転e to je skratka "et cetera" /home u転鱈vate直sk辿 adres叩re /initrd bootovacie skripty (iba v niektorych distr叩ch) /lib kni転nice potrebn辿 na beh programov /lost+found s炭bory obnoven辿 diagnostick箪mi n叩strojmy /misc r担zny 炭el /media pripojen辿 perif辿rie, cd-rom, usb k直炭, mp3 player 29.3.2008 LinuxFEST 3 7/48
  • 8. d - Adres叩r, prieinok, zlo転ka /opt tre泥ostrann箪 softv辿r /proc virtu叩lny filesystem s inform叩ciami o syst辿mov箪ch zdrojoch /root dom叩ci adres叩r u転鱈vate直a root /sbin syst辿mov辿 programy /tmp doasn辿 s炭bory, ma転e sa pri reboote /usr u転鱈vate直sk辿 programy, kni転nice, dokument叩cia /var premenliv辿 s炭bory, logy, datab叩zy, print spooler, mail queue 29.3.2008 LinuxFEST 3 8/48
  • 9. c - peci叩lne znakov辿 s炭bory v辰ina je v /dev /dev/null prijme a zru邸鱈 akeko直vek d叩ta /dev/full v転dy pln辿 zariadenie /dev/loop loopback disk device /dev/zero generuje pr炭d n炭l (NUL) /dev/random generuje pseudon叩hodn辿 鱈sla (blok) /dev/urandom generuje pseudon叩hodn辿 鱈sla 29.3.2008 LinuxFEST 3 9/48
  • 10. l symbolick叩 linka Soft link obsahuje meno a cestu in辿ho s炭boru ln -s meno1 meno2 Hard link hard link je pointer na inode vo filesyst辿me nie je mo転n辿 spravi泥 hardlink na in箪 filesystem ln meno1 meno2 29.3.2008 LinuxFEST 3 10/48
  • 11. hard vs. soft michal@backup:~/linuxfest$ ls -l total 172 drwxr-xr-x 2 michal michal 4096 2008-03-28 13:19 adresar -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 hardlink-osnova.odt -rw-r--r-- 1 michal michal 100462 2008-03-19 19:59 Linuxfest.tar.gz -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 osnova.odt lrwxrwxrwx 1 michal michal 10 2008-03-28 13:19 softlink-osnova.odt -> osnova.odt michal@backup:~/linuxfest$ ls -lL total 204 drwxr-xr-x 2 michal michal 4096 2008-03-28 13:19 adresar -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 hardlink-osnova.odt -rw-r--r-- 1 michal michal 100462 2008-03-19 19:59 Linuxfest.tar.gz -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 osnova.odt -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 softlink-osnova.odt 29.3.2008 LinuxFEST 3 11/48
  • 12. hard vs. soft michal@backup:~/linuxfest$ ls -l total 172 drwxr-xr-x 2 michal michal 4096 2008-03-28 13:19 adresar -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 hl2-osnova.odt -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 hl-osnova.odt -rw-r--r-- 1 michal michal 100462 2008-03-19 19:59 Linuxfest.tar.gz lrwxrwxrwx 1 michal michal 10 2008-03-28 13:19 sl-osnova.odt -> osnova.odt michal@backup:~/linuxfest$ ls -lL total 172 drwxr-xr-x 2 michal michal 4096 2008-03-28 13:19 adresar -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 hl2-osnova.odt -rw-r--r-- 2 michal michal 32226 2008-03-19 19:59 hl-osnova.odt -rw-r--r-- 1 michal michal 100462 2008-03-19 19:59 Linuxfest.tar.gz ?--------- ? ? ? ? ? sl-osnova.odt 29.3.2008 LinuxFEST 3 12/48
  • 13. s domain socket p - pipe sl炭転ia na medzi-procesov炭 komunik叩ciu(IPC) ponad pr鱈stupov辿 pr叩va s炭borov辿ho syst辿mu #Socket python> import socket python> my_scoket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) python> my_socket.bind('/tmp/socket_name') #pipe python> import os python> receive,transmit = os.pipe() 29.3.2008 LinuxFEST 3 13/48
  • 14. S炭borov箪 syst辿m popisuje ak箪m sp担sobom s炭 ulo転en辿 d叩ta, HDD, FDD, CD-ROM, sie泥 (SMB, NFS), procfs... nieko直ko vrstiev abstrakcie umo転uj炭cich pr鱈stup k 炭dajom virtu叩lny filesystem m担転e reprezentova泥 ak辿ko直vek d叩ta (WikipediaFS, procfs) 29.3.2008 LinuxFEST 3 14/48
  • 15. Metad叩ta okrem mena s炭boru a jeho obsahu sa ukladaj炭 aj in辿 d叩ta as vytvorenia as posledn辿ho pr鱈stupu vlastn鱈k (user, group) pr鱈stupov辿 pr叩va ve直kos泥 roz邸鱈ren辿 atrib炭ty (autor dokumentu, k坦dovanie) 29.3.2008 LinuxFEST 3 15/48
  • 16. Sch辿ma 29.3.2008 LinuxFEST 3 16/48
  • 17. i-node z叩kladn叩 jednotka UNIX FS ukazuje na 僓鉛邸庄艶 i-nody, alebo bloky d叩t 29.3.2008 LinuxFEST 3 17/48
  • 18. superblok 邸trukt炭ra obsahuj炭ca z叩kladn辿 inform叩cie o disku geometria vo直n辿 miesto umiestnenie prv辿ho i-nodu nevyhnutn箪 pri boote k坦pie superbloku v ka転dej skupine blokov 29.3.2008 LinuxFEST 3 18/48
  • 19. superblok backup:/home/michal/linuxfest# dumpe2fs /dev/hda1 | grep -i superblock dumpe2fs 1.40-WIP (14-Nov-2006) Primary superblock at 1, Group descriptors at 2-2 Backup superblock at 8193, Group descriptors at 8194-8194 Backup superblock at 24577, Group descriptors at 24578-24578 Backup superblock at 40961, Group descriptors at 40962-40962 Backup superblock at 57345, Group descriptors at 57346-57346 Backup superblock at 73729, Group descriptors at 73730-73730 Backup superblock at 204801, Group descriptors at 204802-204802 Backup superblock at 221185, Group descriptors at 221186-221186 29.3.2008 LinuxFEST 3 19/48
  • 20. 貼顎姻稼叩鉛 synchroniz叩cia - race condition zmazanie s炭boru uvo直nenie miesta na disku odstr叩nenie s炭boru zo z叩znamov v prieinku do 転urn叩lu sa zapisuj炭 bud炭ce oper叩cie iba atomick辿 zmeny = ve直a 炭dajov Reiser4 zhlukuje atomick辿 zmeny do spojit辿ho bloku a t箪m optimalizuje 転urn叩l v pr鱈pade p叩du je obnova r箪chlej邸ia ako fsck 29.3.2008 LinuxFEST 3 20/48
  • 21. 貼顎姻稼叩鉛 nie niektor辿 FS s炭 st叩le konzistentn辿, resp. jedinou nekonzistenciou m担転e by泥 straten辿 miesto (Unix File System) soft updates obmedz鱈 sa mno転ina asynchr坦nnych oper叩ci鱈 zber smet鱈 je v辰邸inou na pozad鱈 (garbage collection) 29.3.2008 LinuxFEST 3 21/48
  • 22. S炭borov辿 syst辿my 29.3.2008 LinuxFEST 3 22/48
  • 23. ext2 1993 - second extended file system nato直ko r箪chly, 転e sa pou転鱈va na benchmarky /boot, /tmp 5% pre roota tune2fs -m 1 /dev/sdXY clean, not clean parameter zapnutie 転urn叩lu tune2fs -j /dev/hdXX 29.3.2008 LinuxFEST 3 23/48
  • 24. ext3 2001 - Third extended file system ext2 roz邸鱈ren箪 o 転urn叩l 3 re転imy Writeback 転urn叩luje iba metad叩ta, ur箪chly kontrolu konzistentnosti Ordered akanie na z叩pis d叩t a potom zmena metad叩t (metad叩ta zodpovedaj炭 d叩tam) Journal pln箪 転urn叩l, v邸etko rob鱈me 2x nem叩 undelete nuluje pointery na bloky v i-node zmazan箪ch LinuxFEST 3 29.3.2008 s炭borov 24/48
  • 25. ext3 bez 転urn叩lu r箪chlej邸鱈 ako ext2 邸tandardn箪 FS v mnoh箪ch distr叩ch 転iaden n叩stroj na defragment叩ciu 転iadne kryptovanie 転iadna kompresia 転iadne chekcksumy v 転urn叩le podpora ACL a extended attributes 29.3.2008 LinuxFEST 3 25/48
  • 26. ext4 nestabiln箪, 2.6.19 ve直k辿 disky 1024 pebibytes sp辰tne aj dopredne kompatibiln箪 s ext3 mo転nos泥 predbe転nej alok叩cie s炭visl箪ch blokov viac ako 32000 adres叩rov journal checksum online defragment叩cia rozl鱈邸enie timestempu 1ns 29.3.2008 LinuxFEST 3 26/48
  • 27. ext2,3,4 Max file size 2 TiB Max filename size 255 characters Max volume size 16 TiB Allowed characters in filenames Any byte except NUL and '/' Max file size 16GiB 2TiB Max filename size 255 bytes Max volume size 2TiB 32TiB Allowed characters in filenames All bytes except NUL and '/' Max file size 16 TiB Max filename size Max volume size 1024 PiB = 1 EiB Allowed characters in filenames All bytes except NUL and '/' 29.3.2008 LinuxFEST 3 27/48
  • 28. Ako je to s fragment叩ciou Ext2, Ext3, Ext4 Ext2-4 sa fragmentuje hlavne ke je na disku m叩lo miesta priemern叩 fragment叩cia je minim叩lna prejavuje sa na vy泥a転en箪ch serveroch m辿diacentr叩ch s obrovsk箪mi d叩tov箪mi tokmi Ako to funguje? 29.3.2008 LinuxFEST 3 28/48
  • 29. ReiserFS 2001 - prv箪 s podporou 転urn叩lu v kernely vysok箪 v箪kon efekt鱈vne ukladanie mal箪ch s炭borov ukladanie koncov do jedn辿ho bloku viac s炭borov v jednom bloku ve直k辿 mno転stvo s炭borov v adres叩ry vhodn箪 na http cache, mail cache, db Max file size 8 TiB Max number of files 232 (~4 billion) Max volume size 16 TiB Allowed characters in filenames All bytes except NUL and '/' 29.3.2008 LinuxFEST 3 29/48
  • 30. JFFS2 - Journalling Flash File System verzia 2 navrhnut箪 pre flash pam辰te vyu転鱈vanie cel辿ho adresn辿ho priestoru neprepisovanie t箪ch ist箪ch miest routery, CF karty, USB k直炭e podporuje hard linky kompresia zlib, rubin, rtime podpora NAND flash (sekvenn辿 鱈tanie) garbage collector na pozad鱈 29.3.2008 LinuxFEST 3 30/48
  • 31. JFFS2 - Journalling Flash File System verzia 2 ned叩 sa poveda泥 ko直ko miesta je free pri pripojen鱈 je nutn辿 skontrolova泥 v邸etky inode-i (relat鱈vne pomal辿 pripojenie) n叩stupca je LogFS uren箪 pre ve直k辿 flashov辿 pam辰te 29.3.2008 LinuxFEST 3 31/48
  • 32. SQUASHFS pre flash disky read only (firmv辿ry, kiosky, LiveCD...) r箪chla kompresia LZMA, GZIP RW v kombin叩ci鱈 s UnionFS Slax, BackTrack OpenWRT mksquashfs, unsquashfs 29.3.2008 LinuxFEST 3 32/48
  • 33. UnionFS umo転uje vytvori泥 RW filesystem ponad RO z叩klad, stack-ovac鱈 FS CD + HDD = jeden filesyst辿m zapisovate直n叩 vetva ma v辰邸iu prioritu mazanie z RO m辿dia cez .wh. s炭bory, alebo vlastn箪 oddiel na RW part鱈ci鱈 >mount -t unionfs -o dirs=/media/cdrom,/tmp none /home/cdrw 29.3.2008 LinuxFEST 3 33/48
  • 34. XFS najstar邸鱈 転urn叩lovac鱈 FS pre high-end servery podpora pre multiprocesorov辿 po鱈tae 転urn叩l navrnut箪 tak aby mal minim叩lny dopad na v箪kon 29.3.2008 LinuxFEST 3 34/48
  • 35. Btrfs v0.1 iba vo v箪voji, in邸pirovan箪 ZFS efekt鱈vna pr叩ca s mal箪mi aj velk箪mi s炭bormi (rozsahy 転iadne zoznamy inodov) snapshotting (aj sn鱈mky s炭 転iv辿 a m担転u by泥 upraven辿), ve直mi r箪chle copy-on-write kontroln辿 s炭ty v邸etk辿ho nie je potrebn箪 転urn叩l r箪chla kontrola (online kontrola v pl叩ne) 29.3.2008 LinuxFEST 3 35/48
  • 36. Btrfs v0.1 online zmeny ve直kosti sub-oddiely viac oddielov v jedno filesyst辿me (konverzia Ext3 -> Btrfs) nesk担r: storage polls viac zariaden鱈 mirroring a stripping inkrement叩lne z叩lohy Max file size 16 EiB Max number of files 264 Max filename size 255 bytes Max volume size 16 EiB Allowed characters in filenames All bytes except NUL and '/' 29.3.2008 LinuxFEST 3 36/48
  • 37. tmpfs Pseudo filesyst辿m, ktor箪 uchov叩va v邸etky s炭bory v RAM $mount none /mnt/xyz -t tmpfs -o size=100m 29.3.2008 LinuxFEST 3 37/48
  • 38. /sys pseudo filesyst辿m umo転uj炭ci pr鱈stup ku vn炭torn箪m premenn箪m kernelu napr鱈klad zoznam modulov ls /sys/module umo転nil vznik udev 29.3.2008 LinuxFEST 3 38/48
  • 39. /dev pseudo filesyst辿m s dynamick箪m zoznamom zariaden鱈 ka転d辿 zariadenie m叩 s炭bor v /dev minor, major 鱈slo (2.7 dynamick辿) udev mimo kernel, v userspace dynamick辿 vytv叩ranie polo転iek 29.3.2008 LinuxFEST 3 39/48
  • 40. /proc pseudo filesystem zobrazuje inform叩cie o procesoch /proc/pid /proc/PID/cmdline pr鱈kaz ktor箪 proces spustil /proc/PID/cwd symlink na pracovny adres叩r /proc/PID/exe symlink na spustite直n箪 s炭bor /proc/PID/root cesta ku koreov辿mu adres叩ru 29.3.2008 LinuxFEST 3 40/48
  • 41. /proc /proc/PID/status obsahuje aktu叩lny stav procesu, stav pou転itej pam辰te... /proc/PID/task adres叩r obsahuj炭ci hardlinky na ak辿ko直vek 炭lohy ktor辿 tento proces spustil /proc/PID/maps mapa pam辰te ukazuj炭ca ktor辿 adresy s炭 vidite直n辿 /proc/cpuinfo /proc/meminfo ........ 29.3.2008 LinuxFEST 3 41/48
  • 42. loop s炭bor ako blokov辿 zariadenie napr鱈klad pripojenie image 29.3.2008 LinuxFEST 3 42/48
  • 43. loop Vytvor鱈me 10 MB s炭bor $ dd if=/dev/zero of=file.img bs=1k count=10000 Sprav鱈me asoci叩ciu file.img a /dev/loop0 $ losetup /dev/loop0 file.img Vytvor鱈me filesystem $ mke2fs -c /dev/loop0 10000 mke2fs 1.35 (28-Feb-2004) max_blocks 1024000, rsv_groups = 1250, rsv_gdb = 39 Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 2512 inodes, 10000 blocks 500 blocks (5.00%) reserved for the super user ... 29.3.2008 LinuxFEST 3 43/48
  • 44. loop Pripoj鱈me FS $ mkdir /mnt/point1 $ mount -t ext2 /dev/loop0 /mnt/point1 $ ls /mnt/point1 lost+found 29.3.2008 LinuxFEST 3 44/48
  • 45. 僓鉛邸庄艶 sie泥ov辿 sshfs nfs_fs smb_fs 9p_fs in辿 virtu叩lne gnome-vfs gvfs kio-vfs 29.3.2008 LinuxFEST 3 45/48
  • 46. Zdroje a odkazy http://linuxbasics.org/course/book/index http://linuxfest.sk http://www.debian.org http://www.ubuntu.com http://en.wikipedia.org/wiki/Filesystem http://en.wikipedia.org/wiki//dev/random http://www.ibm.com/developerworks/linux/library/l-linux-filesystem/ http://www.cyberciti.biz/tips/understanding-unixlinux-filesystem-superblock.html http://geekblog.oneandoneis2.org/index.php/2006/08/17/why_doesn_t_linux_need_d http://tldp.org/HOWTO/SquashFS-HOWTO/ http://en.wikipedia.org/wiki/Procfs http://en.wikipedia.org/wiki/Sysfs http://www.abclinuxu.cz/clanky/system/sysfs-brana-do-jadra http://www.abclinuxu.cz/clanky/jaderne-noviny/jaderne-noviny-23.-1.-2008 http://www.abclinuxu.cz/clanky/system/suborove-systemy-i http://www.linux.com/articles/22150 http://www.ibm.com/developerworks/linux/library/l-linux-filesystem/ 29.3.2008 LinuxFEST 3 46/48
  • 47. 永看僓一看厩温稼庄艶 akujem V叩m za pozornos泥 29.3.2008 LinuxFEST 3 47/48
  • 48. Kontakt Na pr鱈padn辿 ot叩zky r叩d odpoviem email: michal6103 at gmail dot com 29.3.2008 LinuxFEST 3 48/48
  • 49. LinuxFest podporuj炭 29.3.2008 LinuxFEST 3 49/48