changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > org > notes / 20240302.org

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