How to protect GRUB to avoid init=/bin/bash

Normally the GRUB bootloader of our computer enable any people to edit it and change the kernel command line to add “init=/bin/bash” and get irrestricted access to all files in your system.

Fortunately GRUB lets you to add a password to it as explained here:

All you need to do is edit your /boot/grub/grub.conf and add:

set superusers="root"
password_pbkdf2 root grub.pbkdf2.sha512.10000.biglongstring

Also you need to create a password’s hash using this command:

$ grub-mkpasswd-pbkdf2

Then replace the above “grub.pbkdf2.sha512.10000.biglongstring” with this generated hash.

But this solution is not good enough because it will prevent the GRUB menu editing but also will annoy you asking a password everytime you try to boot your system.

You can fix it adding “- – unrestricted” to menuentry in the grub.conf:

menuentry 'Debian GNU/Linux' ... --unrestricted {

That is all!

Getting started with RFM69

The RF transceivers RFM69 are really nice for low power applications. There are many projects using it currently.

It supports FSK, GFSK, MSK, GMSK and OOK modulations. Also it has AES and CRC-16 engines internally.

I decide to list some projects here as future reference.

First project is called RadioHead (no! it is not the music band). The main advantage of RadioHead is because it supports many types of transceivers (nRF24, CC1100, MRF89, etc) :

The second project is from LowPowerLab, it is devoted exclusively to RFM69 family:

Other project devoted to RFM69 is plainRFM69, this project has some optimization to enter on low power mode as soon os possible and doesn’t have all features from previous project:

There is an interesting thread from iwanders (Ivor Wanders is the author of plainRFM69) :

Another interesting project: Using a RFM69 to control a KaKu switch with OOK modulation:

I receive some RFM69HW modules (bought from Alibaba) and my plan is to use it with NuttX, this transceiver has many features, then creating a Network Driver is not so easy. The datasheet is here:

Running NuttX on Teensy 3.1

The PJRC Teensy 3.1 board is a very nice and powerful board. It has a small form-factor powered by NXP/Freescale MK20DX256 ARM Cortex-M4 microcontroller at 72MHz.

Normally it is used to run Arduino compatible sketches. Since I’m not a great Arduino fan the logic thing to do is run something else on it.

Fortunately NuttX has support to this board.

These are the steps I did to get it running:

1) Download the teensy loader for your platform:

$ gunzip teensy.64bit.gz 
$ mv teensy.64bit teensy_loader
$ chmod a+x teensy_loader
$ sudo cp teensy_loader /usr/local/bin/

3) Get the udev rules and copy it to right place:

$ wget
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1622 (1.6K) [text/plain]
Saving to: ‘49-teensy.rules’

49-teensy.rules                100%[=================================================>]   1.58K  --.-KB/s    in 0s      

2016-04-16 15:23:31 (47.7 MB/s) - ‘49-teensy.rules’ saved [1622/1622]

$ sudo cp 49-teensy.rules /etc/udev/rules.d/

3) Clone NuttX mainline bitbucket apps and nuttx repositories.

$ mkdir nuttx_teensy
$ cd nuttx_teensy
$ git clone
$ git clone

4) Compile NuttX to Teensy 3.1:

$ cd nuttx
$ cd tools/
$ ./ teensy-3.x/nsh
$ cd ..
$ make menuconfig
  Build Setup  --->
    Build Host Platform (Linux)  --->

$ make
LD: nuttx
make[1]: Leaving directory '/comum/workspace/NuttX/nuttx/nuttx/arch/arm/src'
CP: nuttx.hex
CP: nuttx.bin

5) Plug Teensy 3.1 on USB cable and press the board’s button.

6) Now run the teensy loader:

$ teensy_loader
File ->
  Open HEX File
    Select nuttx.hex

Click on Program icon Button it will program nuttx.hex in the board

7) Connect a USB/Serial 3.3V to Teensy 3.1 board, this way:

USB Serial | Teensy Board pin
   GND     |       GND
   TXD     |        0
   RXD     |        1

8) Run minicom or other serial console program
Configure it to use your USB/Serial port as 115200 8n1

Now in the teensy load program click on Reset icon Button, the NuttX shell will appear:

