-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnote3
473 lines (346 loc) · 12 KB
/
note3
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
Chapter 3 Configuring Hardware
-All OS run on hardware
.
.
.
Configuring Firmware
-Well known firmware ,BIOS(Basic IN/OUT System)
-new frimware EFI/UEFI(Unified extensible Firmware interface)
-Firmware reside in EEPROM(electronically Erasable programable Read Only Memory)
firmware work flow
-->Turn on--> POST -->load bootloader --> past control to boot loader.
IRQ(Interrupt Request) = Signal send to the CPU instructing it to suspend its current activity and to handle some external event.
-in x86_64 IRQ is from 0 to 15
-modern PC provide more!
-Some IRQ already reserverd for specific purpose
0 - System Timer
1 - Keyboard
2 - Cascade for IRQs 8-15
3 - Second RS-232 serial port
4 - First RS-232 serial port
5 - Sound card or second parallel port
6 - Floppy disk controller
7 - First parallel port
8 - Real time clock
9 - ACPI system control interrupt (used by intel chipset for Power Management)
10 - Open intterupt
11 - Open intterupt
12 - PS/2 mouse
13 - Math coprocessor (Reserved for internal use)
14 - Primary ATA controller (/dev/hda /dev/hdb)
15 - Secondary ATA controller(/dev/hdc /dev/hdd)
* new system for Serial ATA (/dev/sda /dev/sdb)
cat /proc/interrupts = to see list of interrupts
I/O Addresses(I/O ports) = unique locations in memory that are reserved for communications between CPU and specific physical hardware(like IRQ ,cannot be shared)
cat /proc/ioports
DMA(direct memory addressing) -Hardware directly access memory without CPU
cat /proc/dma
Coldplug and hotplug
coldplug = system need to be off for plug in
hotplug = system can be on for plug in
Some tools to help user to access information and edit hardware.
1.Sysfs = mounted at /sys ,exports information about devices so that user-space can access
2. HAL-Daemon = Hardware Abstaraction Layer (hald) ,run as daemon, provides other user-space programs with information about available hardware.
3. D-Bus = Desktop Bus , run in daemon, enable proccess to commucincate with hardware, such as USB
4. /udev = mounted at /deb which creates dynamic device files as drivers are loaded and unloaded. can configure udev in /etc/udev
Configuring Expansion Cards
lspci = displays all of the information about the PCI busses in system.
-v = increase verbosity
-n = display information in numeric codes rather than translating the codes to manufacturer and device names.
-nn Displays both the manufacturer and device names and their associated numeric codes.
-s = show specific pci
Kernel Modules
-handle hardware in linux
-stored in /etc/modules
-some modules already compiled into kernel
lsmod = show modules that currently loaded into the system
Loading Kernel modules
insmod / modprobe
insmod = insert module into the kernel
need to load dependencies
modprobe = automatically loads any depended-on modules
insmod
exp
insmod /lib/modules/3.16.6/kernel/drivers/bluetooth/bluetooth.ko
-require full name module
-sometimes need module options, need to refer to the documentation
modprobe
exp
modprobe bluetooth
-v = verbose
-C = use configuration file in /etc/modprobe.conf
-n/--dry-run = causes modprobe to perform checls and all other opertaions except module insertion.
-r = remove module
-f = froce the module loading even if the kernel version doesn't match what the module expect.
--show-dependencies = show dependecies for the module
-l = list option available form the wildcards
Removing Kernel Module
rmmod = removing module
rmmod bluetooth
-v = verbose
-f = force removal
-w = wait for the module in unused condititon before removing it
Configuring USB devices
-There are several USB controllert available
-UHCI,OHCI,EHCI,R8A66597
-UHCI and OHCI = USB 1.0
two tools for managing USB devices:usbmgr and hotplug
usbmgr = detect usb and load module to the kernel
-but hotplug is famous
hotplug = relies on kernel support , uses files stored in/etc/hotplugto control specific USB,
COnfiguring Hard Disk
-Three Common hardisk interface
Parallel Advanced Technology Attachment(PATA),ATA
Serial Advanced Technology Attachment(SATA)
Small Computer System Interface (SCSI)
++USB,IEE1394
PATA
-parallel interface,several bits is stransferred over the cable at once.
-cable are wide
-supporting to 40 to 80 lines
-can connect up to two devices to each PATA connector,
-must be configured as MASTER and SLAVE(done via jumper)
-modern PATA support cable select
-/dev/hda /dev/hdb
-hda for master and hdb for slave
-partition hda1,hda2
-modern distibution treat PATA disks as SCSI
SATA
-FASTER than PATA
-cable much thinner
Configuring SCSI
-better than PATA
-few people use SCSI
-SCSI support 8-16
-sometimes SCSI adapter have their own firmware
-numbering is depend on SCSI ID
-lowest to highest
Design Hard Disk Layout
-create partition and format!
-Why partiton
--Multiple OS support
--Filesystem choice
--Disk Space management
--Disk Error protection
--Security
--Backup
Partitioning Systems
-Usually MBR
---data stored in the first sector of the disks
---size is very limited (2tebibytes)=2^40 bytes=512Byte
-the successor is GUID Partition Table
MBR partition
x64 system only allowed 4 partition
-but hard disk become bigger and make this new partition scheme
-PRimary
-same as the original partition
-Extended
-special type of primary partition that serve as placeholder for the next type
-Logical
-reside within an extended partition
primary partition = 1-->4
logical partition = 5-->up
gap cannot exist in logical partition
MBR HOLD partition table and boot loader
-very sensitive and important
-have type code
--0x0c = FAT,0x05= old type extended partition 0x07 = NTFS ,0x82 = Linux swap, 0x83 = filesystem
GPT
part of intel EFI spec
-can be use in PC that doesnt use EFI
-preferred in partitioning system on disks bigger than 2Tib
-employs protective MBR
-make utilities unaware of GPT
-additional data structures define GPT
-this data sturctures lies in start of disk and end of disk
--CAN create up to 128 partitions(may be raise if necessary)
--gap can occur in partition number
-drawbacks is support for it is immature
Alternative to PARTITION
-LVM(logical volume management)
-use pvreate,vgcreate,lvcreate,lvscan to manage physical volumes(partition)
-combine partition into one big volume group
-assign them into /dev/mapper
-filsesystem size can be change!!
Mount Points
-After partition is created, it must be mount before use
Creating Partitions and Filesystems
MBR partitioning tools!
fdisk = fixed disk,to create partition for MBR
exp fdisk /dev/hda
p = display current partition = fdisk -l /dev/hda
n = create new partition
w = write table to disk and exit
q = quit without saving
After partition is created , it needs to be formatted!
-involve in low level data structures in disk
Linux Supported FileSystem
1. Ext2fs(Second Extended File System)
- tradiotanl Linux-native fs
-created for linux. and dominant
-good choice for small /boot partition.
-non journal fs
-ext2
2. Ext3fs
-basically ext2fs with journaling
-recover from crash quickly
3. Ext4fs
-abily to work with very large disks
4. ReiserFS
- designed from scratch as journaling FS for Linux
-good at hadling large numbers of small files
-because sue tricks to squeeze the ends of files into each other's unused spaces
-reiserfs
5. Jfs
- IBM developed JFS
-techincally sophisticated journaling system
-good if familiar wih AIX or OS/2
-jfs
6. XFS
SGI created XFS for IRIX OS
-gain reputation for robustness,speed and flexibility on IRIX
7. Btrfs
-fast performer and can handle large disk and files
-maybe a successor for current fs
Different FS for Linux
1. FAT(File Allocation Table)
-old and primitive
-the only fs supported by DOS during early day of Windows,
-all majos OS support FAT
-vary in the size of FAT(12-, 16-, 32-bit pointers)
-support long filenames
-msdos
2. NTFS(New Technology FS)
- preferred fs for Windows NT and beyond.
-linux can reand and overwrite existing files, but cannot write new files
3. HFS and HFS +
-Hierarchical FS
-for MAc OS
-Linux provides full read/write HFS
4. ISO9660
-standard fs for CD-ROM
-come with several level
-Level 1 - similar to the original FAT
-Level 2 and 3 - add support for longer 32-character filenames
-Linux also support Rock Ridge extension for longer filenames,permissions,symbolic links, and so on.
-same with Juliet for Windows
-Windows support for both of them
5. UDF (Universal Disc Format)
-next generation fs
-use in DVD-ROM
PS = to create ISO-9660 and other optical disc fs
- mkisofs = creates ISO-9660
-cdrecord = to writes this image to a blank CD-R
-growisofs = combine both but only works onn recordable DVD media
Creating FS
mkfs.fstype = create fs for the partition
fstype = fs type code
or mkfs -t <fs type code>
*for ext2 n ext3 mke2fs is used instead
-c = bad block Check(sign that the disk doesn't have long to live)
-m = percent, sets the reserved-space percentage
other mkfs
mkdosfs = create FAT fs
mkfs,msdks
mkfs.vfat
-F = set fat-size
Creating Swap Space
-Linux use swap partition
-extension of memory
-MBR code 0x82
-need to defined in /etc/fstab
mkswap = to create swap fs
exp
mkswap /dev/sda7
swapon /dev/sda7 = use the swap space
to activate it permanenly need to change /etc/fstab
Maintaining FS
-basically tools use to maintain FS need to be used when the fs is unmounted
3 basic tools
1.dumpe2fs
2.tune2fs
3.debugfs
dumpe2fs = show information about ext2 and ext3
-h = utility will omit information about group descriptors
-can be run while the fs is mounted
xfs provide same utilites = xfs_info
Tune FS
tune2fs = change fs parameters that are reported by dumpe2fs
-c = maximum number of time the disk may be mounted without a check
-C = set mount counter
-i = set interval for check
-j = add journal to the fs, convert ext2 to ext3
-m = set reserved block
xfs_admin = for xfs
-PLEASE USE IN UNMOUNTED FS
-l/-u = to obtain fs UUID
blkid = can display the label and UUID of any partitions
-L/-U = change the label(12 char only) and UUID (use generate to create UUID/dont set UUID that been used by other partitions)
Interactive Debugging FS
debugfs = use interactive options to debug fs
-show_super_stats/stats = same as dumpe2fs
-stat filename = display inode of the file
-undelete inode name = undelte file
- need to know the file inode using lsdel/list_deleted_inodes
-write internal-fiels external-file = extract file from badly damged file
-cd ,mv,cp etc
-list_requests ,lr,help ? = show help
-quit
Checking FileSystem
fsck = checkin FS
-A = check all files in /etc/fstab
-V = verbose
-N = will display what its normally do without doing it
-t = set fs type
-- = for inside options
-f = force
=i = interactive
-a/-p = perform automatic check
!!ONLY RUN FSCK IN UNMOUNTED FS or READ ONLY FS
Monitorin DISK use by Partition
df = summary fo disk space used
-a = all fs
-h = human readable
-i /--inodes = show inodes
-l = local only
-T = show filesystem type
-t =limit the filesystem type to show
exp
df /home = can be used to see disk usage of /home
MOnitoring DISK use by Directory
du = show disk usage by Directory/similar to du
-a = show disk usage for individual files as well
-c = compute grand total
-h = human readable
-l = count hard links
--max-depth = limit the report to n levels
-s = summarize
-x = limit filesystem
MOunting and Unmounting
mount= mounting file system
-a = mount all fs in /etc/fstab
-r = mount it to read only
-v = show ver bose
-w = mount it to read write
-t = mount with file type
-L/-U = mount by label or UUID
-o = add filesystem specific options
--file that mounted is saved in /etc/mtab, this file in /etc but cannot be configure
mount options
loop = loopback fS
auto or noauto = mount or doest mount the fs at boot
user or nouser = allows or disallows ordinary users to mount the fs,Used in /etc/fstab
users = any user may unmount the fs
owner - similar to user but user must own the device
remount = change one or more mount options without explicitly unmounting a partition
ro = specifies a read-only mount of fs
rw = specifies a read write
.
.
.
umount = unmount fs
basicallyy same options with mount
Permanently Mount FS
EDIT /etc/fstab
DEVICE MOUNTPOINT FILESYSTEM OPTIONS DUMP FSCK
-DEVICE usually use label /UUID