Showing disks attached on a linux computer

The application that will probably be available on every system would be fdisk, so i will start with that

fdisk -l

But that is not my favorite, the one i use (Because i have disks of same size so i need more information) is

lshw -class disk

But i still need to know the partitions so fdisk -l will be necessary with that too

There is a third option,

hwinfo --disk

And, because sometimes i want to see parititons too

lsblk

Will do the trick

flogging a dead kindle (BACK TO LIFE !)

Kindle Keyboard
Kindle Keyboard working again

My kindle was displaying a message saying

Battery Empty

Connect your kindle to a power source and charge it until this screen disappears. This may take up to 30 Minutes

If you continue to see this screen after charging, you will need to reset your Kindle. Unplug it from the power source, then slide and hold the power switch for 15 seconds.

In short, both did not work, Once plugged into a charger, The orange light will come up for a few seconds, then it will disappear, my charger LED will also turn off meaning no power is being drawn, resetting did not resolve it either as it seems there is absolutely no power in the battery, considering that i have left it for months without use or charging.

So, the solution seemed to be heating it up a bit against an electric fan heater (Few seconds, don’t make the kindle hot), then plugging it into a charger kept the orange light on, the orange light flickered for a few seconds after plugging it in (Obviously not a “by deign” kind of flickering).

Also worth mentioning that one of the chargers works better than the other, after the heating, one of the chargers (Larger capacity) seems to hold the orange charging light steady, while the smaller one seems to fail within a few seconds of plugging it in (orange light goes out)

Now, it seems to be charging, the battery empty page refreshed, but still gave a battery empty page, then a few seconds later, what do you know, that battery empty screen disappeared and the kindle initiated a boot sequence (The normal screen that appears when you start the kindle with a progress bar) (If this does not happen after 30 minutes of orange light lit up, You might want to consider resetting it like the kindle says).

This is one of the very old kindles, It dates back to many years ago. In the footer of the menu, it says kindle 3.3, on the back it says (Kindle model number D00901), But i am not really planning to invest time finding out what this kindle is called, it is the one with the keyboard

Source of the problem, a theory, Lithium batteries have a cutoff charge, meaning, devices leave some power in a battery (And consider it empty, switching themselves off before a complete drain) because if the voltage goes below that threshold, it can be dangerous to recharge.

Heating probably registered some voltage on the battery convincing the kindle to charge it.

The 3-4 seconds of mild flickering is still a mystery though.

Final note: Once the kindle booted, both chargers seemed to work just fine.

DBMAIL commands

First thing first, using the manual, your commands will go in dry run mode, no hints are given on why needed changes are counted but not executed, this is because you have to rn the command with the y switch to do the changes, here are a few ones you will use often

dbmail-util -dy – set delete status on deleted mail (deleted by IMAP or POP)
dbmail-util -py – delete messages with delete status

dbmail-util -by – rebuild the caches

Without the Y, no changes will be made to the database

Wake on LAN with linux

My always on Linux machine is a dell FX 160, very low power consumption, should work as my VPN, asterisk server, and wake up other computers when i need them, the device itself is multi homed, So i basically need it to wake up other devices on one of the networks

The commands you need for this to work are as follows

etherwake -i eth1 xx:xx:D2:B2:30:C9 (My laptop)

eth1 is the network connected to my mini linux server that is connected to the target network.

Thats all there is to it, in addition to enabeling wake on lan in your BIOS

CP overwrite files in destination

Although the copy program cp in Linux overwrites without prompting, in practice, it does not, the reason behind that is that the command is aliased with the (cp -i), you can check that by using the alias command

So there are 2 solutions to this to make cp overwrite

The first would be to unalias, while the second would be to execute the command directly with

\cp

Or you can use the full path to the alias command like

/usr/bin/cp

I personally use

\cp this that

The best computer – tv setup for your living room

The best computer-tv setup for your living room

Here, i am posting this to remind myself of how to setup my media center at home, so it can be a bit messy

