Project

General

Profile

Miscellaneous » History » Version 4

Anonymous, 10/31/2021 01:52 PM
adding notes

1 1
h1. Miscellaneous
2
3 4
h2. Add new drive SW RAID5
4
5
# Format drive if needed (see below for steps).
6
# Add new drive to SW RAID:
7
<pre>
8
$ sudo mdadm --manage /dev/md0 --add /dev/sdd1
9
</pre>
10
# Grow array:
11
<pre>
12
$ sudo mdadm --grow --raid-devices=4 /dev/md0
13
</pre>
14
15
h2. Replace failed SW RAID drive
16
17
# If drive is brand new be sure to create a partition on it:
18
<pre>
19
sorber@file2:~$ sudo parted /dev/sdg
20
GNU Parted 3.3
21
Using /dev/sdg
22
Welcome to GNU Parted! Type 'help' to view a list of commands.
23
(parted) mklabel gpt
24
(parted) mkpart primary 2048s 100%                                        
25
(parted) print                                                            
26
Model: ATA ST2000DM008-2FR1 (scsi)
27
Disk /dev/sdg: 2000GB
28
Sector size (logical/physical): 512B/4096B
29
Partition Table: gpt
30
Disk Flags: 
31
32
Number  Start   End     Size    File system  Name     Flags
33
 1      1049kB  2000GB  2000GB               primary
34
35
(parted) quit
36
</pre>
37
# If needed, mark bad drive as failed:
38
<pre>
39
$ sudo mdadm --manage /dev/md0 --fail /dev/sdd
40
</pre>
41
# Add new drive to replace failed:
42
<pre>
43
$ sudo mdadm --manage /dev/md0 --add /dev/sdd1 /dev/sdg1
44
</pre>
45
# Improve rebuild speed slightly:
46
<pre>
47
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_min"
48
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_max"
49
</pre>
50
# Monitor rebuild:
51
<pre>
52
$ watch -n1 cat /proc/mdstat 
53
</pre>
54
55
h2. Get detailed drive information
56
57
<pre>
58
$ udevadm info --query=all --name=/dev/sda
59
</pre>
60
61 1
h2. Split flac with cue
62
63
<pre>
64
$ sudo apt install cuetools shntool
65
66
$ shnsplit -f file.cue -t %n-%t -o flac file.flac
67
</pre>
68
69
h2. Fix Chrome Display Glitches
70
71
Somewhere around Chrome 86 display glitches started happening on wake. Here is how to fix:
72
73 3
Enabling @enable-vulkan@ in @chrome://flags@ then restarting the browser fixed it. If that does not work, you can also try enabling `ignore-gpu-blacklist` as well.
74 1
75
h2. Setup SSH Public Key
76
77
# On host machine generate a key pair. This key can be reused for multiple remote machines so it's not really necessary to change the name unless multiple keys are generated, which is also not really needed.
78
<pre>
79
$ ssh-keygen -t rsa
80
</pre>
81 3
 *NOTE:* for NetBeans to use/recognize the ssh key you must use the old PEM format:
82 1
<pre>
83
$ ssh-keygen -m PEM -t rsa
84
</pre>
85
# Now use `ssh-copy-id` to copy the key to the remote machine (for example):
86
<pre>
87
$ ssh-copy-id -i ~/.ssh/phalanx_rsa.pub dsorber@phalanx
88
</pre>
89
90
h2. Read Windows Product Key from ACPI Firmware
91
92
Boot into Linux and run:
93
94
<pre>
95
$ sudo strings /sys/firmware/acpi/tables/MSDM
96
</pre>
97
98
h2. Windows 10 Install and SysPrep Instructions
99
100
Very good instructions: https://theitbros.com/sysprep-windows-10-machine-guide/
101
102
103
h2. Search and Replace on Binary Files
104
105
A good hex editor can do search and replace on binary files but sometimes that's not practical:
106
107
* BBE - https://sourceforge.net/projects/bbe-/
108
 BBE is a binary editor with SED-like syntax:
109
<pre>
110
$ bbe -e 's/\x0a\x0d\x0a/\x0d\x0a/' infile > outfile
111
</pre>
112
* binwalk - https://github.com/ReFirmLabs/binwalk
113
 binwalk can search for hex strings (and do many other things)
