High Performance USB stick formatting with ext4

To format my USB sticks that I use following set of commands:

Assuming my USB stick is recognized as sdc, and has a primary partition created this is the set of commands that I use:

# create ext4 filesystem without journal
mkfs.ext4 -O ^has_journal /dev/sdc1

# give your newly formatted partition a name
e2label /dev/sdc1 storage

# Use data mode for filesystem as writeback for better performance
tune2fs -o journal_data_writeback /dev/sdc1

# Disable reserved space on my 57GB drive it wastes 5% which is 3GB
tune2fs -m 0 /dev/sdc1

Pine64 2GB DDR3 SDRAM, 10/100/1000 MB Ethernet port unpacking and quick review

Even though in my mid May post I said I will not go into future endeavors with low cost devices this one I have ordered long time ago (April 2016) and it was delayed with shipping.

Pine64 looked interesting and promising since they raised $1.7M on Kickstarter offered 3 different variants for affordable price.

Allwinner is awful with their open source support so you will not be using this device for your next media center since Kodi will not work, but since it has 2GB RAM and 1Gb Ethernet it seems perfect fit for a small home server.

I ordered 2GB model for 29$ + 12$ for shipping with tracking number. I opted out of WiFi+Bluetooth module since I was more interested in using gigabit Ethernet port. Also on my Raspberry Pi 3 which I use as my main media player I almost never use WiFi and Bluetooth. Those are good additions, but if they come with the device.

Order was done on their homepage and promised to be shipped in May, but all their shipping was heavily delayed. I received mine end of June after many inquiries on their forum since their communication with customers is almost non-existing.

Here are my unboxing pictures of the device. Packaging is okay, device is almost double in size when compared to Raspberry Pi.

 

DSC_2293 DSC_2294 DSC_2295 DSC_2296 DSC_2297 DSC_2298 DSC_2299 DSC_2300 DSC_2301 DSC_2302

You will need 2A+ micro USB charger and micro-SD card to get this working.

I downloaded DietPi image and copied it to 16GB Toshiba micro-SD and it worked out of the box as expected.

One thing I am currently testing and trying to fix is Ethernet port which is giving me slow speeds in one direction.

Here is my ethtool output which clearly states that it is using 1Gb full duplex speed:

ethtool eth0
Settings for eth0:
       Supported ports: [ TP MII ]
       Supported link modes:   10baseT/Half 10baseT/Full
                               100baseT/Half 100baseT/Full
                               1000baseT/Half 1000baseT/Full
       Supported pause frame use: No
       Supports auto-negotiation: Yes
       Advertised link modes:  1000baseT/Full
       Advertised pause frame use: No
       Advertised auto-negotiation: Yes
       Speed: 1000Mb/s
       Duplex: Full
       Port: MII
       PHYAD: 0
       Transceiver: external
       Auto-negotiation: on
       Link detected: yes

But when I test it with iperf I get pretty strange results:

iperf -c 192.168.254.1 -t 30 -d
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 192.168.254.1, TCP port 5001
TCP window size: 49.6 KByte (default)
------------------------------------------------------------
[  5] local 192.168.254.2 port 50784 connected with 192.168.254.1 port 5001
[  4] local 192.168.254.2 port 5001 connected with 192.168.254.1 port 49709
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-30.0 sec  2.64 GBytes   754 Mbits/sec
[  5]  0.0-30.1 sec  8.75 MBytes  2.44 Mbits/sec

I get a lot of retransmited packets:

netstat -s |grep retransmited
   23122 segments retransmited

I tried two different power sources one 2A and one 2.5A, different Cat5e cables and switched ports on the switch. Nothing helped.

If I get this resolved Pine64 could be great for small home server.

OrangePi poor replacement for the real Raspberry Pi

I was intrigued with low price of Orange Pi PC on GearBest site and since I had a lot of unused points I decided to order one even though I did not really need it. For a few bucks you get quad core CPU, 1GB of RAM, Ethernet all the bells and whistles as Raspberry Pi for third of the price.

What could go wrong? Well it seems for this price you get what you paid for a third of quality manufacturing. As soon as I opened my box I noticed that the board is slightly bent as you can see on the picture here:
opi1

Board itself is not quality made and not sturdy enough. It seems that this was either error in manufacturing or shipping. I thought well it is not broken, all the pieces are there, it could work.

I have downloaded three different images for the Orange Pi, official one from their site, and two from loboris that I found on their forum as proven to work.

As soon as I applied power something seemed off. Orange light on the Ethernet jack lit up and nothing else happened as you can see on the picture:opi2

I waited some time, since no other light or activity happened I decided to connect my USB-2-serial adapter to check what is happening with boot procedure. Here is a clip booting Ubuntu Vivid Mate where you can see that it stops exactly at the point when detecting DRAM:

Similar thing happened when I tried to use Armbian:

From the following I could only conclude that DRAM could be the issue. After googling about my problem I found out that there is a lot of other people facing the same issue:

http://www.cnx-software.com/2015/10/02/orange-pi-pc-not-booting-you-are-not-alone/

Of course I have used different power adapters, different images, and nothing seemed to work. Only change I could see on this device was when I tried manually to slightly bend it, then green Ethernet light came on, but without any change in boot process.

After complaining to GearBest their solution was to refund part of the money I paid and give me additional points, but I was so disappointed with the product and the quality that I have decided not to invest in the same device again.

I will keep my two Raspberry Pi 3s and one Raspberry Pi 2 as my main devices and not go into future endeavors with these low-cost knock-off devices. Poor build quality, awful software support, no mainstream kernel support, no user support are just some things to mention.

Compare contents of two directories in bash

It’s always good when you are looking for a way to do a task and you find great one-liner that just does the job right:

diff -rq directory1/ directory2

Switches “r” and “q” will recursively compare the two directories and showing brief output.

I wanted to test this and ideal candidate for thiss was my ScummVM collection on my laptop and on my NAS storage. I used following command:

diff -rq ScummVM/ /mnt/volume_2/games/scummvm/

 

Grep pattern in files if found delete the file

Recently I was presented with a problem where mail server was dying because of 100K+ mails in queue.

Due to spool overload it was necessary to identify a pattern and delete it from the /var/spool/postfix/incoming/ and later this needed to be applied for certain inboxes that were filled with spam.

Simplest way to find a pattern and if found was to use following command:

find -type f -exec grep -q "YOURPATTERN" '{}' \; -print

Be advised that this will print out all the mails/files that contain YOURPATTERN. If you are satisfied with matching result it’s easy to delete them with:

find -type f -exec grep -q "YOURPATTERN" '{}' \; -delete

For example one spammed inbox was containing 64305 messages with “Delivery Subsystem” as sender. To delete those messages I used:

find -type f -exec grep -q "Delivery Subsystem" '{}' \; -delete

After deletion of just that one pattern, inbox was down to 3534 mails.

So with just simple analysis and identification of spam mail and the right pattern you can delete all those unwanted files efficiently.