Skip to content

Commit ac21aff

Browse files
committed
Split dev-filesystem
1 parent ec7aa96 commit ac21aff

28 files changed

+532
-216
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Includes Linux concepts and utilities that work on Linux, not necessarily in the
3030
1. [dmesg](demesg.md)
3131
1. [installkernel](installkernel.md)
3232
1. Initialization
33-
1. [Install OS](install-os.md): how to install a new OS
33+
1. [Install Operating System](install-operating-system.md): how to install a new OS
3434
1. [Boot](boot.md)
3535
1. [GRUB](grub.md)
3636
1. [Init](init.md): System V, Upstart
@@ -53,6 +53,7 @@ Includes Linux concepts and utilities that work on Linux, not necessarily in the
5353
1. [mountall](mountall.md)
5454
1. [pathchk](pathchk.md)
5555
1. [swap partition](swap-partition.md)
56+
1. [tune2fs](tune2fs.md)
5657
1. [UUID](uuid.md)
5758
1. ext filesystems
5859
1. [e2label](e2label.md)
@@ -63,6 +64,8 @@ Includes Linux concepts and utilities that work on Linux, not necessarily in the
6364
1. [proc filesystem](proc-filesystem.md)
6465
1. [dev filesystem](dev-filesystem.md)
6566
1. [mknod](mknod.md)
67+
1. [/dev/loop](/dev/loop.md)
68+
1. [/dev/sr0](/dev/sr0.md)
6669
1. [sysfs](sysfs.md)
6770
1. [ramfs](ramfs.md)
6871
1. [binfmt_misc filesystem](binfmt-misc-filesystem.md)
@@ -89,6 +92,9 @@ Includes Linux concepts and utilities that work on Linux, not necessarily in the
8992
1. File managers
9093
1. [Krusader](krusader.md)
9194
1. [vifm](vifm.md)
95+
1. Partitions
96+
1. [parted](parted.md)
97+
1. [gparted](gparted.md)
9298
1. [CD DVD](cd-dvd.md)
9399
[isoinfo](isoinfo.md)
94100
[eject](eject.md)

cloc.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Count files, line of code, empty lines and comment lines under directory.
44

55
cloc .
66

7+
Does not seem possible to add new languages. For more flexibility see: <http://stackoverflow.com/questions/1358540/how-to-count-all-the-lines-of-code-in-a-directory-recursively> A good one is:
8+
9+
( find ./ -name '*.tex' -print0 | xargs -0 cat ) | wc -l
10+
711
Sample output for GDB:
812

913
4770 text files.

dd.md

+16-10
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ Default values: 512 B.
4646

4747
## count
4848

49-
Copy up to count blocks (defined by bs):
49+
Copy up to count blocks (defined by `bs`):
5050

51-
[ `echo -n 1234 | dd status=none bs=2 count=1` = 12 ] || exit 1
52-
[ `echo -n 1234 | dd status=none bs=1 count=3` = 123 ] || exit 1
51+
[ "$(printf '1234' | dd status=none bs=2 count=1)" = '12' ] || exit 1
52+
[ "$(printf '1234' | dd status=none bs=1 count=3)" = '123' ] || exit 1
5353

5454
## size suffixes
5555

56-
-`c`: 1 (char)
57-
-`w`: 2 (word)
58-
-`kB`: 1000
59-
-`K`: 1024
60-
-`MB`: 1000*1000
61-
-`M`: 1024*1024
56+
- `c`: 1 (char)
57+
- `w`: 2 (word)
58+
- `kB`: 1000
59+
- `K`: 1024
60+
- `MB`: 1000*1000
61+
- `M`: 1024*1024
6262

6363
and so on for G, T, P, E, Z and Y!
6464

@@ -101,6 +101,12 @@ Most useful ones:
101101

102102
TODO
103103

104+
## verbose
105+
106+
## Monitor progress
107+
108+
Not easy: <http://askubuntu.com/questions/215505/how-do-you-monitor-the-progress-of-dd>
109+
104110
## Applications
105111