114
<pre>
115
$ binwalk -R "\x0a\x0d\x0a" infile
116
117
WARNING: Signature '0    string    \x0a\x0d\x0a    Raw signature (\x0a\x0d\x0a)' is a self-overlapping signature!
118
119
DECIMAL       HEXADECIMAL     DESCRIPTION
120
--------------------------------------------------------------------------------
121
242           0xF2            Raw signature (\x0a\x0d\x0a)
122
412           0x19C           Raw signature (\x0a\x0d\x0a)
123
580           0x244           Raw signature (\x0a\x0d\x0a)
124
749           0x2ED           Raw signature (\x0a\x0d\x0a)
125
. . .
126
</pre>
127
128
h2. Wake-on-LAN WOL
129
130
Must be enabled on interface; need MAC
131
<pre>
132
$ sudo apt install etherwake
133
$ sudo etherwake <target MAC> -i <outgoing interface>
134
135
$ sudo etherwake b4:2e:99:a5:1e:f0 -i enp30s0
136
</pre>
137
138
h2. Allocator Shim
139
140
From Chromium, this is really interesting
141
* https://chromium.googlesource.com/chromium/src/base/+/master/allocator/README.md
142
143
However it is not clear how to use it outside of Chromium.
144
145
h2. Update Geany
146
147
# Install prereq packages (this obviously only needs to be done once):
148
<pre>
149
$ sudo apt install libgtk-3-dev libgtkspell-dev libgtkspell3-3-dev
150
</pre>
151
# Set compile flags:
152
<pre>
153
$ export CFLAGS="-O3 -march=native" 
154
$ export CXXFLAGS=$CFLAGS
155
</pre>
156
# Build geany and set to install in /opt so it won't collide with the packaged version:
157
<pre>
158
$ tar xf geany-1.30.tar.bz2
159
$ cd geany-1.30/
160
$ ./configure --prefix=/opt/local --enable-gtk3
161
$ make -j20
162
$ sudo make install
163
</pre>
164
# Set PKG_CONFIG_PATH environment variable so we can build the plugins.
165
<pre>
166
$ export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig/
167
</pre>
168
# Build geany-plugins:
169
<pre>
170
$ tar xf geany-plugins-1.30.tar.bz2 
171
$ cd geany-plugins-1.30/
172
$ ./configure --prefix=/opt/local --enable-gtk3
173
$ make -j20
174
$ sudo make install
175
</pre>
176
177
h2. Find and replace across multiple files
178
179
<pre>
180
$ find /home/www -type f -print0 | xargs -0 sed -i 's/subdomainA\.example\.com/subdomainB.example.com/g'
181
</pre>
182
183
h2. Useful IPMI commands
184
185
186
Power measurement on the SuperMicro (probably won't work on Dell chassis as they have some proprietary version of ipmi):
187
188
<pre>
189
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.136.108 dcmi power reading
190
</pre>
191
192
Check power status (i.e. on/off) of chassis:
193
<pre>
194
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power status
195
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power off
196
</pre>
197
198
Get IPMI IP address (look for "IP Address"):
199
<pre>
200
sudo ipmitool lan print 
201
</pre>
202
203
h2. Full sshfs Connect Command
204
205
<pre>
206
sudo sshfs -o idmap=user -o uid=$(id -u) -o gid=$(id -g) -o allow_other -o follow_symlinks ryftuser@sm-X11DGQ:/home/ryftuser /mnt/sm-X11DGQ/
207
</pre>
208
209
h2. Side-by-side Color Diff
210
211
<pre>
212
$ sudo apt-get install colordiff
213
$ colordiff -y --suppress-common-lines data.txt /ryftone/data.txt
214
</pre>
215
216
h2. x86 ABI
217
218
* https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI
219
220
h2. clang-format and clang-tidy
221
222
* http://www.labri.fr/perso/fleury/posts/programming/using-clang-tidy-and-clang-format.html
223
224
h2. Shared Library and Related Resources
225
226
* http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
227
* https://blog.qt.io/blog/2011/10/28/rpath-and-runpath/
228
* http://www.bnikolic.co.uk/blog/linux-ld-debug.html
229
* http://insanecoding.blogspot.com/2012/07/creating-portable-linux-binaries.html
230
* https://stackoverflow.com/questions/4156055/static-linking-only-some-libraries
231
232
h2. Ubuntu: List Grub Entries
233
234
<pre>
235
gawk  'BEGIN {                                                                                                                       
236
  l=0                                                                                                                                
237
  menuindex= 0                                                                                                                       
238
  stack[t=0] = 0                                                                                                                     
239
}                                                                                                                                    
240
241
function push(x) { stack[t++] = x }                                                                                                  
242
243
function pop() { if (t > 0) { return stack[--t] } else { return "" }  }                                                              
244
245
{                                                                                                                                    
246
247
if( $0 ~ /.*menu.*{.*/ )                                                                                                             
248
{                                                                                                                                    
249
  push( $0 )                                                                                                                         
250
  l++;                                                                                                                               
251
252
} else if( $0 ~ /.*{.*/ )                                                                                                            
253
{                                                                                                                                    
254
  push( $0 )                                                                                                                         
255
256
} else if( $0 ~ /.*}.*/ )                                                                                                            
257
{                                                                                                                                    
258
  X = pop()                                                                                                                          
259
  if( X ~ /.*menu.*{.*/ )                                                                                                            
260
  {                                                                                                                                  
261
     l--;                                                                                                                            
262
     match( X, /^[^'\'']*'\''([^'\'']*)'\''.*$/, arr )                                                                               
263
264
     if( l == 0 )                                                                                                                    
265
     {                                                                                                                               
266
       print menuindex ": " arr[1]                                                                                                   
267
       menuindex++                                                                                                                   
268
       submenu=0                                                                                                                     
269
     } else                                                                                                                          
270
     {                                                                                                                               
271
       print "  " (menuindex-1) ">" submenu " " arr[1]                                                                               
272
       submenu++                                                                                                                     
273
     }                                                                                                                               
274
  }                                                                                                                                  
275
}                                                                                                                                    
276
277
}' /boot/grub/grub.cfg
278
</pre>
279
280
* https://askubuntu.com/a/941993/392271
281
282
283
h2.GCC Disable Unused Variable Warnings
284
285
286
<pre>
287
#pragma GCC diagnostic push
288
#pragma GCC diagnostic ignored "-Wunused-variable"
289
( your problematic library includes )
290
#pragma GCC diagnostic pop
291
</pre>
292
293
See: https://stackoverflow.com/a/22708539/73878
294
295
h2. Fix Steam after NVidia driver update
296
297
Since this has now bitten me twice... Steam requires the 32 bit version of the GL library.
298
299
<pre>
300
$ sudo apt install libnvidia-gl-418:i386
301
</pre>
302
303
h2. Restart Cinnamon from TTY
304
305
# Cinnamon freezes
306
# Switch tty. I usually go to tty6, `Ctrl+Alt+F6`
307
# If you need to login first, do so.
308
# Type `w` (yes, just the letter) and press enter. This commands does a lot of different things, but you need it to figure out the number of the display you are using. The display number is in the column FROM. Mine is `:0` (yes, including the colon).
309
# Assuming that cinnamon is already dead (which you would notice by the windows lacking titles and that you can't move different windows around, and perhaps even not being able to use the keyboard), you type `export DISPLAY=:0; cinnamon &`, and don't forget the colon. I add the ampersand (&) only not to keep that tty busy.
310
311
Sauce: https://askubuntu.com/a/198935/392271
312
313
h2. Ubuntu Set Specific Kernel to Boot
314
315
* Use this command to get a list of available options:
316
<pre>
317
$ grep -Ei 'submenu|menuentry ' /boot/grub/grub.cfg | sed -re "s/(.? )'([^']+)'.*/\1 \2/"
318
menuentry  Ubuntu
319
submenu  Advanced options for Ubuntu
320
    menuentry  Ubuntu, with Linux 4.4.0-34-generic
321
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (upstart)
322
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (recovery mode)
323
menuentry  System setup
324
</pre>
325
* Backup grub configuration, just in case:
326
<pre>
327
$ sudo cp /etc/default/grub /etc/default/grub.bak
328
</pre>
329
* Edit grub configuration and change `GRUB_DEFAULT` to something like this:
330
<pre>
331
$ sudo vim /etc/default/grub
332
333
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-53-generic"
334
</pre>
335
* Update grub configuration
336
<pre>
337
$ sudo update-grub
338
</pre>
339
* See also: https://askubuntu.com/questions/216398/set-older-kernel-as-default-grub-entry
340
341
h2. Ubuntu Networking Resources
342
343
* https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
344
* https://help.ubuntu.com/lts/serverguide/network-configuration.html.en
345
* https://netplan.io/
346
347
h2. Win10 Licensing Info
348
349
* https://www.windowscentral.com/how-change-product-key-windows-10
350
* https://www.tenforums.com/tutorials/49586-determine-if-windows-license-type-oem-retail-volume.html
351
* https://www.tenforums.com/windows-updates-activation/104569-win-10-activation-expiring-volume-license.html
352
353
h2. Python GTK Development Resources
354
355
* https://python-gtk-3-tutorial.readthedocs.io/en/latest/layout.html
356
* https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Box.html#Gtk.Box.pack_start
357
* https://lazka.github.io/pgi-docs/Gtk-3.0/mapping.html
358
359
h2. cpufrequtils Governor Configuration
360
361
These instructions are intended for Ubuntu 16.04 and later (using systemd init).
362
363
* Check the available and currently set governors. Ubuntu has an โ€œondemandโ€ service that sets the governor to ondemand after boot.
364
<pre>
365
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
366
conservative ondemand userspace powersave performance schedutil
367
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 
368
ondemand
369
</pre>
370
371
* Configure cpufrequtils to set the governor to performance at boot
372
<pre>
373
$ echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils
374
GOVERNOR="performance"
375
</pre>
376
377
* Disable the automatic ondemand service. 
378
<pre>
379
$ sudo systemctl disable ondemand
380
</pre>
381
382
* Reboot.
383
384
* Now check that the governor is set to performance for every CPU:
385
<pre>
386
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
387
performance
388
performance
389
performance
390
performance
391
โ€ฆ
392
performance
393
performance
394
performance
395
</pre>
396
397
* Check current CPU speeds:
398
<pre>
399
$ watch -n 1 bash -c 'cpufreq-info | grep "current CPU frequency"'
400
</pre>
401
402
h2. rsync via ssh example
403
404
<pre>
405
$ rsync --info=progress2 -ahz --compress-level=9 -e "ssh -i ~/ryft-pat-f1.pem" data/ ryftuser@18.205.65.5:/ryftone/regression/pubmed/data/
406
</pre>
407
408
h2. Read Performance using AIO
409
410
Use this fio command (run from temp directory on disk in question) to measure max disk read performance:
411
412
<pre>
413
$ fio --name TEST --eta-newline=5s --filename=fio-tempfile.dat --rw=read --size=10g --io_size=10g --blocksize=512k --ioengine=libaio --fsync=0 --iodepth=32 --direct=1 --numjobs=1 --runtime=300 --group_reporting
414
</pre>
415
416
Note that DIRECT_IO is required when using AIO. (see also: https://askubuntu.com/a/991311/392271)
417
418
h2. Remove Source Files While Creating Tarball
419
420
This is handy as it saves on disk space.
421
<pre>
422
$ tar --remove-files -cf pictures.tar Pictures/
423
</pre>
424
425
h2. Linux Find and Remove Files
426
427
Find and remove files (even with spaces in the path) using case insensitive matching for the wildcard:
428
<pre>
429
$ find . -type f -iname "*.jpg" -print0 | xargs -0 rm
430
</pre>
431
432
h2. Convert ASCII hex to binary
433
This problem seems to come up every so often. There is no need for a one-off solution:
434
435
<pre>
436
$ xxd -r -p input.txt output.bin
437
</pre>
438
439
https://stackoverflow.com/questions/7826526/transform-a-hex-info-to-binary-using-linux-command
440
441
h2. Well Said
442
443
https://developers.slashdot.org/comments.pl?sid=12326098&cid=56908942
444
445
h2. Hex Editor
446
447
I had been using [[https://hexinator.com/|Hexinator]] but I've had some minor issues with it. Today I tried [[https://www.wxhexeditor.org/home.php|wxHexEditor]] and I was pleasantly surprised.
448
449
Download from here: https://github.com/EUA/wxHexEditor
450
451
You'll need the latest version of libwxgtk<version>-dev package.
452
453
I had some minor issues with the build (which seems a somewhat bizarre arrangement...) modify the makefile to set `CC` and `CXX` directly, right about line 90.
454
455
Finally, to get it installed in the right place:
456
<pre>
457
sudo make install DESTDIR=/opt/local BINDIR=bin DATADIR=share
458
</pre>
459
460
h2. Preprocessor Fun
461
462
To invoke the preprocessor directly:
463
<pre>
464
gcc -E -DSOME_DEFINE=SOME_VALUE somefile.c 
465
</pre>
466
467
See also [[https://linux.die.net/man/1/unifdef|unifdef]]: "The unifdef utility acts on #if, #ifdef, #ifndef, #elif, #else, and #endif lines, and it understands only the commonly-used subset of the expression syntax for #if and #elif lines."
468
469
h2. Convert Oversampled .flac to 16 bit 44.1 khz .flac
470
471
<pre>
472
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox {} -b 16 -r 44100 output/{/.}.flac"
473
474
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox -v 0.98 {} -b 16 -r 44100 output/{/.}.flac"
475
</pre>
476
477
h2. Aligned C++ STL Types
478
479
<pre>
480
#include <vector>
481
#include <boost/align/aligned_allocator.hpp>
482
483
template <typename T>
484
using aligned_vector = std::vector<T, boost::alignment::aligned_allocator<T, 4096>>;
485
</pre>
486
487
h2. Command line convert .png to .jpg
488
489
<pre>
490
$ for x in *.png; do convert $x $(basename $x .png).jpg; done
491
</pre>
492
493
You can also add the "`-quality 90`" option if needed.
494
495
h2. Determine CPU Family Name
496
497
<pre>
498
$ gcc -march=native -Q --help=target|grep march
499
</pre>
500
501
h2. Convert .flac to .m4a (AAC)
502
503
Requires `ffmpeg` built with libfdk_aac:
504
505
<pre>
506
$ /opt/bin/ffmpeg -i input.flac -vn -c:a libfdk_aac -vbr 3 output.m4a
507
</pre>
508
509
All together using `find` and `parallel` for magic:
510
<pre>
511
$ find . -type f -name "*.flac" | parallel -j16 "/opt/bin/ffmpeg -i {} -vn -c:a libfdk_aac -vbr 4 {/.}.m4a"
512
</pre>
513
514
h2. PyGObject
515
516
This is the magic needed to have stuff happen quasi asynchronously using PyGObject (GTK+):
517
518
<pre>
519
# Yield to the main loop temporarily
520
while Gtk.events_pending():
521
    Gtk.main_iteration()
522
</pre>
523
524
h2. FUSE Code
525
526
 *https://pastebin.com/wavKntiu
527
528
h2. Use Windoze Schtuffs
529
530
 * https://support.microsoft.com/en-gb/help/17588/fix-problems-that-block-programs-from-being-installed-or-removed (gotta love how this requires a separate program)
531
 * [[http://landinghub.visualstudio.com/visual-cpp-build-tools|MSVC Tools]] - compiler (seems to be the rough equivalent of `build-essential`)
532
 * [[https://docs.microsoft.com/en-us/sysinternals/downloads/procmon|Process Monitor]] - useful debug tool
533
  * https://www.codeproject.com/Articles/560816/Troubleshooting-dependency-resolution-problems-usi - example for using Process Monitor
534
 * http://download.microsoft.com/download/7/2/E/72E0F986-D247-4289-B9DC-C4FB07374894/wdexpress_full.exe - (required by wingtk below)
535
 
536
* https://github.com/wingtk/gvsbuild - haven't tried this yet but looks amazing... 
537
538
h2. Build Handbrake Git Build
539
540
Steps for building Handbrake using AOCC:
541
542
<pre>
543
$ source /home/dsorber/Downloads/aocc/setenv_AOCC.sh
544
$ export CC=clang
545
$ export CXX=clang++
546
$ export CFLAGS="-g -O3 -mtune=native"
547
$ export CXXFLAGS=$CFLAGS
548
$ cd ~/Downloads/HandBrake/
549
$ rm -rf build/
550
$ ./configure --prefix=/opt --enable-x265 --enable-fdk-aac --gcc=/home/dsorber/Downloads/aocc/AOCC-1.1-Compiler/bin/clang
551
$ cd build
552
$ make -j17
553
$ sudo make install
554
</pre>
555
556
----
557
558
Regular build (18.04 and later):
559
<pre>
560
$ rm -rf build/
561
$ ./configure --prefix=/opt/local --enable-x265 --enable-fdk-aac
562
$ cd build
563
$ make -j17
564
$ sudo make install
565
</pre>
566
567
h2. Politically Correct Linux
568
569
* https://entertainment.slashdot.org/comments.pl?sid=11493671&cid=55759997
570
571
h2. This guy gets it
572
573
Regarding software purist ideology vs pragmatism
574
575
* https://linux.slashdot.org/comments.pl?sid=11156367&cid=55256437
576
577
h2. "Rotate" Video Playback via Metadata
578
579
<pre>
580
$ ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
581
</pre>
582
583
584
h2. Ubuntu Remove Old Kernels Oneliner
585
586
<pre>
587
$ sudo apt-get purge $(for tag in "linux-image" "linux-headers"; do dpkg-query -W -f'${Package}\n' "$tag-[0-9]*.[0-9]*.[0-9]*" | sort -V | awk 'index($0,c){exit} //' c=$(uname -r | cut -d- -f1,2); done)
588
</pre>
589
590
* [[https://askubuntu.com/questions/2793/how-do-i-remove-old-kernel-versions-to-clean-up-the-boot-menu/571360#571360|Sauce]]
591
592
h2. Remove New Lines (command line)
593
594
For a file:
595
<pre>
596
$ tr -d '\n' < yourfile.txt
597
</pre>
598
599
Or for output of a command (e.g.):
600
<pre>
601
$ find . -type f -name '*.txt' | tr -d '\n'
602
</pre>
603
604
h2. Convert from .mp4 to .mkv Container
605
606
Use `avconv` to convert container without re-encoding:
607
<pre>
608
$ sudo apt-get install libav-tools
609
610
$ avconv -i filme.mp4 -c copy filme.mkv
611
</pre>
612
613
h2. Remove String From Many File Names
614
615
On Ubuntu use Perl rename utility, e.g.:
616
617
<pre>
618
$ rename 's/ \(1920x1080\) \[WaifuKenny\]//' *.mp4
619
</pre>
620
621
h2. Change Default Text Editor
622
623
I always have to Google this...
624
625
<pre>
626
$ sudo update-alternatives --config editor
627
</pre>
628
629
h2. Linux View System RAM Speed
630
631
View RAM speed (actual) on Debian/Ubuntu/Mint:
632
633
<pre>
634
$ sudo lshw -short -C memory
635
H/W path                      Device      Class          Description
636
====================================================================
637
/0/0                                      memory         64KiB BIOS
638
/0/b                                      memory         32GiB System Memory
639
/0/b/0                                    memory         [empty]
640
/0/b/1                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
641
/0/b/2                                    memory         [empty]
642
/0/b/3                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
643
/0/d                                      memory         768KiB L1 cache
644
/0/e                                      memory         4MiB L2 cache
645
/0/f                                      memory         16MiB L3 cache
646
</pre>
647
648
h2. Linux Memory Schtuff
649
650
* [[https://github.com/jbert/exmap|exmap]]
651
* https://jameshunt.us/writings/smaps.html
652
* https://techtalk.intersec.com/2013/07/memory-part-2-understanding-process-memory/
653
* http://bmaurer.blogspot.com/2006/03/memory-usage-with-smaps.html
654
655
* https://github.com/torvalds/linux/blob/master/Documentation/filesystems/proc.txt
656
657
* From: http://stackoverflow.com/questions/24484481/entry-in-proc-meminfo
658
<pre>
659
  2. Active(file), Inactive(file) has file back-end which means its original file is in disk but to use it faster it was loaded on RAM.
660
</pre>
661
662
663
* From: http://unix.stackexchange.com/questions/56879/tracking-down-missing-memory-usage-in-linux
664
665
  The "memory used by a process" is not a clear cut concept in modern operating systems. What can be measured is the size of the address space of the process (SIZE) and resident set size (RSS, how many of the pages in the address space are currently in memory). Part of RSS is shared (most processes in memory share one copy of glibc, and so for assorted other shared libraries; several processes running the same executable share it, processes forked share read-only data and possibly a chunk of not-yet-modified read-write data with the parent). On the other hand, memory used for the process by the kernel isn't accounted for, like page tables, kernel buffers, and kernel stack. In the overall picture you have to account for the memory reserved for the graphics card, the kernel's use, and assorted "holes" reserved for DOS and other prehistoric systems (that isn't much, anyway).
666
667
  The only way of getting an overall picture is what the kernel reports as such. Adding up numbers with unknown overlaps and unknown left outs is a nice exercise in arithmetic, nothing more.
668
669
 * [[http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html|Understanding memory usage on Linux]]
670
671
 * https://linux-mm.org/LinuxMM
672
673
h2. Reinstall grub on UEFI System
674
675
Reinstalling grub on a UEFI system is slightly different than on a traditional legacy BIOS system:
676
677
<pre>
678
# Mount the primary drive root partition and the boot EFI partition
679
sudo mount /dev/sda# /mnt            # Mount root (/) partition
680
sudo mount /dev/sda# /mnt/boot       # Mount boot (/boot) partition (if separate from root partition; typically not)
681
682
sudo mkdir -p /mnt/boot/efi          # Create EFI partition mount point
683
sudo mount /dev/sda1 /mnt/boot/efi   # Mount EFI partition
684
685
# Mount your virtual filesystems:
686
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
687
688
# Chroot
689
sudo chroot /mnt
690
</pre>
691
692
Now, if you have networking you'll need DNS. If using `resolvconf` (for recent versions of Ubuntu):
693
694
# Edit ` /etc/resolvconf/resolv.conf.d/head` and add the following line (OpenDNS server).  Then save and exit:
695
<pre>
696
add nameserver 208.67.222.222
697
</pre>
698
# Next enable updates and update:
699
<pre>
700
sudo resolvconf --enable-updates
701
sudo resolvconf -u
702
</pre>
703
# Now you should have DNS. Test by pinging something.
704
705
Finally, back to fixing grub. Note that the grub install should run smoothly with no errors or warnings. If you see any something is probably wrong.
706
<pre>
707
apt-get install grub-efi-amd64  # Install grub EFI bootloader (this should be all you need to do)
708
709
710
# manual steps if you need them for some reason
711
grub-install --recheck --no-floppy --force /dev/sda1  # Install grub bootloader in EFI partition
712
713
#####
714
echo "configfile (hd0,gpt#)/boot/grub.cfg" > /boot/efi/ubuntu/grub.cfg # Tell grub to load grub.cfg from /boot
715
716
update-grub                          # Create grub menu list
717
#####
718
719
exit                                 # Exit chroot
720
721
</pre>
722
723
Reboot and you should be back in business.
724
725
h2. Convert flac to VBR mp3 using ffmpeg/lame
726
727
<pre>
728
for file in *.flac; do name=$(echo $file | sed "s/\.flac//g"); ffmpeg -i "$file" -codec:a libmp3lame -qscale:a 0 "$name".mp3; done
729
</pre>
730
731
h2. Create UEFI/legacy BIOS Bootable ISO
732
733
* http://askubuntu.com/questions/625286/how-to-create-uefi-bootable-iso
734
735
h2. Getting rEFInd to work on Mac OS 10.11
736
737
* http://mattjanik.ca/blog/2015/10/01/refind-on-el-capitan/
738
739
h2. Convert DTS 5.1 to FLAC
740
741
<pre>
742
sudo apt-get install libdca-utils ffmpeg sound-juicer gnome-terminal easytag vlc 
743
744
for file in *.wav; do name=$(echo $file | sed "s/\.wav//g"); dcadec -o wavall "$file" > "$name"_decoded.wav; ffmpeg -i "$name"_decoded.wav "$name".flac; rm -f "$file" "$name"_decoded.wav; done
745
</pre>
746
747
Source: http://ubuntuforums.org/archive/index.php/t-1849260.html
748
749
h2. Windows Utils
750
751
* http://windirstat.info/download.html
752
* https://www.raymond.cc/blog/safely-delete-unused-msi-and-mst-files-from-windows-installer-folder/
753
754
h2. SSH Security
755
756
https://stribika.github.io/2015/01/04/secure-secure-shell.html
757
758
h2. Windows 10
759
760
* http://ultimateoutsider.com/downloads/ - GWX Control Panel to disable GWX (Windows 10 update nagging)
761
* [[https://www.safer-networking.org/spybot-anti-beacon/|Spybot Anti-Beacon]] - Disable Micro$oft "telemetry" data gathering from Windows 10, 8.x, and 7
762
763
<pre>
764
The newest version of the KB3035583 update includes a background process which scans the 
765
system's Windows Registry twice a day to see if the values for the four aforementioned registry 
766
inputs were manually edited to disable the upgrade prompt. If they were, the process will alter 
767
the values, silently re-download the Windows 10 installation files (about 6 GB in total), and 
768
prompt the user to upgrade.
769
</pre>
770
771
772
h2. gpg-agent
773
774
* http://www.infrastructureanywhere.com/documentation/additional/mirrors.html
775
776
These instructions are geared toward reprepro but should be useful in general for setting up `gpg-agent`.
777
778
779
h2. Resolve DNS While VPN Connected
780
781
How to configure dnsmasq for DNS overrides while using a VPN connection: https://chawlasumit.wordpress.com/2014/06/15/linux-mint-openconnect-vpn-dns-issues/
782
783
h2. Pretty Print Python Traceback
784
785
<pre>#!python
786
import traceback
787
788
 ...
789
790
try: 
791
    with open('/dev/null', 'w') as void:
792
        rc = not bool(subprocess.call('modprobe -r {:s}'.format(mod_name), 
793
                                      shell=True, stdout=void, stderr=void))
794
except Exception as e:
795
    print_failure_status()
796
    exc_type, exc_value, exc_traceback = sys.exc_info()
797
    print('\n')
798
    traceback.print_exception(exc_type, exc_value, exc_traceback)
799
    print('\n')
800
</pre>
801
802
h2. Generating Random Data Files for Testing
803
804
One approach is to use /dev/urandom (non-blocking pseudorandom device):
805
<pre>
806
$ dd if=/dev/urandom bs=32M count=32 of=data_1GB.bin
807
</pre>
808
Unfortunately /dev/urandom is a bit slow. However, you can alternatively use openssl to generate pseudorandom numbers a bit faster:
809
<pre>
810
 $ openssl rand 1073741824 > data_1GB.bin
811
 $ for run in {1..30}; do echo $run; openssl rand 1073741824 >> data_30GB.bin; done
812
</pre>
813
814 2
h2. Cloning HDDs
815 1
When configuring multiple chassis it is necessary to clone an HDD. There are all sorts of disk imaging tools out there but it's hard to beat the trusty dd command. The pv (pipe viewer) portion isn't strictly necessary but it prints out a very useful textual status bar. The back ticked blockdev command reports the size of the drive in bytes, which pv then uses to determine overall progress. The bs argument to dd should correspond to the cache size of the drive for optimum performance (32MB is a sane default for most drives these days).
816
817
To clone a single drive to another identical drive (assuming sda is the source and sdb is the destination):
818
<pre>
819
 $ sudo dd if=/dev/sda bs=32M | pv -s `sudo blockdev --getsize64 /dev/sda` | sudo dd of=/dev/sdb bs=32M
820
</pre>
821
To clone to multiple drives all at once (assuming sda is the source and sdb, sdc are destinations):
822
<pre>
823
 $ sudo dd if=/dev/sda bs=32M | pv -s `sudo blockdev --getsize64 /dev/sda` | tee >(sudo dd of=/dev/sdb bs=32M) | sudo dd of=/dev/sdc bs=32M
824
</pre>
825
It is entirely possible to clone more drives by adding additional `>(sudo dd of=/dev/sdX bs=32M)` arguments to the tee command. Note that tee outputs to stdout so it is necessary to pipe the output of tee to the final dd command as shown above. If you don't do this then tee will spew the raw contents of the source HDD to your screen, which will make the clone take forever and look especially ugly!
826
827
For some reason RedHat/CentOS do not have the pv command or even a package for it in their repos!!! Therefore, boot from a Debian-based OS in order to clone.
828
829
h2. Generating ISOs
830
831
<pre>
832
 $ genisoimage -R -J -o <output.iso> <some directory>
833
</pre>
834
To deal with long file names:
835
<pre>
836
 $ genisoimage -R -J -l -D -joliet-long -o <output.iso> <some directory>
837
</pre>
838
839 2
h2. BIOS/grub
840 1
841 2
* http://forums.linuxmint.com/viewtopic.php?f=46&t=119832
842
* http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html
843
* https://wiki.archlinux.org/index.php/GRUB2
844
* http://unix.stackexchange.com/questions/28443/does-grub2-support-putting-boot-on-a-raid5-partition
845 1
846
h3. Creating a BIOS Boot Partition on a GPT system
847
848
<pre>
849
$ sudo parted /dev/sda
850
(parted) mkpart primary 0 1024k
851
(parted) set 2 bios_grub on
852
</pre>
853
854 2
h2. Actiontec Router
855
856
* http://transition.fcc.gov/oet/ea/fccid/
857
* http://opensource.actiontec.com/mi424wref.html
858 1
859
h2. Temp
860
861
https://www.grumpyland.com/blog/183/installing-software-raid-on-centos-567-via-ssh/
862
<pre>
863
# swap is on /dev/md1
864
/dev/md1 none            swap    sw              0       0
865
866
# storage is on /dev/md0
867
/dev/md0        /storage        xfs     noatime,barrier=0 0 0
868
//faramir/production/sw /sw     cifs    username=samba,password=w00tw00t!,file_mode=0666,dir_mode=0777  0       0
869
</pre>
870
871
----
872
[[../|Back home]]