Since the Raspberry Pi Zero and Zero W are not available in bulk quantity, I looked around for alternatives. The C.H.I.P. seems to be a great option, but the company has been unable to fulfill it’s orders and the $9 version has been discontinued 🙁 The Banana Pi is a knock-off of the rPi but the cost is 50% to 100% more than the rPi. Similar for the NanoPi, about double the cost. Finally I found the Orange Pi, it’s costs are similar (some as low as $7) yet there’s many variations of it. Trying to make sense of the options, I put together a table that compares some aspects of the oPi:
Category: linux
Lots of alias addresses on an IP interface?
It’s easy to add multiple IP addresses to an interface in Linux. For example, you want to have both the address 172.16.0.13 and 192.168.0.17 for your Ethernet device. But, can we create LOTS and LOTS of addresses?
For fun, I wrote a little script to create bunches of alias addresses. I tested on a RedHat Enterprise 6.8 64bit VM (running kernel 2.6.32-642.el6.x86_64), since there’s still lots of this older o/s out there. I tried 50,000 alias addresses, and ta da! it works fine:
# ip addr
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:76:75:29 brd ff:ff:ff:ff:ff:ff
inet 172.16.47.139/16 brd 172.16.255.255 scope global eth0
inet 192.168.0.1/32 scope global eth0:3232235521
inet 192.168.0.2/32 scope global eth0:3232235522
inet 192.168.0.3/32 scope global eth0:3232235523
inet 192.168.0.4/32 scope global eth0:3232235524
. . .
inet 192.168.195.77/32 scope global eth0:3232285517
inet 192.168.195.78/32 scope global eth0:3232285518
inet 192.168.195.79/32 scope global eth0:3232285519
inet 192.168.195.80/32 scope global eth0:3232285520
inet6 fe80::a00:27ff:fe76:7529/64 scope link
valid_lft forever preferred_lft forever
The network seems plenty responsive still; and I can ping any of the alias addresses. Creation of 50,000 aliases took about a minute. FWIW.
Ubuntu Window Border – Bigger than 1px
Many of the default Ubuntu desktop themes come with a 1 pixel-wide window border. This makes it difficult to resize your windows*
You can increase this window size by editing the parameters for your theme. First off, you need to figure out which theme you’re using. In many themes, you’ll find this at:
System -> Preferences -> Look and Feel -> Appearance -> Theme tab.
Once you know the theme, open a terminal and edit the file that defines it. For this example, I’m using the Ambiant-MATE theme with the metacity window manager. Thus, the file I want to edit is:
/usr/share/themes/Ambiant-MATE/metacity-1/metacity-theme-1.xml
You’ll want to be root to do this. Look for the frame_geometry_normal section (usually the first), and change these three lines from 1 to a larger value. I found that 4 pixels is adequate:
<distance name=”left_width” value=”4″/>
<distance name=”right_width” value=”4″/>
<distance name=”bottom_height” value=”4″/>
Save the file, then you need to log out and log back in so your window manager restarts. That’s it!
*Unless you use the Alt + Right-Mouse-Button or Alt-F8 tricks, but those are not commonly known.
Install Ubuntu MATE 16.04 on RAID 1
Task: Install Ubuntu MATE 16.04 (or any similar Debian Linux O/S) on RAID 1 disks
Reference:
- http://askubuntu.com/questions/505446/how-to-install-ubuntu-14-04-with-raid-1-using-desktop-installer
- http://askubuntu.com/questions/660023/how-to-install-ubuntu-14-04-64-bit-with-a-dual-boot-raid-1-partition-on-an-uefi
Given: Two disks, /dev/sda and /dev/sdb; using MBR tables. (GPT is similar but you’ll need to set the bios_grub flag).
Simple single RAID set (/dev/md0) created from the two disks.
Boot into the Ubuntu live-installation; open a terminal window.
Partition the disks
# parted -a optimal
unit MiB
# Do first drive
select /dev/sda
mktable msdos
mkpart primary ext4 1 -1 # uses all the space excet 1MiB at front for boot area
set 1 raid on
# Repeat on second drive
select /dev/sdb
mktable msdos
mkpart primary ext4 1 -1 # uses all the space excet 1MiB at front for boot area
set 1 raid on
# Done
quit
Stop the auto-detected RAID: Sometimes (if you already have mdadm installed) the live-instance of Ubuntu that you’re running will autodetect the just-created RAID partitions and build the array. You don’t want this yet, so stop it:
# cat /proc/mdstat
If you see any, like /dev/md127 or whatever, stop it:
# sudo mdadm --stop /dev/md127
Create file systems in here, really not needed but I do this to start “clean” on the disks before RAID overwrites this. It leaves some identity info out there anyway; for example, a ‘print’ in parted shows the filesystem type.
# sudo mkfs.ext4 /dev/sda1
# sudo mkfs.ext4 /dev/sdb1
Build the RAID array.
Install mdadm (onto the Live distro, not the final system)
# sudo apt-get -y install mdadm
# sudo mdadm --create /dev/md0 --bitmap=internal --level=1 --raid-disks=2 /dev/sda1 /dev/sdb1
Partition the RAID array
# sudo parted -a optimal /dev/md0
unit MiB
mktable msdos
mkpart primary 1 16GB # Swap partition, use whatever size you need
mkpart primary 16GB -1 # The rest for / (root partition)
Now install Ubunto onto the new RAID array – but NOT the bootloader yet (-b); you must handle that special.
# ubiquity -b
During the install, select “Something else” for the disk layout.
Choose the swap and root partitions on the /dev/md0 device for the install.
Check the “format” box to format the root partition as ext4.
Let the install run, this uses much time…
Do NOT reboot yet – it will fail. You must manually install the bootloader onto each disk.
sudo -s
mount /dev/md0p2 /mnt
mount -o bind /dev /mnt/dev
mount -o bind /dev/pts /mnt/dev/pts
mount -o bind /sys /mnt/sys
mount -o bind /proc /mnt/proc
cat /etc/resolv.conf >> /mnt/etc/resolv.conf
chroot /mnt
apt-get install mdadm
vi /etc/grub.d/10_linux # change quick_boot and quiet_boot both to 0
grub-install /dev/sda
grub-install /dev/sdb
update-grub
exit
Negated getopt long-form options: to dash or not to dash?
Is there a standard or convention that specifies the long-form option negation prefix for a CLI? That is, which is correct?:
--nodaemonize --no-daemonize
I looked thru the POSIX specs, the Getopt::Long parsers, the manpages for getopt() and getopts(), and found nada! So what’s a coder to do? Write a Perl script, of course! I wrote script that parsed thru the entire man(1) set of pages, and pulled out both forms of negated long options. Here’s the result:
Without dash (no): 368 unique options With dash (no-): 1135 unique options
And the winner is… BOTH forms! There is no standard for it. The with-dash form was preferred 3:1, but that’s not enough margin to call it a clear winner.
What was apparent is for a single utility, use ONE OR THE OTHER. Don’t ever mix them for a single utility. And there you have it.
Defacto-standard for Linux/UNIX CLI options
== DRAFT ==
Although there’s no need for a standard usage of the getopt() long options, we have only 2 x 26 = 52 available switch characters for the older short options. (Actually, more, ‘cuz we can do things like -4 or -# or -@ for switches. Regardless…)
Because choices are limited, a defacto standard has emerged — 30+ years in the making — for the short options:
-f --force, sometimes -f is used for a config file -h --help -o --output (to the named file, for example) (rarely: -o optionname=value) -v --verbose -q --quiet
The above are almost universally used, while the following are “frequently” used:
-a --all or --append; or a start time (the --at-time) -c --configuration-file or related .conf option, sometimes -f is used for this (but -c preferred) -d --debug or sometimes --directory -D --no-daemonize or --disable -e --error; send to stderr instead of syslog -E --enable -g --group(s) -i --interactive, --identity or some identity related thing, sometimes --ignore -l --long or --lengthy, such as include details (different than verbose); or --log-level, or --list -n --count, any numerical thing -p --port or --priority -r --recursive -R --alternate-root or --root, also -R (uppercase) sometimes used for --recursive -t time-related things -T test related things, especially test timeouts -u --user or username or submitter things, sometimes -l used for this (think l = login name) -V --version (uses uppercase V because lowercase v means verbose) -w a web-related thing, such as a URL -x and -X X11 things. Historically, the upper/lowercase meaning is reversed; lower is disable and upper is enable it -- this is opposite normal convention. -y --yes, take the affirmative or default action instead of prompting; also -y used to mean syslog -z --colorize-output -4 IPv4 -6 IPv6 -# Any numerical limit (avoid this tho, it causes problems in shell scripts)
And a defacto convention is that the lowercase form is used to invoke an action, while the uppercase form is used to suppress an action. For example,
-z (lowercase) typically means to colorize the output -Z (uppercase) means to NOT colorize the output, implying it's colorized by default.
But uppercase can also have conventional meanings, too. Such as -R for an alternate root.
—
These aren’t absolute, and there’s plenty of commands that don’t follow the above, but there’s more that do. If you’re writing a new utility or command, please try to follow the above! The community will thank you!