106112
Copy one hard disk to another:
@@ -132,7 +138,7 @@ We recommend sticking to the GNU version, as it is maintained by an organization
132138

133139
Basic usage:
134140

135-
dd -fv /dev/from /dev/to ddrescue.log
141+
ddrescue -fv /dev/from /dev/to ddrescue.log
136142

137143
- `-f`: write even if destination exists already. Required to copy device files to other device files.
138144
- `-v`: print the transfer status while it is going on.

dev-filesystem.md

+48-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# dev filesystem
22

3-
Contains device driver files.
3+
Contains device driver files, and things related to device drivers like symlinks that give nice names to device drives.
44

5-
To really understand what is going on, learn how to make a minimal device driver yourself. This is not documented here.
5+
To understand what is going on, make a minimal device driver yourself. This is not documented here. Prerequisites you will learn when you do that:
66

7-
Standard device number and paths are documented at: <http://www.lanana.org/docs/device-list/devices-2.6+.txt>, which is part of the LSB.
8-
9-
Some devices are created automatically by the Kernel even if there is no corresponding hardware to offer services under read write, e.g. random number generation.
7+
- what do the type, major and minor numbers mean
8+
- you can device arbitrary effects to standard file system calls like `open` and `close` on device files. They are usually not represented on disk in any way.
109

1110
## devtmpfs
1211

@@ -148,6 +147,18 @@ Discussion: <http://unix.stackexchange.com/questions/60641/linux-difference-betw
148147

149148
Device files of this type represent block devices such as hard disks or flash memory.
150149

150+
Type, major, minor: block, 8, X, one per partition:
151+
152+
brw-rw---- 1 root disk 8, 0 Aug 23 03:45 /dev/sda
153+
brw-rw---- 1 root disk 8, 1 Aug 23 04:43 /dev/sda1
154+
brw-rw---- 1 root disk 8, 2 Aug 23 03:45 /dev/sda2
155+
brw-rw---- 1 root disk 8, 3 Aug 23 03:45 /dev/sda3
156+
brw-rw---- 1 root disk 8, 4 Aug 23 03:45 /dev/sda4
157+
brw-rw---- 1 root disk 8, 5 Aug 23 03:45 /dev/sda5
158+
brw-rw---- 1 root disk 8, 6 Aug 23 03:45 /dev/sda6
159+
brw-rw---- 1 root disk 8, 7 Aug 23 03:45 /dev/sda7
160+
brw-rw---- 1 root disk 8, 8 Aug 23 03:45 /dev/sda8
161+
151162
The first device is `sda`, the second `sdb`, and so on.
152163

153164
Also, partitions inside those devices have device files for them too.
@@ -182,18 +193,42 @@ Now note that when you move the mouse, cat spits something out to the screen!
182193

183194
`mice` is the combination of all mice, and each other `mouseX` is a single mouse device.
184195

185-
## loop
196+
## /dev/shm
186197

187-
## loop0
198+
Files created by `shm_open` calls. This function is part of POSIX, but creation of the files under `/dev` is not.
188199

189-
## loop1
200+
## /dev/disk
190201

191-
TODO
202+
Symlinks to partition identifiers.
192203

193-
Type, major, minor: block, 7, `X` for `loopX`
204+
Allows you to get identifier info.
194205

195-
Used to mount regular files that contain filesystems instead of device files as is usual.
206+
If id no present, link not there.
196207

197-
## /dev/shm
208+
TODO what is the name of the subsystem that implements this? Where is it documented?
198209

