Linux file systems

advertisement
CS 3100
Operating Systems
Spring 2002
Linux File Systems
I.
Devices
A. device files
i. all devices are treated as files
ii. the /dev directory represents available devices
iii. device names are semi-descriptive
B. block and char (or raw) devices
i. block devices use a buffer system
ii. many devices have both a block and char file entry
C. major and minor numbers
i. the major number represents a device driver, the minor number is a parameter
ii. each device driver may handle a family of devices
II.
Partitions
A. a partition is a physically defined area of disk
B. advantages
i. prevents potential encroachment, limits growth
ii. isolates corruption
iii. may limit fragmentation
iv. facilitates backup and recovery
v. allows separate booting (separate OS systems)
III.
File Systems
A. every partition contains one file system
B. some types
i. s5
an older System V Unix standard with filenames limited to 14 chars
ii. ufs
current System V standard: multiple superblocks, 255-char filenames, var
logical block sizes
iii. ext2
similar to ufs, the Linux standard
iv. iso9660 CDROM standard with DOS 8+3 filenames
v. hsfs
iso9660 with extended filenames
vi. msdos Windows standard
vii. swap
used exclusively for swap space by the OS
viii. high sierra
Common CDROM standard with extended filenames
ix. ntfs
Windows NT standard
x. tar
Unix sequential media standard
xi. fat32
Windows standard
IV.
The ext2 filesystem (logical blocks are 1k bytes)
A. boot block
B. superblock
contains the bootstrap program and the partition information table – disk
partition size, disk parameters, superblock size, etc.
contains the file system type, a list of free inodes (partial), and a list or bitmap
(FAT) of free data blocks (partial)
a sequence of 128-byte entries – one entry for every file in the system
C. inode blocks
i. file type
ii. number of links
iii. UID of the owner
iv. GUID of the owner’s group
v. file mode (permissions)
vi. file size (in bytes)
vii. last modification timestamp
106751985
03/07/16
CS 3100
Operating Systems
Spring 2002
viii. last access timestamp
ix. last inode update timestamp
x. 15 data block pointers
1. 1 - 12 – pointers to the first 12 data blocks
2. 13 – a pointer to a single indirect data block
3. 14 – a pointer to a double indirect data block
4. 15 – a pointer to a triple indirect data block
The first inode is associated with the root directory file. The inode blocks can be organized into a
linked list with N inodes per node .So, only the first N inodes might reside immediately following the
superblock. (N is typically a large number.)
D. data blocks
V.
data blocks for files
Directories
A. a directory is a file containing a list of 2-value entries for each member file
i. the textual filename
ii. the inode number
B. Linux maintains the inode number of the default or working directory
C. Example: % ls -l
VI.
Standard partitions for a Linux hard disk
A. root – default file system ext2
B. swap – file system is swap
C. user created and defined
VII.
Administration of File Systems
A.
B.
C.
D.
E.
F.
G.
H.
fdisk
mkfs
mount
umount
fsck
sync
du
df
create partitions
create a file system on a partition
attach a file system under the Linux root directory to allow access
de-attach a file system from the Linux root directory
check a Linux file system for integrity
synchronize the memory image of a file system with the physical image
display disk space usage information by directory
display file system space usage information
VIII. Example – creating a partition for a /database file system and directory
A. % fdisk
Disk /dev/hda: 255 heads, 63 sectors, 784 cylilnders
Units = cylinders of 16065 * 512 bytes
Device
Boot
Start
End
Blocks
/dev/hda1 *
1
220
175432
/dev/hda2
221
473
209847
/dev/hda4
635
784
132345
/dev/hda5
1
5
40099
/dev/hda6
6
219
176543
ID
5
6
81
82
83
File System
extended
msdos
Linux native
swap
Linux native
command (m for help): m
available commands
a
toggle a bootable flag
d
delete a partition
l
list know partition types
m
print this help menu
n
add a new partition
106751985
03/07/16
CS 3100
Operating Systems
Spring 2002
p
print the partition table
q
quit without saving changes
w
save new partition table to disk and exit
command (m for help): n
option:
l
logical (numbers over 5)
p
primary (numbers 1-4):
p
partition number (1-4): 3
first cylinder (default 474): 474
last cylinder (default 634):
634
command (m for help): p
Device
Boot
Start
End
Blocks
ID File System
/dev/hda1 *
1
220
175432 5
extended
/dev/hda2
221
473
209847 6
msdos
/dev/hda3
474
634
273645 83 Linux native
/dev/hda4
635
784
132345 83 Linux native
/dev/hda5
1
5
40099
82 swap
/dev/hda6
6
219
176543 83 Linux native
command (m for help): w
B. % mkfs –t ext2 /dev/hda3
mke2fs 1.14, 9-Jan-1999 for EXT2 file system
...
superblock backups stored on blocks: 8193, 23412, 67462, 12343
writing inode tables: done
writing superblocks and filesystem information: done
C. % mount –t ext2 /dev/hda3 /database
variations: % mount –a
% mount /dev/floppy
options: (-o)
rw
ro
auto
user
noauto
defaults
mounting information in file /etc/fstab
file system type is in /etc/fstab
read/write
read only
determine the file system type from the superblock
allow a user to mount
do not automatically mount (must be mounted explicitly)
apply system defaults
example /etc/fstab
# mount device
/dev/hda5
/dev/hda6
/dev/fd0
/dev/hda3
106751985
mount point
swap
/
/floppy
/database
file system type
swap
ext2
auto
ext2
options
defaults
defaults
noauto,user
defaults
03/07/16
Download