tag:blogger.com,1999:blog-29277210987205427022024-03-13T08:58:04.224+10:00Linux Alephtips, tricks and hints for using the linux operating systemUnknownnoreply@blogger.comBlogger44125tag:blogger.com,1999:blog-2927721098720542702.post-84910264831276130662020-01-16T08:20:00.000+10:002020-01-16T08:20:02.903+10:00Disable Bluetooth on by default in Ubuntu MATE 18.04I'd like to have my laptop power up, have the Bluetooth system tray app (blueman) start, but not have the actual Bluetooth powered on by default.<br />
<br />
This was an easy change in the terminal:<br />
<br />
<b><span style="font-family: "Courier New", Courier, monospace;">gsettings set org.blueman.plugins.powermanager auto-power-on false</span></b><br />
<br />
Thanks to Arch Wiki for this: <a href="https://wiki.archlinux.org/index.php/Blueman">https://wiki.archlinux.org/index.php/Blueman</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-52987856292089406472018-05-07T22:21:00.000+10:002018-05-07T22:21:37.816+10:00Wifi latency using RALink RT3090 (rt2800pci)After updating to Ubuntu 18.04 Bionic, I found my RALink RT3090 wireless card using the <span style="font-family: "Courier New", Courier, monospace;"><b>rt2800pci</b></span> driver introduced latency. This was most noticeable as a delay while typing over SSH.<br />
<br />
This is because power management is enabled on the card, which puts it into sleep mode and it takes some time to wake up again.<br />
<br />
You can see the power management state of the card with:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><b>sudo iwconfig</b></span><br />
<br />
Amongst other things, this will show:<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><b>Power Management:on</b></span><br />
<br />
You can test whether disabling power management solves the problem with:<br />
<br />
<b><span style="font-family: "Courier New", Courier, monospace;">sudo iwconfig DEV power off</span></b><br />
<br />
Where DEV is the device name (eg: wlan0, wlp3s0)<br />
<br />
If this solves the problem, then apply the setting on boot. Edit the file <span style="font-family: "Courier New", Courier, monospace;"><b>/etc/NetworkManager/conf.d/default-wifi-powersave-on.conf</b></span> and change:<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><b>[connection]<br />wifi.powersave = 3</b></span><br />
<br />
So it reads:<br />
<br />
<b><span style="font-family: "Courier New", Courier, monospace;">wifi.powersave = 2</span></b>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-2927721098720542702.post-28488281782968517372017-05-04T22:54:00.001+10:002017-05-04T22:56:09.111+10:00Commandline auto-login in Ubuntu 16.04This is based on how <a href="https://github.com/RetroPie/RetroPie-Setup">RetroPie</a> does its autologin and autostart which you can find in <span style="font-family: "courier new" , "courier" , monospace;"><b>scriptmodules/supplementary/autostart.sh</b></span> in the RetroPie-Setup source.<br />
<br />
This works in Ubuntu and Raspbian, it probably works in any systemd distro.<br />
<br />
<b>mkdir -p /etc/systemd/system/getty@tty1.service.d/</b><br />
<br />
Create a file at <b>/etc/systemd/system/getty@tty1.service.d/autologin.conf</b> with contents:
<br />
<br />
<b>[Service]<br />ExecStart=<br />ExecStart=-/sbin/agetty --autologin USERNAME --noclear %I \$TERM</b><br />
<br />
Replace <b>USERNAME</b> with the actual username to login.<br />
<br />
You can now reboot and test this.<br />
<br />
If you want to start something on startup, then create a file <b>/etc/profile.d/10-runthing.sh</b> with contents like: <br />
<br />
<b>if [ "$(tty)" = "/dev/tty1" ]; then<br /> THING<br />fi</b><br />
<br />
Replace <b>THING</b> with the command to run. You could run <b>tmux</b> so you never forget. You could compile DOSBox so it runs on the framebuffer and you appear to have a DOS computer, which is why I wanted to do this. Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-2927721098720542702.post-22883997107318043232017-03-24T13:33:00.003+10:002017-03-24T13:34:11.905+10:003D Modelling Software on Ubuntu 16.04 (OpenSCAD, FreeCAD, gCAD3D, Blender)In addition to the previous post with 3D printer control software, you will likely want something to make models with!<br />
<br />
<h3>
OpenSCAD</h3>
<br />
This modeller uses a C-like programming language to create models. For example, to create a 20mm cube you type <b>cube([20,20,20]);</b><br />
<br />
Install with: <br />
<br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo add-apt-repository ppa:openscad/releases</span></b><br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo apt update</span></b><br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo apt install openscad</span></b><br />
<br />
<br />
Run with <b>openscad</b><br />
<br />
I also find the <b>scad-utils</b> repository to be useful, the <b>morphology</b> plugin has a fillet tool: <a href="https://github.com/openscad/scad-utils">https://github.com/openscad/scad-utils</a><br />
<br />
OpenSCAD website: <a href="http://www.openscad.org/">http://www.openscad.org/</a><br />
OpenSCAD documentation: <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language">https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language</a><br />
<br />
<h3>
FreeCAD</h3>
<br />
A graphical modeller. This has many more features than OpenSCAD though I don't like the interface as much. A good workflow might be to make shapes in OpenSCAD and then import into FreeCAD to polish.<br />
<br />
Install with:<br />
<br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo add-apt-repository ppa:freecad-maintainers/freecad-stable</span></b><br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo apt update</span></b><br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo apt install freecad </span></b><br />
<br />
Run with <b>freecad</b><br />
<br />
FreeCAD website: <a href="http://www.freecadweb.org/">http://www.freecadweb.org/</a><br />
FreeCAD documentation: <a href="https://www.freecadweb.org/wiki/Main_Page">https://www.freecadweb.org/wiki/Main_Page</a><br />
<br />
<h3>
gCAD3D</h3>
<br />
This looks like a simpler version of FreeCAD<br />
<br />
A <b>deb</b> package download is provided on the website for 32-bit and 64-bit.<br />
<br />
Once downloaded, install with:<br />
<br />
sudo dpkg -i gCAD3D*.deb<br />
<br />
Run with gcad3d<br />
<br />
gCAD3D website: <a href="http://www.gcad3d.org/">http://www.gcad3d.org/</a><br />
gCAD3D documentation: <a href="http://www.gcad3d.org/doc/html/index_en.htm">http://www.gcad3d.org/doc/html/index_en.htm</a><br />
<br />
<h3>
Blender</h3>
<br />
I have not played with this much yet, but it's very popular<br />
<br />
Install with: <br />
<br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo add-apt-repository ppa:thomas-schiex/blender</span></b><br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo apt update</span></b><br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo apt install blender</span></b><br />
<br />
Run with <b>blender</b><br />
<br />
Blender website: <a href="https://www.blender.org/">https://www.blender.org/</a><br />
Blender support and docs: <a href="https://www.blender.org/support/">https://www.blender.org/support/</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-32305409175958262932017-03-04T09:11:00.000+10:002017-03-24T08:09:14.866+10:003D Printing Software on Ubuntu 16.04 (Cura, Slic3r, Pronterface, Repetier Host)I recently got a cheap 3D printer and wanted to get started printing with Ubuntu. Some of the software is not so obvious to install, so here's how I got these popular applications going:<br />
<br />
<h3>
<b>Cura</b></h3>
<br />
Cura is available in the <a href="https://launchpad.net/~thopiekar/+archive/ubuntu/cura">https://launchpad.net/~thopiekar/+archive/ubuntu/cura</a> PPA. To install, just:<br />
<b><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></b>
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo add-apt-repository ppa:thopiekar/cura</span></b><br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo apt update</span></b><br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo apt install cura</span></b><br />
<br />
Launch with the <span style="font-family: "courier new" , "courier" , monospace;"><b>cura</b></span> command.<br />
<br />
Cura website: <a href="https://ultimaker.com/en/products/cura-software">https://ultimaker.com/en/products/cura-software</a><br />
<br />
<h3>
<b>Slic3r (Slicer)</b></h3>
<br />
The version in repos is the latest (1.2.9) at the time of writing, however the package is missing some dependencies. This installs all that's required:<br />
<br />
<b><span style="font-family: "courier new" , "courier" , monospace;">sudo apt install slic3r wx-common libopengl-perl libwx-glcanvas-perl</span></b><br />
<br />
Launch the GUI with the <span style="font-family: "courier new" , "courier" , monospace;"><b>slic3r --gui</b></span> command<br />
<br />
Slic3r website: <a href="http://slic3r.org/">http://slic3r.org/</a><br />
<br />
<h3>
<b>Pronterface (aka Printrun)</b></h3>
<br />
This requires <span style="font-family: "courier new" , "courier" , monospace;"><b>python-wxgtk2.8</b></span> which is removed in Ubuntu Xenial 16.04, and the replacement python-wxgtk3.0 does not work well with Printrun.<br />
<br />
There are some instructions around the internet suggesting to install the Wily 15.10 version, but that led to messy dependencies for me.<br />
<br />
Luckily, <a href="http://www.webupd8.org/">WebUpd8</a> package <span style="font-family: "courier new" , "courier" , monospace;"><b>python-wxgtk2.8</b></span> for 16.04 in their PPA, thanks!<br />
<br />
First, install the dependencies Printrun requires with: <br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><b>sudo add-apt-repository ppa:nilarimogard/webupd8<br />sudo apt update<br />sudo apt install python-serial python-wxgtk2.8 python-pyglet python-numpy cython python-libxml2 python-gobject python-dbus python-psutil python-cairosvg git</b></span><br />
<br />
Now change to the directory where you want the application to be and fetch the software with:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><b>git clone https://github.com/kliment/Printrun.git</b></span><br />
<br />
To run, change to the Printrun directory with <b><span style="font-family: "courier new" , "courier" , monospace;">cd Printrun</span></b> and run the <span style="font-family: "courier new" , "courier" , monospace;"><b>python pronterface.py</b></span> command.<br />
<br />
Pronterface website: <a href="http://www.pronterface.com/">http://www.pronterface.com/</a><br />
<br />
<h3>
<b>Repetier Host</b></h3>
<br />
This uses Mono to run the Windows binary, install requirements with:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><b>sudo apt install monodevelop libmono-system-serviceprocess4.0-cil</b></span><br />
<br />
Download and uncompress:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><b>tar xf repetierHostLinux_1_6_2.tgz</b></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><b>cd RepetierHost</b></span><br />
<br />
Run with:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><b>mono RepetierHost.exe</b></span><br />
<br />
Repetier Host website: <a href="https://www.repetier.com/">https://www.repetier.com/</a><br />
<br />Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-2927721098720542702.post-91594536250062108972016-08-13T15:02:00.000+10:002016-08-13T15:04:09.980+10:00DOSBox Full Screen with proper Scaling and Aspect RatioIt's quite confusing to get DOSBox to display games properly on modern hardware, partially because CRT monitors often displayed in non-square pixel modes, and partially because modern LCD displays don't scale well or support all the resolutions that CRTs did.<br />
<br />
This post discusses the settings required in <span style="font-family: "courier new" , "courier" , monospace;"><b>dosbox.conf</b></span> to get DOS games displaying well.<br />
<br />
<b>fullresolution</b><br />
<br />
Set this to your screen's native resolution such as <span style="font-family: "courier new" , "courier" , monospace;"><b>fullresolution=1920x1200</b></span><br />
<br />
<b>output</b><br />
<br />
The default <b><span style="font-family: "courier new" , "courier" , monospace;">surface</span></b> cannot scale, so set this to <span style="font-family: "courier new" , "courier" , monospace;"><b>output=overlay</b></span> which can scale. If you have a decent graphics card you could also try <span style="font-family: "courier new" , "courier" , monospace;"><b>output=openglnb</b></span><br />
<br />
<b>aspect</b><br />
<br />
Set <span style="font-family: "courier new" , "courier" , monospace;"><b>aspect=true</b></span> to ensure the game is not stretched<br />
<br />
<b>scaler</b><br />
<br />
Simple <span style="font-family: "courier new" , "courier" , monospace;"><b>scaler=none</b></span> will work, but you can experiment with the other scalers to see which performs well and which you like the look of.<br />
<br />
The full config options are described at <a href="http://www.dosbox.com/wiki/dosbox.conf">http://www.dosbox.com/wiki/dosbox.conf</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-28297007378655946202016-08-07T13:34:00.001+10:002016-08-07T13:34:21.708+10:00Another Steam Update breaks Ubuntu Xenial 16.04<br />
As of the recent Steam update, Steam will not launch and the following is displayed:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><b>$ steam</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>Setting up Steam content in /home/username/.local/share/Steam</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>Running Steam on ubuntu 16.04 64-bit</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>STEAM_RUNTIME is enabled automatically</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>Installing breakpad exception handler for appid(steam)/version(0)</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>libGL error: unable to load driver: r600_dri.so</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>libGL error: driver pointer missing</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>libGL error: failed to load driver: r600</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>libGL error: unable to load driver: swrast_dri.so</b></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>libGL error: failed to load driver: swrast</b></span><br />
<br />
You can fix it with:<br />
<br />
<b><span style="font-family: "Courier New",Courier,monospace;">mv .local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libstdc++.so.6 .local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libstdc++.so.6.old</span></b><br />
<b><span style="font-family: "Courier New",Courier,monospace;">mv .local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 .local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19.old</span></b><br />
<b><span style="font-family: "Courier New",Courier,monospace;">mv .local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libstdc++.so.6 .local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libstdc++.so.6.old</span></b><br />
<b><span style="font-family: "Courier New",Courier,monospace;">mv .local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libstdc++.so.6.0.19 .local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libstdc++.so.6.0.19.old</span></b><br />
<br />
This is yet another instance of the C++ libraries in the Steam Runtime not being compatible with the free software radeon driver for AMD (ATI) graphics cards:<br />
<br />
<a href="https://github.com/ValveSoftware/steam-for-linux/issues/3273">https://github.com/ValveSoftware/steam-for-linux/issues/3273</a><br />
<br />
I had a previous fix for this when they just packaged the i386 C++ library, but now they're packaging both the i386 and AMD64 C++ library, so my fix needed updating.<br />
<br />
If Valve package one more C++ library that'll be 3 separate libraries: Half-Life 3 confirmed.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-41252754565298516192015-12-07T11:36:00.001+10:002015-12-07T11:36:19.309+10:00Disable Promise FastTrack FakeRAID on CentOS 7I have a system with an onboard Promise FastTrack SATA RAID controller. This isn't a "real" RAID controller, but one which relies on the OS to perform some of the RAID work. This is commonly called "FakeRAID" and is not desirable.<br />
<br />
Despite setting the controller into AHCI Mode in the BIOS, I still get a disk called <b>/dev/mapper/pdc_abcdef</b> or similar and cannot use the disk <b>/dev/sdb</b> directly. I wanted the FakeRAID gone.<br />
<br />
The FakeRAID is managed by Device-Mapper RAID called "dmraid".<br />
<br />
An <a href="http://www.brandonchecketts.com/archives/disabling-dmraid-fakeraid-on-centos-5">old CentOS 5 post</a>
suggests removing the dmraid package might work, but this wanted to
remove anaconda and many other things, so didn't seem a good option.<br />
<br />
There is a kernel boot parameter to disable Device-Mapper RAID so I applied this.<br />
<br />
In <b>/etc/default/grub</b> add <b>nodmraid</b> to <b>GRUB_CMDLINE_LINUX_DEFAULT</b>:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">GRUB_CMDLINE_LINUX_DEFAULT="quiet rhgb nodmraid"</span><br />
<br />
Then re-create the GRUB2 configuration file:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">grub2-mkconfig -o /boot/grub2/grub.cfg</span><br />
<br />
Reboot, and no more FakeRAID drive. Success.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-11726664345225249822015-11-07T21:20:00.002+10:002015-11-07T21:20:26.979+10:00Unknown symbol __dynamic_pr_debugI was working with the default x86_64 + kvm kernel config and a kernel module which uses the <b>pr_debug()</b> printk logging method.<br />
<br />
On load, <b>modprobe</b> prints:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">FATAL: Error inserting modulename: Unknown symbol in module, or unknown parameter (see dmesg)</span><br />
<br />
And <b>dmesg</b> contains:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">Unknown symbol __dynamic_pr_debug</span><br />
<br />
I do have the <b>CONFIG_DYNAMIC_DEBUG=y</b> parameter set in my <b>.config</b>.<br />
<br />
I found reference to this upstream at: <a href="https://lkml.org/lkml/2012/8/30/378">https://lkml.org/lkml/2012/8/30/378</a> where Jim Crombie said "<i>Ok, transient error, went away with a clean build</i>".<br />
<br />
I'd done a <b>make; make modules_install; make install</b> and reboot but that didn't work for me.<br />
<br />
Like Jim found, a <b>make clean</b> then recompile worked for me.<br />
<br />
You need to mount debugfs to use <b>pr_debug()</b>, see <b>dynamic-debug-howto.txt</b> in the kernel Documentation directory.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-15504804488228910922014-06-01T09:29:00.001+10:002014-09-20T10:32:49.523+10:00kernel panic scsi_wait_scan on elrepo kernel-mlBrowsing around <a href="http://elrepo.org/">ELRepo</a>, you can see they have the <b>elrepo-kernel</b> repository which contains the long-life <b><a href="http://elrepo.org/tiki/kernel-lt">kernel-lt</a></b> (currently 3.10) and mainline <b><a href="http://elrepo.org/tiki/kernel-ml">kernel-ml</a></b> (currently 3.14) packages.<br />
<br />
I'd always been curious about these, so I spun up a test VM and did a CentOS 6 Basic Server install, then added ELRepo and installed them.<br />
<br />
<b>kernel-lt</b> works fine first time.<br />
<br />
However, <b>kernel-ml</b> will not boot, and simply repeats:<br />
<pre name="code" class="nobrush:plain">
FATAL: Module scsi_wait_scan not found.
</pre>
<a name='more'></a>
This was discussed on the upstream kernel bug tracker:<br />
<br />
<b>Bug 60758 - module scsi_wait_scan not found kernel panic on boot</b>
<a href="https://bugzilla.kernel.org/show_bug.cgi?id=60758">https://bugzilla.kernel.org/show_bug.cgi?id=60758</a><br />
<br />
As noted in that bug, the problem can be permanently resolved by adding a file like:<br />
<br />
<pre name="code" class="nobrush:plain">
echo 'add_drivers+="virtio_blk"' >/etc/dracut.conf.d/force-vitio_blk-to-ensure-boot.conf
</pre>
<br />
Then backup and rebuild the initramfs:<br />
<br />
<pre name="code" class="nobrush:bash">
cp /boot/initramfs-3.14.4-1.el6.elrepo.x86_64.img /boot/initramfs-3.14.4-1.el6.elrepo.x86_64.img.bak
dracut -f /boot/initramfs-3.14.4-1.el6.elrepo.x86_64.img 3.14.4-1.el6.elrepo.x86_64
</pre>
<br />
The root cause is that the virtio disk driver has changed from using <b>blk_init_queue()</b> in EL6 kernel to <b>blk_mq_init_queue()</b> in kernel 3.13 onwards, but the older EL6 dracut does not consider the latter symbol to be required for the storage drivers, so the initramfs is built without the storage driver.<br />
<br />
This was fixed on Fedora 20 <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1067669">Bug 1067669</a>, and has been cloned to RHEL6 <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1103455">Bug 1103455</a>.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-2927721098720542702.post-69511398616495601322014-03-16T14:07:00.000+10:002014-09-20T10:33:23.018+10:00hosting http and https domains with lighttpdI have two domains, one with an SSL certificate and one without. I wanted to host these on the same lighttpd server which only has one IP address. <br />
<br />
There are several forum threads and lighty wiki articles about this, but none really cover a concise example of how to do it. Many parts of the documentation are confusing and non-obvious, the situation is not helped by the fact that you cannot do name-based SSL hosting, so what you'd expect to be the logical configuration doesn't work.<br />
<br />
After staring at these for a few hours:<br />
<ul>
<li><a href="http://redmine.lighttpd.net/projects/lighttpd/wiki/docs_modredirect">Documentation: Module: mod_redirect</a></li>
<li><a href="http://redmine.lighttpd.net/projects/lighttpd/wiki/HowToRedirectWww">How to redirect www</a></li>
<li><a href="http://redmine.lighttpd.net/projects/lighttpd/wiki/HowToRedirectHttpToHttps">How to redirect http to https</a> </li>
<li><a href="http://redmine.lighttpd.net/projects/lighttpd/wiki/HowToSimpleSSL">Simple SSL configuration</a></li>
<li><a href="http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_SSL">Documentation: Secure HTTP</a></li>
</ul>
And a lot of trial-and-error, here's the config I ended up using:<br />
<a name='more'></a>
<pre>
$HTTP["scheme"] == "http" {
$HTTP["host"] =~ "(^|\.)without.com" {
server.name = "without.com"
server.document-root = "/var/www/without.com"
}
else $HTTP["host"] =~ "(^|\.)withssl.com" {
url.redirect = (".*" => "https://www.withssl.com$0")
}
}
$HTTP["scheme"] == "https" {
$SERVER["socket"] == "X.X.X.X:443" {
server.name = "withssl.com"
ssl.engine = "enable"
ssl.ca-file = "/etc/lighttpd/certs/ca-cert-class1.crt"
ssl.pemfile = "/etc/lighttpd/certs/withssl.com.crt"
server.document-root = "/var/www/withssl.com"
# mitigate BEAST attack
ssl.cipher-list = "ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4-SHA:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM"
# mitigate CVE-2009-3555
ssl.disable-client-renegotiation = "enable"
}
}
</pre>
<br />
The "X.X.X.X" needs to be your server's IP address, the same IP which the domain in your SSL cert resolves to.<br />
<br />
I haven't tested, but you could probably scale this up to host multiple non-SSL domains on the same host as the SSL domain. Hosting <a href="http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_SSL#SSL-on-multiple-domains">multiple SSL domains</a> is well-covered in the lighty documentation.<br />
<br />
The SSL cert and setup I did by following <a href="https://konklone.com/post/switch-to-https-now-for-free">Switch to HTTPS Now, For Free</a> over at Eric Mill's blog.<br />
<br />
When using lighttpd, you'll also need <a href="https://blog.maxux.net/?post/2012/12/27/startssl-with-multiple-domains-on-lighttpd">these instructions to make a unified certificate</a>.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-32080256751488829062014-02-04T17:15:00.000+10:002014-09-20T10:35:35.837+10:00realtek RTL8188CUS slow on Raspberry PiI recently had an adventure troubleshooting slow wifi on one of my Raspberry Pi systems. No matter what I did, I could not get more than 57 kilobytes per second transfer speed to it.<br />
<br />
<a name='more'></a>
First I tried different transfer methods (Samba and SSH) with no change, so it wasn't the transfer method.<br />
<br />
Then I tested the storage. I changed to a fast USB hard drive, moved the USB hard drive around the USB hub in case of power/throughput issues, but was eventually satisfied it wasn't storage when I could get 22 megabyte throughput with a <b>hdparm -t</b>. I should have just done that first.<br />
<br />
Next I suspected either USB or wifi.<br />
<br />
A lot of forum posts suggest to try <b>dwc_otg.speed=1</b> in <b>cmdline.txt</b> however that reduces the chipset to USB1 speeds (11Mb/sec) which wasn't a compromise I was willing to make. There was mention of something called FIQ from 2011/2012, but these improvements are included in the latest (2014-01-07) Raspbian image, so there's no need to tinker with FIQ anymore.<br />
<br />
I wondered if it was the wifi signal, so I moved the Pi right next to the router, but no change. I plugged in an ethernet cable and the speed improved immensely. So it was either USB or wifi.<br />
<br />
Searching around, I read many reports of people having problem with these Realtek RTL8188CUS (driver <b>8192cu</b>) wifi dongles. There were several suggestions to make a file like <b>/etc/modprobe.d/8192cu.conf</b> and turn off the adaptor's power management features with the contents:<br />
<br />
<pre>options 8192cu rtw_power_mgnt=0 rtw_enusbss=0</pre>
<br />
I tried this but still no luck, transfers still sat at 57kb/sec. <br />
<br />
At this point I remembered my other Raspberry Pi was using a different USB wifi adaptor, an RaLink RT5370 (driver <b>rt2800usb</b>). I tried this dongle and the speed instantly improved. We can now rule out USB and wifi signal, and place the blame on the wifi adaptor.<br />
<br />
I have two of these Realtek adaptors, a black one with EDUP on it, and a white one with COMFAST on it. Both produced the slow transfer speed, so it wasn't unique to this one adaptor.<br />
<br />
As best I can figure out, either Realtek's driver or the implementation of the wifi hardware is rubbish, and there's no way it can be fixed.<br />
<br />
I've ordered another RaLink dongle off eBay.Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-2927721098720542702.post-25077568853217372822013-11-21T19:49:00.000+10:002014-09-20T09:20:25.344+10:00yum grouplist doesn't display all groupsI've noticed in Fedora that the <b>yum grouplist</b> command doesn't actually display all the groups:<br />
<br />
<pre>
# yum grouplist | grep Virt
# yum grouplist | grep Virt | wc -l
0
</pre>
<br />
However you can still see a group with groupinfo:
<br />
<pre>
# yum groupinfo Virtualization
Loaded plugins: langpacks, list-data, presto, refresh-packagekit
Group: Virtualization
Group-Id: virtualization
Description: These packages provide a virtualization environment.
</pre>
<br />
Apparently there can be a "hidden" tag on groups, as reported in this Bugzilla entry:<br />
<br />
<a href="https://bugzilla.redhat.com/show_bug.cgi?id=986531"><b>Bug 986531 - unhide all groups from yum grouplist</b></a><br />
<br />
You can see all the groups with the <b>yum grouplist hidden</b> command:<br />
<br />
<pre>
# yum grouplist | wc -l
39
# yum grouplist hidden | wc -l
126
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-61315164802109861692013-11-13T02:19:00.000+10:002014-09-20T10:36:26.254+10:00how does mke2fs decide automatic check mount count?Whenever you create an ext3 or ext4 filesystem with <b>mkfs</b> or <b>mke2fs</b>, a message is printed saying "<b>This filesystem will be automatically checked every X mounts or Y days, whichever comes first</b>".<br />
<br />
However, the number seems to vary depending on the filesystem. How is this value calculated? I used the source of <b>e2fsprogs-1.42.8</b> and the <b>cscope</b> source code tool to find this out.<br />
<br />
<a name='more'></a>
Searching for the origin of the message, we can search for a short part of the string like "mounts or", and we see it's printed by this function in <b>misc/util.c</b>:<br />
<br />
<pre class="brush:c;gutter:true;first-line:281;">
void print_check_message(int mnt, unsigned int check)
{
if (mnt < 0)
mnt = 0;
if (!mnt && !check)
return;
printf(_("This filesystem will be automatically "
"checked every %d mounts or\n"
"%g days, whichever comes first. "
"Use tune2fs -c or -i to override.\n"),
mnt, ((double) check) / (3600 * 24));
}
</pre>
<br />
Which is called here in <b>misc/tune2fs.c</b>:<br />
<br />
<pre class="brush:c;gutter:true;first-line:628;">
/*
* Add a journal to the filesystem.
*/
static int add_journal(ext2_filsys fs)
{
</pre>
<pre class="brush:c;gutter:true;first-line:696;">
print_check_message(fs->super->s_max_mnt_count,
fs->super->s_checkinterval);
</pre>
<br />
So now we need to find what puts the value into <b>s_max_mnt_count</b>. Hunting for uses of that symbol, we see an equals sign here in <b>misc/mke2fs.c</b>:<br />
<br />
<pre class="brush:c;gutter:true;first-line:2440;">
if (get_bool_from_profile(fs_types, "enable_periodic_fsck", 0)) {
fs->super->s_checkinterval = EXT2_DFL_CHECKINTERVAL;
fs->super->s_max_mnt_count = EXT2_DFL_MAX_MNT_COUNT;
/*
* Add "jitter" to the superblock's check interval so that we
* don't check all the filesystems at the same time. We use a
* kludgy hack of using the UUID to derive a random jitter value
*/
for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
val += fs->super->s_uuid[i];
fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
</pre>
<br />
And we can see the <b>MAX_MNT_COUNT</b> is just a precompiler macro, defined in <b>lib/ext2fs/ext2_fs.h</b>:<br />
<br />
<pre class="brush:c;gutter:true;first-line:519;">
* Maximal mount counts between two filesystem checks
*/
#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
</pre>
<br />
So we take 20, add up all the ASCII characters of the UUID and modulo that by 20, then add it to the original 20. It's just maths from here. <b>20+(x%20)</b> gives an effective range of 20 to 39 days.<br />
<br />
We can also tell from the comment in <b>mke2fs.c</b> as to the reason behind this randomness.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-2347103173271372862013-08-29T23:17:00.002+10:002014-09-20T10:15:20.638+10:00finding the netdev_priv structIn addition to the <b>net_device</b> struct within the kernel, network drivers also have their own private or device-specific struct which stores stats unique to the individual hardware.<br />
<br />
The name of the struct varies for each device type, however the location remains the same, right after <b>net_device</b>:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"><b>linux-2.6.32-358.14.1.el6.x86_64/include/linux/netdevice.h</b></span>
<pre class="brush:c;gutter:true;first-line:1343;">
/**
* netdev_priv - access network device private data
* @dev: network device
*
* Get network device private data
*/
static inline void *netdev_priv(const struct net_device *dev)
{
return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN);
}
</pre>
A search in cscope for <b>netdev_priv</b> will show you many functions within drivers which update the priv structure via pointers, for example this one in <b>e1000_main.c</b>:<br />
<pre class="brush:c;">
struct e1000_adapter *adapter = netdev_priv(netdev);
</pre>
So, given that we know <i>what</i> the device-specific struct is called, and <i>where</i> the device-specific private struct is, how do you find it and read it?<br />
<br />
We'll need the ability to read kernel memory using <a href="http://people.redhat.com/anderson/crash_whitepaper/">crash</a>, either run on a live system, or in a vmcore captured with kdump:<br />
<pre class="brush:plain;">
crash /usr/lib/debug/lib/modules/2.6.32-358.14.1.el6.x86_64/vmlinux /var/crash/2013-08-26/vmcore
</pre>
We'll also need the debugging symbols for the driver in question:<br />
<pre class="brush:plain;">
crash> mod -s e1000 /usr/lib/debug/lib/modules/2.6.32-358.14.1.el6.x86_64/kernel/drivers/net/e1000/e1000.ko.debug
MODULE NAME SIZE OBJECT FILE
ffffffffa01550e0 e1000 170678 /usr/lib/debug/lib/modules/2.6.32-358.14.1.el6.x86_64/kernel/drivers/net/e1000/e1000.ko.debug
</pre>
The <b>net</b> command will show you the network devices in the system:<br />
<pre class="brush:plain;">
crash> net
NET_DEVICE NAME IP ADDRESS(ES)
ffff88007e76b820 lo 127.0.0.1
ffff8800372c0020 eth0 192.168.1.126
</pre>
We can then cast <b>net_device</b> against this to see the in-kernel device struct:<br />
<pre class="brush:plain;">
crash> net_device 0xffff8800372c0020
struct net_device {
name = "eth0\000\000\060:03.0\000\000\000",
...
</pre>
But we want to get <i>after</i> this struct and cast it against the struct in the driver.<br />
<br />
We need to know how big <b>net_device</b> is:<br />
<pre class="brush:plain;">
crash> struct -o net_device
struct net_device {
...
}
SIZE: 1728
</pre>
We then find the <b>net</b> address plus the size of <b>net_device</b>:<br />
<pre class="brush:plain;">
crash> px 0xffff8800372c0020+1728
$1 = 0xffff8800372c06e0
</pre>
We can now cast the device-specific private struct against this new address:<br />
<pre class="brush:plain;">
crash> e1000_adapter 0xffff8800372c06e0
struct e1000_adapter {
vlgrp = 0x0,
mng_vlan_id = 65535,
bd_number = 0,
rx_buffer_len = 1522,
...
</pre>
and we're done!Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-2927721098720542702.post-66089828925483120632013-07-09T21:56:00.000+10:002013-12-08T10:04:06.884+10:00akg perception 120 usb mic works on linuxI recently bought an <a href="http://www.akg.com/P120+USB-1039.html?pid=1030">AKG Perception 120 USB</a> microphone to do some voiceover work with.<br />
<br />
I couldn't find any reliable source which confirmed whether this works on Linux or not, so hopefully this post will help someone out.<br />
<br />
<b>This microphone works great on Linux.</b><br />
<br />
Not only that, it works great full stop. I was using a cheap headset before, and the difference in sound quality is incredible. I'm not any sort of audio expert or audiophile, though I can tell you the constant "hiss" that my old headset produced is eliminated with this new microphone.<br />
<br />
I tested using <b>Fedora 18</b> with <b>kernel 3.9.6-200</b> which worked fine.<br />
I also tried <b>Ubuntu 13.04</b> with <b>kernel 3.8.0-19</b> and that worked too.<br />
However, Ubuntu 12.04.3 with kernel 3.8.0-29 didn't work. It recognised the device but would not pick up sound.<br />
<br />
If you wonder about any specific distro, preferably one with a LiveCD, just leave a comment and I'll give it a try if I can.<br />
<br />
Here is the output of <b>lsusb</b> on F18 with the device connected:<br />
<br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"><b>Bus 001 Device 027: ID 074d:3556 Micronas GmbH Composite USB-Device</b></span></span><br />
<br />
Here is the output of <b>dmesg</b> on F18 as the device is connected:<br />
<br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"><b>usb 1-1.2: new full-speed USB device number 27 using ehci-pci<br />usb 1-1.2: New USB device found, idVendor=074d, idProduct=3556<br />usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0<br />usb 1-1.2: Product: AKG Perception 120 USB<br />usb 1-1.2: Manufacturer: AKG Acoustics<br />ALSA sound/usb/clock.c:243 current rate 0 is different from the runtime rate 48000<br />ALSA sound/usb/clock.c:243 current rate 0 is different from the runtime rate 48000<br />usbcore: registered new interface driver snd-usb-audio<br />ALSA sound/usb/clock.c:243 current rate 48000 is different from the runtime rate 44100<br />ALSA sound/usb/clock.c:243 current rate 48000 is different from the runtime rate 44100</b></span></span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-2927721098720542702.post-70770929888198911772013-07-02T15:13:00.001+10:002014-09-20T10:08:07.478+10:00how to display tcp rtoCalculating the <a href="http://tools.ietf.org/html/rfc6298">TCP Retransmission Timeout</a> always makes my head explode, yet it can be useful when troubleshooting TCP algorithms like FRTO or TIME_WAIT timeout when TCP Timestamps are in use.<br />
<br />
This excellent post by sgros gives a very thorough overview of the RTO algorithms in the kernel and how RTO is actually calculated:<br />
<ul>
<li><a href="http://sgros.blogspot.com/2012/02/calculating-tcp-rto.html">http://sgros.blogspot.com/2012/02/calculating-tcp-rto.html</a></li>
</ul>
However, I don't want to do that, and I certainly don't want to do it for every socket in realtime. Is there an easy way to display the RTO for every socket?<br />
<br />
There sure is:
<pre class="brush:plain">
ss -i
</pre>
The <b>-i</b> option of <b>ss</b> is the flag to "Show internal TCP information", check <b>man ss</b> for more options.<br />
<br />
Here's an example of a socket on my system including its RTO:<br />
<br />
<pre class="brush:plain">
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 10.99.0.123:51308 192.168.34.111:http
cubic wscale:6,7 rto:660 rtt:396/38.75 ato:40 cwnd:10 send 272.3Kbps rcv_space:14600
^^RTO^^
</pre>
<b>ss</b> is one of the "next generation" <b>iproute2</b> commands to replace the older <b>netstat</b>. Much like <b>ip addr</b> has replaced ifconfig, <b>ip route</b> has replaced route, and <b>ip neigh</b> has replaced arp.Unknownnoreply@blogger.com7tag:blogger.com,1999:blog-2927721098720542702.post-47555811408964130262013-01-16T08:23:00.001+10:002014-09-20T10:03:47.942+10:00how to network jumbo frames to a kvm guestGetting a <a href="http://en.wikipedia.org/wiki/Jumbo_frame">jumbo frame</a> to a KVM guest is not something which works out of the box, but can be configured to work quite easily.<br />
<br />
One way get jumbo frames to a KVM guest is to directly pass the guest a physical NIC through PCI Passthrough, or a Virtual Function through SR-IOV.<br />
<br />
Another way is to use the traditional <a href="http://wiki.libvirt.org/page/Networking#Bridged_networking_.28aka_.22shared_physical_device.22.29">libvirt bridge</a>. Create a bridge on the host, and bridge the guest's NICs into this. The reason this doesn't work by default is all the interfaces are created with the default Ethernet MTU of 1500 bytes.<br />
<br />
You can set MTU of the physical NIC, the bridge, and the guest interface with the network-scripts, but you cannot automatically set the MTU of the tap interface with the network-scripts. The tap interface is how the virtual network interface connects to the "real world". You'll see these tap devices with names like "<b>vnet0</b>" in your bridge.<br />
<br />
So how do we do this?<br />
<br />
First, some requirements:<br />
<ul>
<li><b>A physical interface which supports jumbo frames.</b><br />The Linux bridge code will only allow the bridge to change to the smallest MTU of all its interfaces.</li>
<li><b>A bridge with the larger required MTU</b><br />Technically a jumbo frame covers MTU from 1501 to 9000, but almost everyone just wants to set 9000<b><br /></b></li>
<li><b>virtio-net or Intel e1000 network interface inside the guest</b><br />The real-life Realtek 8139 does not support an MTU of 9000, therefore there is no driver support for large MTU in the emulated version either.</li>
</ul>
Our first step is to make all tap interfaces on the host have an MTU of 9000. We do this by adding a udev rule to the top of the network device creation as follows:<br />
<br />
<b>/etc/udev/rules.d/70-persistent-net.rules</b> (on host)<br />
<pre class="brush:plain;">
SUBSYSTEM=="net", ACTION=="add", KERNEL=="vnet*", ATTR{mtu}="9000"
</pre>
Then set your physical interface MTU to 9000:<br />
<br />
<b>/etc/sysconfig/network-scripts/ifcfg-eth0</b> (on host):<br />
<pre class="brush:bash;">
DEVICE=eth0
HWADDR=[physical MAC address]
TYPE=Ethernet
ONBOOT=yes
BRIDGE=br0
MTU=9000
</pre>
And do the same inside the bridge:<br />
<br />
<b>/etc/sysconfig/network-scripts/ifcfg-br0</b> (on host)<br />
<pre class="brush:bash;">
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
DELAY=0
MTU=9000
</pre>
Now inside your guest, set your virtio or e1000 interface to also have the larger MTU:<br />
<br />
<b>/etc/sysconfig/network-scripts/ifcfg-eth0</b> (in guest)<br />
<pre class="brush:bash;">
DEVICE=eth0
HWADDR=[guest MAC address]
TYPE=Ethernet
ONBOOT=yes
MTU=9000
</pre>
You'll need to perform a "<b>service network restart</b>" on the host, or at least bring the bridge and eth interfaces down and up. Start your guest and confirm all interfaces have been made with the correct MTU:<br />
<pre class="brush:plain;">
# ip link
2: eth0: mtu 9000 qdisc pfifo_fast state UP qlen 1000
link/ether 01:23:45:67:89:0A brd ff:ff:ff:ff:ff:ff
3: br0: mtu 9000 qdisc noqueue state UNKNOWN
link/ether 01:23:45:67:89:0A brd ff:ff:ff:ff:ff:ff
4: vnet0: mtu 9000 qdisc pfifo_fast state UNKNOWN qlen 500
link/ether fe:54:00:01:23:45 brd ff:ff:ff:ff:ff:ff
</pre>
This should be enough to send a "Do Not Fragment" 9000 byte frame over the network. Let's test with a ping:<br />
<pre class="brush:plain;">
# ping -c 4 -s 8972 -M do 172.16.0.2
PING 172.16.0.2 (172.16.0.2) 8972(9000) bytes of data.
8980 bytes from 172.16.0.2: icmp_seq=1 ttl=64 time=1.27 ms
8980 bytes from 172.16.0.2: icmp_seq=2 ttl=64 time=0.284 ms
8980 bytes from 172.16.0.2: icmp_seq=3 ttl=64 time=0.202 ms
8980 bytes from 172.16.0.2: icmp_seq=4 ttl=64 time=0.260 ms
</pre>
Success!Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-2927721098720542702.post-9212433146930399132012-08-05T10:27:00.005+10:002014-09-20T09:59:09.417+10:00how to persist ethtool settings across rebootYou can use the <b>ethtool</b> command to read and change information about your network interfaces.<br />
<br />
For example, <b>ethtool -g ethX</b> reads the size of the <a href="http://en.wikipedia.org/wiki/Circular_buffer">ring buffer</a> on the NIC, and <b>ethtool -G ethx rx A tx B</b> changes it. Use <b>man ethtool</b> to discover more settings.<br />
<br />
But these options don't persist across reboot, so how do you make sure your settings are kept permanent?<br />
<br />
You can enter the ethtool commands in <b>/etc/rc.local</b> (or your distribution's equivalent) where commands are run after the current runlevel completes, but this isn't ideal. Network services may have started during the runlevel and ethtool commands tend to interrupt network traffic. It would be more preferable to have the commands applied as the interface is brought up.<br />
<br />
The <b>network</b> service in CentOS has the ability to do this. The script <b>/etc/sysconfig/network-scripts/ifup-post</b> checks for the existence of <b>/sbin/ifup-local</b>, and if it exists, runs it with the interface name as a parameter (eg: <b>/sbin/ifup-local eth0</b>)<br />
<br />
We can create this file with <b>touch /sbin/ifup-local</b> make it executable with<b> chmod +x /sbin/ifup-local</b> set its SELinux context with <b>chcon --reference /sbin/ifup /sbin/ifup-local</b> and then open it in an editor.<br />
<br />
A simple script to apply the same settings to all interfaces would be something like:<br />
<pre class="brush:bash;gutter:true;">
#!/bin/bash
if [ -n "$1" ]; then
/sbin/ethtool -G $1 rx 4096 tx 4096
/sbin/ethtool -K $1 tso on gso on
fi
</pre>
Keep in mind this will attempt to apply settings to ALL interfaces, even the loopback.<br />
<br />
If we have different interfaces we want to apply different settings to, or want to skip the loopback, we can make a <b>case</b> statement:<br />
<pre class="brush:bash;gutter:true;">
#!/bin/bash
case "$1" in
eth0)
/sbin/ethtool -G $1 rx 16384 tx 16384
/sbin/ethtool -K $1 gso on gro on
;;
eth1)
/sbin/ethtool -G $1 rx 64 tx 64
/sbin/ethtool -K $1 tso on gso on
/sbin/ip link set $1 txqueuelen 0
;;
esac
exit 0
</pre>
Now ethtool settings are applied to interfaces as they start, all potential interruptions to network communication are done as the interface is brought up, and your server can continue to boot with full network capabilities. Unknownnoreply@blogger.com13tag:blogger.com,1999:blog-2927721098720542702.post-9475144659097905042012-08-04T08:26:00.001+10:002012-08-04T08:26:47.721+10:00kvm virtual machine won't startRecently I brought my KVM host down for an upgrade. I shut down the guests within their OSes, confirmed they were powered off with a <b>virsh list --all</b>, and everything went well with the upgrade.<br />
<br />
However, upon returning the guests to service, one of them would not start up. Typing <b>virsh start</b> I got the helpful error message<br />
<br />
<b>Error restoring domain: cannot send monitor command</b><br />
<b>Connection reset by peer</b><br />
<br />
Why was this one VM broken but the others were fine?<br />
<br />
I played around with <b>virsh autostart</b> and <b>virsh autostart --disable</b> but that had no effect, nor did a reboot of the hypervisor.<br />
<br />
After some searching around, it turns out libvirt has the capability to keep "managed save states" of guests, kinda like a sleep mode or snapshot, to save you fully powering a guest OS off.<br />
<br />
For some reason, a managed save for this one guest had been created, perhaps it had not shut down properly, or perhaps there's an errorr in libvirt. I could view the saved state with<br />
<br />
<b># virsh list --all --managed-save<br /> Id Name State<br />----------------------------------<br /> - guest1 shut off<br /> - guest2 saved</b><br />
<br />
Now a <b>virsh managedsave-remove guest2</b> returned it to the "<b>shut off</b>" state, and I could start it properly with <b>virsh start</b> as per usual.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-73702002676250658882012-06-20T09:33:00.000+10:002012-06-20T09:34:23.978+10:00grub2 usb keyboard not workingI installed the newly released <a href="http://fedoraproject.org/wiki/Releases/17">Fedora 17</a> this week, only to find I could no longer control the GRUB2 screen to get into Windows to play some games. The keyboard and mouse work perfectly in BIOS, and in Linux once USB drivers are loaded, just not at the GRUB2 screen.<br />
<br />
Many forum threads exist for this, most pointing towards the "USB Legacy" or similar option in the BIOS. I had this turned on, however turning it off made no difference either.<br />
<br />
GRUB2 can load some driver modules, so perhaps it wasn't loading the USB modules. Adding <b>GRUB_PRELOAD_MODULES="usb usb_keyboard ehci ohci uhci"</b> to <b>/etc/default/grub</b> and then rebuilding the config files with <b>grub2-mkconfig -o /boot/grub2/grub.cfg</b> didn't change anything either.<br />
<br />
At this point I started coming across articles mentioning <a href="http://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface">UEFI</a> support for GRUB2. UEFI is the "new BIOS" standard coming out on new motherboards. My motherboard is a fairly new model, so it does have EFI firmware.<br />
<br />
Turns out the solution is to install a version of GRUB2 with EFI support. This was done with <b>yum install grub2-efi</b> to install the package, then <b>grub2-efi-install /dev/sda</b> to install the EFI-supporting bootloader onto my hard drive. I regenerated a new config with <b>grub2-efi-mkconfig -o /boot/grub2/grub.cfg</b> while I was at it.<br />
<br />
Now my USB keyboard works perfectly in GRUB2.Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-2927721098720542702.post-27098951223966317832012-04-26T21:49:00.001+10:002012-04-26T21:51:10.976+10:00su to root without a passwordI'm sick of typing the root password every time I want to <b>su -</b> on Fedora to become the root user. I know how to allow <b>sudo</b> access without a password, but I don't want to use sudo, I want to be able to just type <b>su -</b> and become root.<br />
<br />
I couldn't find a good answer for this on Google, so I read the man pages of <b>pam</b> (Pluggable Authentication Modules) until I figured it out.<br />
<br />
In the file <b>/etc/pam.d/su</b> put this as the second line:<br />
<br />
<b>auth sufficient pam_permit.so</b><br />
<br />
This is incredibly insecure as it lets literally anyone at all with a login become root.<br />
<br />
To restrict this just to your username, use this line instead, replace the <b>yourusername</b> with your actual username:<br />
<br />
<b>auth sufficient pam_succeed_if.so use_uid user = yourusername</b><br />
<br />
You can also restrict this to a group, here the group <b>allowedpeople</b> can su without a password:<br />
<br />
<b>auth sufficient pam_succeed_if.so use_uid user ingroup allowedpeople</b>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2927721098720542702.post-11715786841978333252012-04-21T22:51:00.003+10:002012-05-14T23:58:16.099+10:00starting rtorrent on system startuprTorrent is a curses-based bittorrent client for Linux.<br />
<br />
It's very light on system resources but has great features such as monitoring of a directory for .torrent files, auto-move based on status (incoming, seeding, complete, etc), categories, magnet link handling and RSS capabilities.<br />
<br />
I have a headless system where I seed some (legal) torrents and wanted rTorrent to start up when the system did. There are <a href="http://libtorrent.rakshasa.no/wiki/RTorrentCommonTasks#StartingrTorrentonSystemStartup">some examples</a> of init scripts on the rTorrent site but I didn't like how these ran, specifically the <span style="font-family: "Courier New",Courier,monospace;"><b>su</b></span> constantly needing a password and the odd way it started <a href="http://www.gnu.org/software/screen/">GNU Screen</a>.<br />
<br />
<b>Download</b><br />
<ul>
<li><a href="https://github.com/superjamie/rtorrent-init-script">https://github.com/superjamie/rtorrent-init-script</a></li>
</ul>
<b>Installation</b><br />
<ul>
<li>Put it at <b><span style="font-family: "Courier New",Courier,monospace;">/etc/init.d/bittorrent</span></b> and make it executable<br /><b><span style="font-family: "Courier New",Courier,monospace;">chmod +x /etc/init.d/bittorrent</span></b></li>
<li>Add to chkconfig<br /><b><span style="font-family: "Courier New",Courier,monospace;">chkconfig --add bittorrent</span></b></li>
<li>Set to start on system startup<br /><b><span style="font-family: "Courier New",Courier,monospace;">chkconfig bittorrent on</span></b></li>
<li>If you want non-root users to be able to control it, put this in your <b><span style="font-family: "Courier New",Courier,monospace;">visudo</span></b>, replace "username" with your non-priveledged username<br /><b><span style="font-family: "Courier New",Courier,monospace;">username localhost=NOPASSWD:/etc/init.d/bittorrent*</span></b></li>
<li>Setup an alias to the script in the user's <span style="font-family: "Courier New",Courier,monospace;"><b>~/.bashrc</b></span><br /><span style="font-family: "Courier New",Courier,monospace;"><b>alias bittorrent='/etc/init.d/bittorrent'<br />alias bt='bittorrent'</b></span></li>
</ul>
<b>Requirements</b><br />
<ul>
<li>CentOS 6 or Fedora 12-14. Probably also works on CentOS 5.</li>
<li>screen and rtorrent</li>
<li>A non-priveledged user to run rtorrent, this can either be a new user just to run torrents, or an existing user</li>
<li>Absolute session path in the <span style="font-family: "Courier New",Courier,monospace;"><b>.rtorrent.rc</b></span> file<br /><span style="font-family: "Courier New",Courier,monospace;"><b>session = /home/rtorrent/.session ## this is good<br />session = ~/.session ## this will break<br />session = .session ## so will this</b></span></li>
<li>Paths for other actions such as monitoring directories for .torrent files and auto-moving complete downloads don't have to be absolute.</li>
</ul>
<b>Usage</b><br />
<ul>
<li>Control the daemon with<span style="font-family: "Courier New",Courier,monospace; font-size: small;"><b>bittorrent start, bittorent stop, bittorrent restart</b></span></li>
<li>Get information about the daemon with<br /><span style="font-family: "Courier New",Courier,monospace;"><b>bittorrent status, bittorrent info</b></span></li>
<li>Connect to the screen session with<br /><span style="font-family: "Courier New",Courier,monospace;"><b>bittorrent connect</b></span><br />(press ctrl+a then d to disconnect)</li>
</ul>
<b>Licensing</b><br />
<ul>
<li>Released under GNU GPL v3 - <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a></li>
</ul>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-2927721098720542702.post-49265304058206551522012-04-21T22:27:00.002+10:002014-05-05T22:14:21.835+10:00starting minecraft server on system startupThis is an initscript to run a Minecraft or CraftBukkit server on CentOS, Fedora, and Ubuntu.<br />
<br />
<b>Features</b><br />
<ul>
<li>Start, stop, restart CraftBukkit as a system service</li>
<li>Automatic (via cron) and manual logfile rotation</li>
<li>Automatic (via cron) and manual backups</li>
<li>Backup compression and rotation (keeps 7 days worth of backups)</li>
<li>Check latest Recommended Build and update to it if required</li>
<li>Information display including Java path, current memory usage, current TCP connections</li>
<li>Able to run multiple separate instances of the server at once</li>
</ul>
<b>Supported Distributions</b><br />
<ul>
<li>CentOS 6, CentOS 5, Fedora 14<br />(probably works on Fedora Core 6 and later, untested)</li>
<li>Ubuntu Server 12.04 LTS</li>
</ul>
Other distros which use SysV Init or Upstart (Debian, Mint) will probably work.<br />
Distros using systemd (Fedora 15+, Arch Linux, etc) will not work.<br />
<br />
<b>Get the script, view Requirements, Installation, Backups, Multiple Instances, and Usage</b><br />
<ul>
<li><a href="https://github.com/superjamie/minecraft-init-script">https://github.com/superjamie/minecraft-init-script</a></li>
</ul>
<b>License</b><br />
<br />
Released under GNU GPL v3 - http://www.gnu.org/licenses/ <br />
<br />
<b>Credits</b><br />
<br />
Thanks to these people whose work I have used in the making of this<br />
<ul>
<li><a href="http://forums.bukkit.org/threads/tutorial-centos-bukkit-installation.56371/">http://forums.bukkit.org/threads/tutorial-centos-bukkit-installation.56371/</a></li>
<li><a href="http://www.minecraftwiki.net/wiki/M3tal_Warrior_Server_Startup_Script">http://www.minecraftwiki.net/wiki/M3tal_Warrior_Server_Startup_Script</a></li>
<li><a href="http://forums.bukkit.org/threads/admin-linux-init-script-for-bukkit.53235/">http://forums.bukkit.org/threads/admin-linux-init-script-for-bukkit.53235/</a></li>
</ul>
Unknownnoreply@blogger.com29tag:blogger.com,1999:blog-2927721098720542702.post-52699644872260723382012-04-21T22:19:00.000+10:002012-05-15T00:02:52.871+10:00The State of the LinuxIt's been a while since I've posted but I'm still around. I started this blog as a sharing of tips and fixes I which used and couldn't find anywhere else. I've easily found most things I've wanted to do in the last few years so I haven't had the need to make much noise.<br />
<br />
Today I'm here to write about the state of desktop Linux as I see it, compared to when this blog started in 2008 and I was obviously using <a href="http://www.ubuntu.com/">Ubuntu</a>.<br />
<br />
These days I am a <a href="http://fedoraproject.org/">Fedora</a> user. This was mostly brought about by starting to use <a href="http://www.redhat.com/products/enterprise-linux/">RHEL</a> at work and the need to become familiar with regular use of the RPM-based distro. I've also changed all my own servers over to <a href="http://www.centos.org/">CentOS</a>.<br />
<br />
Fedora's okay. Some people may deny this, but I think it's obviously a dumping ground for features Red Hat want to try, or to have the Fedora community crowdsource most of the initial testing and bugfixing before doing their own QA for inclusion in RHEL.<br />
<br />
Fedora's near-bleeding-edge package cycles, still with a focus on stability, is both its strength and its weakness. It's great having <a href="http://www.kernel.org/">the kernel</a> or <a href="http://www.winehq.org/">Wine</a> updated in-distro within a week of new major upstream releases. It's frustrating having to deal with "latest and greatest" features I dislike such as <a href="http://www.gnome.org/">GNOME 3</a> and <a href="http://www.freedesktop.org/wiki/Software/systemd">systemd</a>. I generally find <a href="http://yum.baseurl.org/">Yum</a>/<a href="http://rpm.org/">rpm</a> to be greatly messy and inferior compared to <a href="http://wiki.debian.org/Apt">apt</a>.<br />
<br />
GNOME 3 is probably the largest thing to happen to desktop Linux in the last few years. It was met with such a hugely negative response and such polarising opinions that sites are <i>still</i> running polls about it. I think the developers made a mistake, sticking their head in the sand and telling users that the forced paradigm shift to Gnome Shell was what they wanted, despite the fact many people said they didn't.<br />
<br />
Many Linux users appear to be seeking alternatives to Gnome Shell and all the competing Desktop Environments (<a href="http://www.kde.org/">KDE</a>, <a href="http://www.xfce.org/">XFCE</a>, <a href="http://lxde.org/">LXDE</a>) have probably seen an increase in user base. <a href="http://linuxmint.com/">Linux Mint</a> listened to their users and pursued the <a href="http://mate-desktop.org/">MATE</a> fork of GNOME 2, then created the <a href="http://cinnamon.linuxmint.com/">Cinnamon Desktop</a>. This fulfilling of majority demand has pushed them to the top of <a href="http://distrowatch.com/">Distrowatch</a> and kept them there. Kudos to the Mint Team for putting their money where their mouth is.<br />
<br />
Ubuntu chose <a href="http://unity.ubuntu.com/">Unity</a> over Gnome Shell. I've tried Unity several times and have been disgusted by it. It's so un-useable that I consider it just plain broken. I think it's pushing Ubuntu into irrelevance and their declining rating on Distrowatch tends to agree.<br />
<br />
Mint used to be based on Ubuntu and have now started offering a re-base on <a href="http://www.debian.org/">Debian</a>. <a href="http://crunchbanglinux.org/">CrunchBang</a> also used to be based on Ubuntu and has switched to Debian altogether. Ubuntu's own variants Kubuntu and Xubuntu have fallen from sponsored releases to just "officially recognised" community projects.<br />
<br />
I considered Ubuntu to be the king of Linux distros for a long time, but its reign is now well and truly over.<br />
<br />
One interesting distro I saw on a magazine is <a href="http://www.fuduntu.org/">Fuduntu</a>. The name is ridiculous but the product itself is worth a look. It's a fork of Fedora 14 which has gone rolling-release. It still runs GTK2 and SysV Init but incorporates the latest 3.x kernel series. It has a smaller package set than Fedora and runs a Mac-like desktop environment based around a top-of-screen Gnome Panel and <a href="https://launchpad.net/awn/">Avant Window Navigator</a>.<br />
<br />
My own desktop these days is <a href="http://openbox.org/">Openbox</a> with <a href="http://code.google.com/p/tint2/">tint2</a> panel, a minimalist throwback from my days as an <a href="http://www.archlinux.org/">Arch Linux</a> user.<br />
<br />
Arch itself is a good distro with a great community, full of positive helpful people, few (if any) jerks, and little politics. However, I found myself spending around a quarter of my computer time just maintaining my system, rather than using the computer to do other things. Arch is something all Linux enthusiasts should do once for a period of time, the amount of tinkering and low-level micro-management required is educational and improves your Linux skills, but I feel it also is very much "using Linux for the sake of using Linux".<br />
<br />
There seems to be a big paradigm shift happening all over desktops these days. Unity and GNOME 3 led for Linux and seem to have failed, Microsoft have shown their Metro interface which must be a bad joke. It's as if the development world has suddenly and unanimously decided the "menu and taskbar" interface which began with Windows 95 is no longer good enough, but nobody's come up with a suitable replacement, except perhaps Cinnamon.<br />
<br />
Which desktop eventually wins out is still anyone's guess. Mint has shown that it's not necessarily the big corporate-backed developers who set the trend. Maybe we will never see one true new standard environment and modular personalised DEs will be the order of the day.Unknownnoreply@blogger.com0