199-
Files created by `shm_open` calls. This function is part of POSIX, but creation of the files under `/dev` is not.
210+
Example:
211+
212+
ls -l /dev/disk/
213+
214+
Sample output:
215+
216+
total 0
217+
drwxr-xr-x 2 root root 420 Aug 23 2015 by-id
218+
drwxr-xr-x 2 root root 100 Aug 23 2015 by-label
219+
drwxr-xr-x 2 root root 180 Aug 23 2015 by-uuid
220+
221+
Then:
222+
223+
ls -l /dev/disk/by-id/
224+
225+
Sample output:
226+
227+
total 0
228+
lrwxrwxrwx 1 root root 10 Aug 23 03:45 322246df-fed3-42f7-ba4d-4d72d6cce95f -> ../../sda5
229+
lrwxrwxrwx 1 root root 10 Aug 23 03:45 5CE89967E8994066 -> ../../sda3
230+
lrwxrwxrwx 1 root root 10 Aug 23 03:45 84f8087d-fc74-45b8-a6a2-180856b48982 -> ../../sda6
231+
lrwxrwxrwx 1 root root 10 Aug 23 04:43 A6DA9BF3DA9BBE4D -> ../../sda1
232+
lrwxrwxrwx 1 root root 10 Aug 23 03:45 D0EC9F59EC9F38A4 -> ../../sda2
233+
lrwxrwxrwx 1 root root 10 Aug 23 03:45 e45497f8-6295-41da-ad8c-90dbbac264e8 -> ../../sda8
234+
lrwxrwxrwx 1 root root 10 Aug 23 03:45 ff1b6e50-82ff-4696-823f-774b0f803298 -> ../../sda7

fdisk.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
View and edit partition tables and disk parameters.
44

5+
Mnemonic: Format disk.
6+
7+
util-linux package.
8+
59
REPL interface.
610

711
Does not create filesystems. For that see: `mke2fs` for ext systems.
812

9-
Mnemonic: Format disk.
10-
1113
Better use gparted for simple operations if you have X11
1214

1315
To view/edit partitions with interactive CLI prompt interface.
@@ -37,6 +39,8 @@ Sample output for each disk:
3739
/dev/sda6 940277760 948099071 3910656 82 Linux swap / Solaris
3840
/dev/sda7 907640832 940267519 16313344 83 Linux
3941

42+
TODO: what is the `boot` column?
43+
4044
## REPL
4145

4246
Edit partitions for `sdb` on REPL interface:
@@ -48,9 +52,9 @@ Operation: make a list of changes to be made, then write them all to disk and ex
4852
Most useful commands:
4953

5054
- `-m`: list options
51-
- `-p`: print info on partition, same as using `-l` option.
52-
- `-o`: create new DOS partition table.
53-
- `-n`: create new partition.
54-
- `-d`: delete a partition.
55-
- `-w`: write enqueued changes and exit.
55+
- `-p`: print info on partition, same as using `-l` option
56+
- `-o`: create new DOS partition table
57+
- `-n`: create new partition
58+
- `-d`: delete a partition
59+
- `-w`: write enqueued changes and exit
5660

filesystem.md

+12-74
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ The MBR can only be at the start of a physical partition, not of a logical parti
119119

120120
This is why on bootloader configurations you give `/dev/sda`, instead of `/dev/sda1-4`.
121121

122-
## fuseblk
123-
124-
TODO. NTFS partitions as such.
125-
126122
## Format disks
127123

128124
To format a disk is to prepare it for initial utilization, often destroying all data it contains.
@@ -188,47 +184,12 @@ You should only use on partition devices (ex: `sda1`), not on the entire devices
188184

189185
If you want to edit the partition table, first use a tool like `fdisk`.
190186

191-
## tune2fs
192-
193-
Get and set parameters of ext filesystems that can be tuned after creation.
194-
195-
List all parameters:
196-
197-
sudo tune2fs -l /dev/sda5
198-
199-
## gparted
200-
201-
GUI to `fdisk` + `mke2fs.`
202-
203-
Very powerful and simple to use.
204-
205-
## parted
206-
207-
Get information on all partitions
208-
209-
Very useful output form:
210-
211-
sudo parted -l
212-
213-
Sample output:
214-
215-
Number Start End Size Type File system Flags
216-
1 1049kB 1574MB 1573MB primary ntfs boot
217-
2 1574MB 102GB 100GB primary ntfs
218-
4 102GB 485GB 384GB extended
219-
5 102GB 465GB 363GB logical ext4
220-
7 465GB 481GB 16.7GB logical ext4
221-
6 481GB 485GB 4005MB logical linux-swap(v1)
222-
3 485GB 500GB 14.7GB primary ntfs
223-
224187
## sda
225188

