changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > org > notes / 20240302.org

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