Kodi (XBMC) seems to be the only real competitor to Windows Media center, in my case, i feel it is much better than Windows Media Center.

Hardware

The raspberry PI 2 (With 1 GB ram) can function as the hardware with it’s HDMI output

Or

An old PC, with cooling switched to passive watter cooling (Cost me around $40 on ebay for the parts) to get rid of the noisy fan, and with the hard drive replaced by a bootable linux flash stick (Also to reduce noise)

Please note that the analogue (D-SUB / VGA) cable is just as good as HDMI, analogue signal over such a short distance is not a problem, so you can connect the D-SUB to your TV or the HDMI cable, you will not notice the difference. But you will need to connect audio to external speakers or something.

The disadvantage of the old PC method are

The cooling system costs half as much as a raspberri PI ! alot of money i would say.
The PC is bulky compared to the PI
Draws much more power than the PI

The advantages

You already have that old PC
You can use Kodi on Windows, then use your IPAD as a keyboard and mouse (No such app exists for linux yet)
You can use it for more general purpose purposes later on
It’s eithernet port is not provided through USB like the PI
You can have much more RAM on it
You can add an input card to it and connect your home receiver to it
You can install hard drives inside (Remember to make them spin down when not in use) and then use it as NAS
You can install an IR receiver on the com port and use LIRC to program any remote you have
It can play DVDs (If it has a DVD player)

———————————————-

Plugins that i like for Kodi

Fastest disk duplication tool

I have been using DD for a long time, specify the block size etc, then pipe it into PV if you like, and there you have it

But you can use PV directly

So let us assume we want to put sda on sdb (See how direction arrows are pointing out of sda in the command)

pv < /dev/sda > /dev/sdb

and you are done, no need for DD, PV is faster because it checks the speed on both disks first, and there you have it

At first it will be much faster than you anticipated, that is because it is buffering in RAM, once you run out of ram, the speed will drop back, even if you dont run out of ram, there will be time for the sync operation

For example, while cloning my 40GB SSD onto an 80GB western digital, at first the speed was 180MB/s, once i ran out of ram, it dropped to 50MB/s

The best way to find deal with duplicate files on Linux

There are 2 popular packages to deal with duplicate files on linux

The first would be fslint (apt-get install fslint), the down side is that it is not sorting by file size, because when i have 10,000 duplicate files on my disks, i really don’t want to deal with them all and make choices, so what comes to mind is this, the second is fdupes, i have never used it before so i would not know, so we will be using fslint with a small script.

first, find the duplicate files, in my case, i only want the ones over 2MBs

/usr/share/fslint/fslint/findup /hds -size +2048k > /root/dups.txt

Now, this little simple script should read the data into a mysql table (Command line PHP script, you will need to edit the mysql username, password and database), you also need to tell it what the path you used in the command above is (I used
“/hds”), also included is the database sql file, you can put that in with PHPMyAdmin

Now, you can run the above script and it will go and investigate file sizes on the file system.

Then, you can either walk through the database after sorting by size, or write your own display script (Fetch and print, nothing too fancy), so you will know where your greatest gains are, and this way you will not lose a day filtering those duplicate files.

Have fun, and please let me know what you think

Note on PATA – IDE 1.8″ 2.5″ compatibility and difference

Just because this took a lot of research from me (Looking at specs), I am posting this here for my own reference.

Note: CF cards will work on both 3.3V and 5V. so there is a bit of a mystery on why we need a voltage step down chip and a jumper for this particular adapter, other drives are clearly incompatible IDE interfaces.

it turns out that when combined with a converter using the fc1307a chip to create CF out of 2 SD cards, it will not work without a voltage step down, with the wrong setting, or with cards with no step down, a computer will see the combined cards, but will fail when trying to format them for some reason.

The 1.8 adapter (Sideways IDE interface) is 3.3V, the normal 2.5 disks are 5 Volt, the adapter we have that turns CF cards into 1.8 or 2.5 compatible drive, has a JUMPER to select, this jumper effectivly activates or deactivates the voltage step down chip (The only chip on the board)