226189
## sdb
227190

228191
## hda
229192

230-
## Device files
231-
232193
Each hard disk and partition corresponds to device file.
233194

234195
There are many types of device files. In particular, hard disks and partitions are block device files.
@@ -264,6 +225,10 @@ If a MBR is not present and a filesystem starts directly at the start of the dev
264225

265226
### IDE
266227

228+
### PATA
229+
230+
### Parallel ATA
231+
267232
### hd vs sd
268233

269234
`hd` is for IDE disks, `sd` for SATA disks.
@@ -274,45 +239,18 @@ SATA stands for Serial Advanced Technology Attachment (or Serial ATA) and IDE is
274239

275240
But by the beginning of 2007, SATA had largely replaced IDE in all new systems.
276241

277-
<http://www.diffen.com/difference/IDE_vs_SATA>
278-
279-
## Raw device
280-
281-
<http://en.wikipedia.org/wiki/Raw_device>
282-
283-
Bypasses the OSs filesystem management like caching, allowing user programs to do it
284-
285-
## sr0
286-
287-
CD DVD.
288-
289-
`/dev/cdrom` is a symlink to it.
242+
Both have the same device number 8.
290243

291-
## mmcblk0
292-
293-
A SanDisk SD card had a device named `mmcblk0`.
294-
295-
## /dev/disk
296-
297-
Symlinks to partition identifiers.
298-
299-
Allows you to get identifier info.
300-
301-
If id no present, link not there.
244+
<http://www.diffen.com/difference/IDE_vs_SATA>
302245

303-
Example:
246+
### SCSI
304247

305-
cd /dev/disk/
306-
ls -l
307-
by-id
308-
by-label
309-
by-path
310-
by-uuid
248+
Both SATA and IDE are SCSI. This is why both `hd` and `sd` have the same major device number.
311249

312-
ls -l by-id
250+
<https://en.wikipedia.org/wiki/SCSI>
313251

314-
## fsck
252+
## Raw device
315253

316-
File System Check.
254+
<http://en.wikipedia.org/wiki/Raw_device>
317255

318-
Check and repair Linux filesystems.
256+
Bypasses the OSs filesystem management like caching, allowing user programs to do it

getconf.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# getconf
2+
3+
Get system configuration variables.
4+
5+
TODO how are those obtained from the Linux kernel? Via `getrlimit`?
6+
7+
Get all:
8+
9+
getconf -a
10+
11+
Get one:
12+
13+
getconf MAX_ARG

gparted.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# gparted
2+
3+
GUI to `fdisk` + `mke2fs.`
4+
5+
Very powerful and simple to use.

gpu.md

+10
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,13 @@ For example, from the `lspci` output, in `GF108M [NVS 5400M]`:
6969
### NVIDIA settings
7070

7171
To check that the installation is working, use `nvidia-settings`, which monitors the GPU, and will show if the GPU is not properly installed.
72+
73+
## dGPU
74+
75+
Discrete GPU, a traditional GPU separate from the CPU, with it's own internal memory.
76+
77+
## IGP
78+
79+
Intermediate between CPU and GPU, uses RAM memory.
80+
81+
<http://en.wikipedia.org/wiki/Graphics_processing_unit#Integrated_graphics_solutions>

grub.md

+8
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ Recognizes Linux and Windows.
159159

160160
TODO how to use it
161161

162+
## Multiboot specification
163+
164+
<https://en.wikipedia.org/wiki/Multiboot_Specification>
165+
166+
Standard created by GRUB for booting OSes.
167+
168+
Followed by Linux and many NIXes, but not Windows or Mac.
169+
162170
## Bibliography
163171

164172
- <http://www.dedoimedo.com/computers/grub-2.html>

0 commit comments

Comments
 (0)