summaryrefslogtreecommitdiff
path: root/3 resources/linux
diff options
context:
space:
mode:
authorJasper Ras <jras@hostnet.nl>2025-01-08 10:48:09 +0100
committerJasper Ras <jras@hostnet.nl>2025-01-08 10:48:09 +0100
commited0753ad224f0c65133bd7a63180257eecd9f5e3 (patch)
treecc662868574fe17db58be9e0faadd452c84dc59c /3 resources/linux
parent493be30dc981eaf762a95a1218f96893b1976727 (diff)
vault backup: 2025-01-08 10:48:09
Diffstat (limited to '3 resources/linux')
-rw-r--r--3 resources/linux/Watch.md1
-rw-r--r--3 resources/linux/apt.md2
-rw-r--r--3 resources/linux/bootloader.md1
-rw-r--r--3 resources/linux/device-drivers.md19
-rw-r--r--3 resources/linux/device-mapper.md25
-rw-r--r--3 resources/linux/filesystems/tmpfs.md13
-rw-r--r--3 resources/linux/filesystems/virtual filesystem.md0
-rw-r--r--3 resources/linux/glibc.md1
-rw-r--r--3 resources/linux/lsof.md65
-rw-r--r--3 resources/linux/man pages.md2
-rw-r--r--3 resources/linux/networking/dhcp.md4
-rw-r--r--3 resources/linux/networking/ip-masquerade-nat.md14
-rw-r--r--3 resources/linux/networking/nbp.md3
-rw-r--r--3 resources/linux/networking/pxe-boot.md15
-rw-r--r--3 resources/linux/networking/udp.md0
-rw-r--r--3 resources/linux/nic.md1
-rw-r--r--3 resources/linux/shared anonymous memory mappings.md2
-rw-r--r--3 resources/linux/system v shared memory.md2
-rw-r--r--3 resources/linux/tftp.md2
19 files changed, 172 insertions, 0 deletions
diff --git a/3 resources/linux/Watch.md b/3 resources/linux/Watch.md
new file mode 100644
index 0000000..dafeb80
--- /dev/null
+++ b/3 resources/linux/Watch.md
@@ -0,0 +1 @@
+`watch (1)` periodically executes the executable on argv. It can be used to reload the output of a command, like `sudo watch ovs-dpctl dump-flows` . \ No newline at end of file
diff --git a/3 resources/linux/apt.md b/3 resources/linux/apt.md
new file mode 100644
index 0000000..36a098c
--- /dev/null
+++ b/3 resources/linux/apt.md
@@ -0,0 +1,2 @@
+reinstall packages:
+`apt reinstall <pkg>` \ No newline at end of file
diff --git a/3 resources/linux/bootloader.md b/3 resources/linux/bootloader.md
new file mode 100644
index 0000000..e9c2fff
--- /dev/null
+++ b/3 resources/linux/bootloader.md
@@ -0,0 +1 @@
+[[TODO]] \ No newline at end of file
diff --git a/3 resources/linux/device-drivers.md b/3 resources/linux/device-drivers.md
new file mode 100644
index 0000000..e4fe9d2
--- /dev/null
+++ b/3 resources/linux/device-drivers.md
@@ -0,0 +1,19 @@
+major, minor numbers
+major = driver (used by kernel when opening device to dispatch to correct driver)
+minor = used by driver to differentiate device(s)
+
+after disk the major, minor numbers are shown:
+```
+[jasras@n04.compute.vps2-lej1 ~]$ ls -l /dev/dm-*
+brw-rw---- 1 root disk 253, 0 Oct 25 10:10 /dev/dm-0
+brw-rw---- 1 root disk 253, 1 Oct 25 10:11 /dev/dm-1
+brw-rw---- 1 root root 253, 11 Oct 28 19:58 /dev/dm-11
+brw-rw---- 1 root root 253, 12 Oct 28 19:58 /dev/dm-12
+```
+
+available devices: `cat /proc/devices`
+
+character devices vs block devices; what is the difference?
+
+---
+[oreilly-device-drivers](https://www.oreilly.com/library/view/linux-device-drivers/0596000081/ch03s02.html) \ No newline at end of file
diff --git a/3 resources/linux/device-mapper.md b/3 resources/linux/device-mapper.md
new file mode 100644
index 0000000..f862496
--- /dev/null
+++ b/3 resources/linux/device-mapper.md
@@ -0,0 +1,25 @@
+Device mapper is a kernel driver to map physical block devices to virtual ones; this means that for example we can have many physical devices be represented by a single virtual one (linear mapping).
+
+How does it work?
+[[TODO]]
+What is its function in relation to multipath?
+
+Logical devices using device-mapper can be managed using `man 8 dmsetup`
+```
+[jasras@n04.compute.vps2-lej1 ~]$ sudo dmsetup info 3600a098038314d736724566a67346538
+Name: 3600a098038314d736724566a67346538
+State: ACTIVE
+Read Ahead: 256
+Tables present: LIVE
+Open count: 1
+Event number: 3
+Major, minor: 253, 12
+Number of targets: 1
+UUID: mpath-3600a098038314d736724566a67346538
+```
+
+If dmsetup cannot remove a device because a process still has it open, but lsof does not show any processes that open it, use `-f` which replaces the device with a fake that rejects all I/O.
+
+---
+[device-mapper](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/device_mapper#device_mapper)
+[dmsetup](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/dmsetup#dmsetup) \ No newline at end of file
diff --git a/3 resources/linux/filesystems/tmpfs.md b/3 resources/linux/filesystems/tmpfs.md
new file mode 100644
index 0000000..624c835
--- /dev/null
+++ b/3 resources/linux/filesystems/tmpfs.md
@@ -0,0 +1,13 @@
+Is a [[virtual filesystem]] that is stored in memory; it uses both RAM and swap space.
+> Kernel option: CONFIG_TMPFS
+
+`mount -t tmpfs source target`
+
+A tmpfs can only grow to 50% of RAM avail. unless overridden with size=nbytes mount option.
+Only consumes RAM for actual usage.
+Data is ephemeral/volatile.
+
+Mount stacking: mount over existing /tmp, to improve speed of apps using alot of tmp files, then unmount to delete data.
+
+Kernel uses tmpfs for [[system v shared memory]] and [[shared anonymous memory mappings]].
+`/dev/shm` or `/run/shm`: [[glibc]] of [[POSIX]] shared memory and [[POSIX]] semaphores. \ No newline at end of file
diff --git a/3 resources/linux/filesystems/virtual filesystem.md b/3 resources/linux/filesystems/virtual filesystem.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/3 resources/linux/filesystems/virtual filesystem.md
diff --git a/3 resources/linux/glibc.md b/3 resources/linux/glibc.md
new file mode 100644
index 0000000..18d18e1
--- /dev/null
+++ b/3 resources/linux/glibc.md
@@ -0,0 +1 @@
+The GNU C standard library. \ No newline at end of file
diff --git a/3 resources/linux/lsof.md b/3 resources/linux/lsof.md
new file mode 100644
index 0000000..e95b968
--- /dev/null
+++ b/3 resources/linux/lsof.md
@@ -0,0 +1,65 @@
+```
+lsof -p 1111 # show open files for this PID
+lsof /path/to/file # show which process has this open
+```
+
+A usage in the wild; using lsof to find the qemu process for a specific base image and using that to get instance name and disk path:
+```
+lsof -F p {{ item['path'] }} | cut -b 2- | head -1 | xargs ps | grep -oP '(instance\\-[a-z0-9]+)|(\\/var\\/lib\\/nova\\/instances\\/[a-z0-9\\-]+\\/disk)' | uniq
+```
+
+(man lsof: search "OUTPUT FOR OTHER PROGRAMS")
+output for other programs
+```
+specify -F
+These are the fields that lsof will produce. The single character listed first is the field identifier.
+ a file access mode
+ c process command name (all characters from proc or
+ user structure)
+ C file structure share count
+ d file's device character code
+ D file's major/minor device number (0x<hexadecimal>)
+ f file descriptor (always selected)
+ F file structure address (0x<hexadecimal>)
+ G file flaGs (0x<hexadecimal>; names if +fg follows)
+ g process group ID
+ i file's inode number
+ K tasK ID
+ k link count
+ l file's lock status
+ L process login name
+ m marker between repeated output
+ M the task comMand name
+ n file name, comment, Internet address
+ N node identifier (ox<hexadecimal>
+ o file's offset (decimal)
+ p process ID (always selected)
+ P protocol name
+ r raw device number (0x<hexadecimal>)
+ R parent process ID
+ s file's size (decimal)
+ S file's stream identification
+ t file's type
+ T TCP/TPI information, identified by prefixes (the
+ `=' is part of the prefix):
+ QR=<read queue size>
+ QS=<send queue size>
+ SO=<socket options and values> (not all dialects)
+ SS=<socket states> (not all dialects)
+ ST=<connection state>
+ TF=<TCP flags and values> (not all dialects)
+ WR=<window read size> (not all dialects)
+ WW=<window write size> (not all dialects)
+ (TCP/TPI information isn't reported for all supported
+ UNIX dialects. The -h or -? help output for the
+ -T option will show what TCP/TPI reporting can be
+ requested.)
+ u process user ID
+ z Solaris 10 and higher zone name
+ Z SELinux security context (inhibited when SELinux is disabled)
+ 0 use NUL field terminator character in place of NL
+ 1-9 dialect-specific field identifiers (The output
+ of -F? identifies the information to be found
+ in dialect-specific fields.)
+
+``` \ No newline at end of file
diff --git a/3 resources/linux/man pages.md b/3 resources/linux/man pages.md
new file mode 100644
index 0000000..576d4b8
--- /dev/null
+++ b/3 resources/linux/man pages.md
@@ -0,0 +1,2 @@
+I need to more consistently read man pages. Example is `man task` to see how taskwarrior works, after reading it today I found that it is actually quite easy.
+They often contain good information on how to use a certain tool. \ No newline at end of file
diff --git a/3 resources/linux/networking/dhcp.md b/3 resources/linux/networking/dhcp.md
new file mode 100644
index 0000000..e426d6f
--- /dev/null
+++ b/3 resources/linux/networking/dhcp.md
@@ -0,0 +1,4 @@
+Dynamic Host Configuration Protocol
+Allows hosts dynamically receive an IP address.
+
+[[TODO]] learn exactly how it works \ No newline at end of file
diff --git a/3 resources/linux/networking/ip-masquerade-nat.md b/3 resources/linux/networking/ip-masquerade-nat.md
new file mode 100644
index 0000000..8b722f4
--- /dev/null
+++ b/3 resources/linux/networking/ip-masquerade-nat.md
@@ -0,0 +1,14 @@
+A function in the kernel that allows guests with internal/private IPs to access the internet by using the hosts' public IP similar to 1 to many NAT.
+
+Differences with Proxy, IP Masq, NAT:
+
+**Proxy**
+Requires special configuration on internal client side. Can be used for caching.
+
+**IP Masq**
+A form of NAT used primarily in Linux devices. Translates IP address and uses the connection tracking table and ports to map responses back to the internal connection.
+
+**NAT**
+Has different types with different use-cases.
+Static NAT: 1-1 mapping of pub/private IP. Dynamic NAT: pool of pub ips to dynamically map private IPs to based on availability.
+PAT (Port): similar to IP Masq; 1-many using ports. \ No newline at end of file
diff --git a/3 resources/linux/networking/nbp.md b/3 resources/linux/networking/nbp.md
new file mode 100644
index 0000000..19676ea
--- /dev/null
+++ b/3 resources/linux/networking/nbp.md
@@ -0,0 +1,3 @@
+Network Bootstrap Program
+
+Is a bootloader that is obtained via the network typically via [[TFTP]]. It handles setting up an environment in which an OS can run or install. For example, it displays a boot menu and downloads the kernel images. It sets up hardware, for example the [[NIC]]s. \ No newline at end of file
diff --git a/3 resources/linux/networking/pxe-boot.md b/3 resources/linux/networking/pxe-boot.md
new file mode 100644
index 0000000..d532ac3
--- /dev/null
+++ b/3 resources/linux/networking/pxe-boot.md
@@ -0,0 +1,15 @@
+PXE = Preboot Execution Environment.
+
+PXE boot process:
+1. Modified [[DHCP]] request: request to include boot information (PXE boot request).
+2. Process DHCP response which includes an IP address of [[TFTP]] server and filename of [[NBP]].
+3. Download NBP over TFTP.
+4. NBP executes
+ 1. Loads additional stuff over network, like kernel images.
+ 2. Handles the boot menu
+5. Kernel takes over boot process and potentially downloads additional files required to complete booting.
+
+Popular NBP's:
+- PXELINUX
+- iPXE
+- GRUB2
diff --git a/3 resources/linux/networking/udp.md b/3 resources/linux/networking/udp.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/3 resources/linux/networking/udp.md
diff --git a/3 resources/linux/nic.md b/3 resources/linux/nic.md
new file mode 100644
index 0000000..592ad1c
--- /dev/null
+++ b/3 resources/linux/nic.md
@@ -0,0 +1 @@
+Network Interface Card \ No newline at end of file
diff --git a/3 resources/linux/shared anonymous memory mappings.md b/3 resources/linux/shared anonymous memory mappings.md
new file mode 100644
index 0000000..71d1cfc
--- /dev/null
+++ b/3 resources/linux/shared anonymous memory mappings.md
@@ -0,0 +1,2 @@
+[[TODO]]
+Linux API book: chapter 49 \ No newline at end of file
diff --git a/3 resources/linux/system v shared memory.md b/3 resources/linux/system v shared memory.md
new file mode 100644
index 0000000..d1f690d
--- /dev/null
+++ b/3 resources/linux/system v shared memory.md
@@ -0,0 +1,2 @@
+[[TODO]]
+Linux API book chapter 48 \ No newline at end of file
diff --git a/3 resources/linux/tftp.md b/3 resources/linux/tftp.md
new file mode 100644
index 0000000..259fdec
--- /dev/null
+++ b/3 resources/linux/tftp.md
@@ -0,0 +1,2 @@
+Trivial File Transfer Protocol
+[[TODO]] \ No newline at end of file