So there you have it, 1.8 and 2.5 PATA drives are not compatible regardless of the fact that the PIN interfaces are the same. the adapters with a voltage step down will work on both, but you need to set them up first with a JUMPER

Raspberry PI camera, quick guide

For those who want a real lowdown right away, here is the final verdict, as of the time of writing this, there are no faster options, the limitations here are imposed by the creators of PI and it’s chips (The Broadcom GPU)

You have 2 options for capturing stills in burst mode. In the case i am addressing here, taking photos of rapidly moving objects in broad daylight, so the shutter speed is very fast, the ISO is not so high (Because of the sun).

1- Through the GPUs stills part of the processor, you would get less than 2 frames per second, you can use the timelapse function.

2- Through the video port on the GPU, this will allow a maximum of 15 frames per second at 5MP resolution, no binning, no sensor cropping, but the still port gives somewhat better photo quality

Considerations

The speed of storage counts, if your storage becomes a bottleneck, 15FPS will not be possible.

1- You can use faster USB storage, the USB port is bound to a maximum of 45MB/Second

2- A fast memory card, currently 25MB/s comes on expensive “Professional” SD cards, i would rather use the USB port

3- Splitting the bandwidth between storage and Ethernet is not a good idea, the Ethernet adapter on the raspberry PI is connected through USB, so it will share the USB bandwidth 😉

4- Splitting the storage or buffering some of the frames on the SD card can be a good idea, as the SD card is connected directly to the CPU not through USB

5- Lowering the photo quality through increased performance will give you good mileage, something equivalent to what other programs call 80% quality will reduce the size pretty well without sacrificing much.

How to get through the stills port

raspistill -o %04d.jpg -ss 5000 -ISO 300 -t 10000 -tl 100 -q 10 -th none

So, the questions that come to mind instantly are, how come quality is a value from 0 to 100 and we are using 10 ? it is a good question, and this is something that is not making sense i know, but judging with my eyes, -q 10 will give us good compression ratio and the photo is still good, the range between 10 and 100 does not make much difference, and then under 10, things go very bad rapidly, no idea why

Now to the next method, which is getting photos from the video port… here is a quick and dirty picamera python script

If you don’t know how python works, please don’t change the indentation, indenting the print statement will add the print to the previous code block which is something we don’t want.

#!/usr/bin/python3
import time
import picamera

frames = 60

with picamera.PiCamera() as camera:
    camera.resolution = (2592, 1944)
    camera.shutter_speed = 5000
    camera.iso = 100
    camera.framerate = 10
    camera.start_preview()
    time.sleep(2)
    start = time.time()
    camera.capture_sequence([
        '/usbstick/image%02d.jpg' % i
        for i in range(frames)
        ], use_video_port=True)
    finish = time.time()
print('Captured %d frames at %.2ffps' % (
    frames,
    frames / (finish - start)))



So simply put, if you are running raspbian, you need to get into the pi config (command is raspi-config), and enable the camera then reboot

Also, don’t forget to run “rpi-update” or apt-get upgrade

Now if you try to take a photo you would enter the command

raspistill -o cam.jpg

But this will take a long time to take one photo (5 seconds by default), this is because it needs to set the exposure, if you want to give it less time you could run the command

raspistill -t 1500 -o test.jpg (One and a half seconds)

But that’s is too long, i already know that it is broad daylight, and that i need a very fast shutter speed, So how do i manually set things ?

Taking a photo of fast moving things in the SUN, i would run the command as follows

raspistill -t 1 -ss 1000 –awb sun -o test1.jpg

Taking photos of moving things in cloudy weather, i would run the command as

So, here are the manual things

–ss 1000 (1 ms, good for a sunny day oudoors, 4ms is good on a cloudy day, with dim light, i would recommend bumping this up a bit)

–ISO 300 (Sensitivity, Back in the day, the film dictated this property), the faster the shutter (Lower value), the higher the needed sensitivity (ISO VALUE), the range is 100 to 800

–nopreview

Prsets for Automatic white balance (AWB)

–awb sun