changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > org > notes / 20240302.org

changeset 5: 4ee259bdc42a
parent: 812feca5a874
child: 4839b0675118
author: Richard Westhaver <ellis@rwest.io>
date: Sun, 16 Jun 2024 22:17:14 -0400
permissions: -rw-r--r--
description: demo-notes
1 * NOTE On blocks and devices
2 :LOGBOOK:
3 - State "NOTE" from [2024-03-02 Sat 21:30]
4 :END:
5 [[https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/dev.html][/dev]]
6 In Linux, everything is a file.
7 
8 /dev/ contains special device files - usually block or character
9 device.
10 
11 major, minor = category, device
12 0, 5
13 
14 mknod - create special device files
15 
16 [[https://www.redhat.com/en/blog/linux-block-devices-hints-debugging-and-new-developments][redhat hints]]
17 
18 #+begin_src shell
19  dd if=/dev/zero of=myfile bs=1M count=32
20  losetup --show -f myfile
21  ls -al /dev/loop0
22  losetup -d /dev/loop0 #teardown
23 #+end_src
24 
25 #+begin_src shell
26  echo "sup dude" > /dev/loop0
27  dd if=/dev/loop0 -bs=1
28  dd if=/dev/nvme0 of=/dev/null progress=true
29  #pacman -S hdparm
30  hdparm -T /dev/nvme0
31 #+end_src
32 
33 #+begin_src shell
34 modprobe scsi_debug add_host=5 max_luns=10 num_tgts=2 dev_size_mb=16
35 #+end_src
36 
37 sparsefiles: create with C, dd, or truncate
38 
39 #+begin_src shell :results output
40 truncate --help
41 #+end_src
42 
43 #+RESULTS:
44 #+begin_example
45 Usage: truncate OPTION... FILE...
46 Shrink or extend the size of each FILE to the specified size
47 
48 A FILE argument that does not exist is created.
49 
50 If a FILE is larger than the specified size, the extra data is lost.
51 If a FILE is shorter, it is extended and the sparse extended part (hole)
52 reads as zero bytes.
53 
54 Mandatory arguments to long options are mandatory for short options too.
55  -c, --no-create do not create any files
56  -o, --io-blocks treat SIZE as number of IO blocks instead of bytes
57  -r, --reference=RFILE base size on RFILE
58  -s, --size=SIZE set or adjust the file size by SIZE bytes
59  --help display this help and exit
60  --version output version information and exit
61 
62 The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
63 Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,... (powers of 1000).
64 Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
65 
66 SIZE may also be prefixed by one of the following modifying characters:
67 '+' extend by, '-' reduce by, '<' at most, '>' at least,
68 '/' round down to multiple of, '%' round up to multiple of.
69 
70 GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
71 Full documentation <https://www.gnu.org/software/coreutils/truncate>
72 or available locally via: info '(coreutils) truncate invocation'
73 #+end_example
74 
75 test mkfs.btrfs on 10T dummy block device
76 #+begin_src shell
77  dd if=/dev/zero of=/tmp/bb1 bs=1 count=1 seek=10T
78  du -sh /tmp/bb1
79  losetup --show -f /tmp/bb1
80  mkfs.btrfs /dev/loop0
81 #+end_src
82 
83 diagnostics
84 #+begin_src shell
85  iostat # pacman -S sysstat
86  blktrace # paru -S blktrace
87  iotop # pacman -S iotop
88 #+end_src
89 
90 bcc/ trace: Who/which process is executing specific functions against
91 block devices?
92 
93 bcc/biosnoop: Which process is accessing the block device, how many
94 bytes are accessed, which latency for answering the requests?
95 
96 at the kernel level besides BPF we got kmods and DKMS,
97 
98 compression/de-duplication can be done via VDO kernel mod
99 
100 https://en.wikipedia.org/wiki/Dynamic_Kernel_Module_Support
101 
102 * NOTE save-lisp-and-respawn
103 :LOGBOOK:
104 - State "NOTE" from [2024-03-02 Sat 22:57]
105 :END:
106 #+begin_src lisp
107  sb-ext:*save-hooks*
108 #+end_src
109 
110 * NOTE syslog for log
111 :LOGBOOK:
112 - State "NOTE" from [2024-03-03 Sun 16:35]
113 :END:
114 sb-posix:
115 - openlog syslog closelog
116 - levels: emerg alert crit err warning notice info debug
117 - setlogmask