NuttShell (NSH)
nsh> ?
help usage:  help [-v] []

  [           cmp         free        mkfifo      set         unset       
  ?           dirname     help        mh          sh          usleep      
  basename    dd          hexdump     mv          sleep       xd          
  break       echo        kill        mw          test        
  cat         exec        ls          pwd         time        
  cd          exit        mb          rm          true        
  cp          false       mkdir       rmdir       uname       

Builtin Apps:

Moving all files and directories to a new subdirectory with a single command

This is a nice trick I learned today thank to this post.

If you are inside a directory with many files and subdirectories and you want to move everything to a new subdirectory you don’t need to move one-by-one, you can use this trick:

$ cd ~/Download
$ ls
fileA fileB fileC
dirAA dirBB dirCC
$ mkdir Download
$ shopt -s extglob
$ mv !(Download) Download

This command will move all files and directories to a new subdirectory, except the hidden files and directories (files/dir started with .something).

Use the dark side Luke (aka “resistance is futile”)

Today I received my HP LaserJet P1102w printer and decided to install it on Linux.
Using the USB cable was a piece of cake! I just ran “hp-setup -i” and it was done.

The WiFi configuration was a completely different history… The printer comes with an Install CD, but don’t expect it to have Linux support. Don’t be fool, don’t expect it from Hewlett-Packard (it is easy to forget your origin when you became rich!).

Searching in the internet forum I discovered all I need to do was to press the WiFi button and it will enable the Ad-Hoc mode. Then I should to press and hold the cancel (x) button until it prints the configuration information, including Ad-Hoc SSID. Ok I did it and received it: “Direct Print Name (SSID) = HP-Print-3D-LaserJet 1102”.

But unfortunately Debian Linux failed to connect to this Ad-Hoc network. It doesn’t appear in the wireless list, then I don’t know whether it as hidden or disabled. I tried to connect using many options, from command like using iw/ip tools, passing to wpa_supplicant to NetworkManager, nothing worked.

Then I decide to test running HpSetup.exe using Wine, but it didn’t work!

After spending more than two hours of my life to get it done, “I surrendered!!!”

Let use the dark side of force! I decided to test it on the free for test Win7 image offered by Microsoft (as explained here in portuguese:

Initially I was trying to figure-out how to instruct VirtualBox to use my physical CD/DVD driver to let Win7 to run HpSetup.exe, but then I realised it could be easy to use an ISO image working as CD disk:

$ sudo dd if=/dev/sr0 of=hpinstall.iso bs=4k

Then I plugged the print’ USB cable to my Debian box and enabled the VirtualBox to use it. Then initialized Win7 and ran HpSetup.exe configuration to connect to my Wireless Router. I spent less then 5 minutes to get it done!

Next time I will avoid buying a printer from HP or any other company that doesn’t support Linux. But how to find a company with good support for Linux?

Update: I just confirmed that Direct Print Ad-hoc networking doesn’t enable the HTTP server for printer configuration. Probably it was enabled in the past, but HP changed it for security reasons.

Converting a VirtualBox VDI image to real HD image

I’m using a small Slitaz distro to create a game machine, it is working fine, now I need to convert the dynamic hard disc VDI image to real raw disc image.

First I tried this command:

$ VBoxManage clonehd Slitaz.vdi /tmp/slitaz_hd.img --format RAW
VBoxManage: error: Cannot register the hard disk '/home/alan/VirtualBox VMs/Slitaz_user/Slitaz.vdi' {e5727c28-c490-49f7-8b23-xxxxxxxxxxxx} because a hard disk '/home/alan/VirtualBox VMs/Slitaz/Slitaz.vdi' with UUID {e5727c28-c490-49f7-8b23-xxxxxxxxxxxx} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 178 of file VBoxManageDisk.cpp

Because I’m using dynamic disc the above command didn’t work.

Now let to try other alternative:

$ VBoxManage internalcommands converttoraw Slitaz.vdi /tmp/slitaz_hd.img
Converting image "Slitaz.vdi" with size 4294967296 bytes (4096MB) to raw...

Great! Worked as expected:

$ ls -l /tmp/slitaz_hd.img
-rw------- 1 alan alan 4294967296 Mar 18 12:03 /tmp/slitaz_hd.img