Tag Archives: linux

So you lost a disk on a MD RAID5 array, now what?

It happens, you just lost a disk on your RAID5 MD array, or things are not how it should look like… How do we troubleshoot this?

First things first, what’s the name of your MD device. You can easily learn that by issuing:

cat /proc/mdstat

This should output something similar to:

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid5 sdd[1] sda[3] sdb[2]
2929890816 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/4] [.AAA]
bitmap: 0/8 pages [0KB], 65536KB chunk

Here we have a MD device /dev/md0. (If you don’t see a response to this, you might have lost your MD device, which could be a bigger issue!)

Another thing that we see (Or we don’t see) here is that sda/sdb/sdd are here in the raid but sdc is nowhere to be found! This is our problem.

For some reason /dev/sdc is not in the RAID group anymore. Let’s see what’s going on with /dev/sdc?

mdadm --examine /dev/sdc

In my example this was hanging for a long time. When I issue dmesg on another console, I was getting a lot of I/O errors about this disk. This is telling me that the disk is malfunctioning.

I shutdown the server and wiggled the disk. Rebooted and it was back online. My array has now four disks however only 3 of them are “functioning” since after the reboot MD kicked /dev/sdc out of the array.

We need to reassemble the array and let RAID5 do its magic. First stop the MD device /dev/md0.

mdadm --stop /dev/md0

Then we need to add /dev/sdc back into the array:

mdadm /dev/md0 -a /dev/sdc

Then depending on the situation we might need to reassemble the array:

mdadm --assemble /dev/md0 /dev/sd[abcd] --verbose --force

Hopefully /dev/sdc is now back in your array now. This should start a long(er) process to sync up the array state to all disks and hopefully you now have your array back!

After the sync completes, I would still do a fsck on the /dev/md0 filesystem.

fsck.ext4 /dev/md0

e2fsck 1.45.5 (07-Jan-2020)
data: recovering journal
JBD2: Invalid checksum recovering block 185073680 in log
JBD2: Invalid checksum recovering block 89 in log
Journal checksum error found in data
data was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (704006059, counted=696320594).
Fix? yes
Free inodes count wrong (182701042, counted=182694547).
Fix? yes

data: 429421/183123968 files (0.2% non-contiguous), 36152110/732472704 blocks

You can use this same steps (or similar) to remove /dev/sdc and replace with a brand new hard drive. In my case wiggling solved the problem for now. (I probably will need a drive in the near future)

I hope this helped someone. It surely will help me when I will have to do this again 😛

Run pihole without raspberry pi

I have few 24/7 running linux boxes at home. I wanted to try pi-hole. But I really didn’t want to add another computer (raspberry pi) on my network.

So my initial feeling was why not try Docker? Good choice. Here is how easy it was.

Pull pihole docker image

docker pull pihole/pihole

Find your local IP (Replace eth0 with your ethernet identifier)

sudo ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d "/" -f 1

Get the IP ( in my case) and run docker:

docker run -d --name pihole -e ServerIP= -e WEBPASSWORD="myawesomepassword" -e DNS1= -p 9080:80 -p 53:53/tcp -p 53:53/udp -p 9443:443 pihole/pihole:latest

Here in this example above I’m using myawesomepassword as login password to pihole (Change it to your password). I connect the host OS port 9080 to pihole’s port 80 and 9443 to pihole’s port 443.

DNS server is running on port 53. (Since I’m not doing any zone transfer I can leave TCP 53, but oh well ¯\_(ツ)_/¯ )

You can login to the admin interface in http://192.168.100:9080/admin and start setting your pihole up.

Have fun blocking pesky DNS requests 😉

shadowsocks auto deploy

I wrote a cloud-init script to automate the deployment of a shadowsocks server. I shared it in a gist here.


  • Creates a non-privileged user
    • Uploads your ssh public key to the user
    • Adds this user to the sudoers group
  • Disables ssh login for the root user
  • Downloads and installs libraries required for chacha20
  • Creates a “random” password and writes it in the config.json file
  • config.json file is in the /root directory. (You will need the password in this config file to be able to connect to your shadowsocks server.)
  • Starts the shadowsocks server.

You have to fill out the _YOURUSERNAMEHERE_, _YOURSSHPUBLICKEYHERE_ and _YOURFULLNAMEHERE_ with your data.

You can use this script in DigitalOcean easily following this document.

Replacing Unity with XFCE in Ubuntu

Here is what I do as soon as I install a new Ubuntu instance: I remove unity desktop and replace it with XFCE. And if you want to do the same it’s pretty straightforward. 😉

Perform all of these as root in a terminal window, or prepend with sudo. (Look elsewhere for GUI steps 🙂 )

  1. Update your repos:
    apt-get update
  2. Uninstall Unity and ubuntu-desktop:
    apt-get purge ubuntu-desktop unity-*
  3. Install XFCE Desktop environment:
    apt-get install xubuntu-desktop
  4. Restart lightdm:
    /etc/init.d/lightdm restart

Voilà! You’re using XFCE desktop! 😉

ý yerine ı görmek istiyor musunuz?

Türkçe karakterlerin sorunsalı olan ISO-8859-9 formatıyla UTF-8 arasındaki uyuşmazlığı çözen küçük bir python scripti yazdım. Program girdi olarak ISO-8859-9 formatlanmış bir yazı alıyor ve de UTF-8 ile formatlayıp dosyaya yazıyor.


python convertToUnicode.py --input /path/to/filename.srt --output /path/to/convertedfilename.srt

ya da

python convertToUnicode.py -i /path/to/filename.srt -o /path/to/convertedfilename.srt

Siz de kullanmak istiyorsanız: https://github.com/emresaglam/convertToUnicode

OpenVPN client test, without a client.

If you need to test the connectivity of your openvpn server from a client’s perspective, you can use this command:

echo -e “\x38\x01\x00\x00\x00\x00\x00\x00\x00” |     timeout 10 nc -u your.openvpnserver.ip port | cat -v


This sends TLS negotiation header to the server and expects a reply in 10 seconds. If you get an empty line, things timed out. If you get a reply like the line below, you have connectivity.


Raspberry Pi carputer update

The only update of the week is that I tested the composite output in a Toyota Highlander’s entertainment system. It booted fine. The fonts are not as crispy as I wanted, but still readable. I didn’t have a chance to test the XBMC however web browsing was acceptable with an open wifi around the campus. 🙂

I’m also waiting some batteries for my old Voltmeter 🙂 Once it’s working I can start some prototyping.

Hopefully more updates in a week.


rarcrack with big files

If you are trying to crack a big rar file with rarcrack (Mine was 2.6G) and you’re receiving this error:

$ ./rarcrack --type rar ./file.rar
 RarCrack! 0.2 by David Zoltan Kedves (kedazo@gmail.com)

 ERROR: The specified file (./file.rar) is not exists or
 you don't have a right permissions!

You need to add these lines below in rarcrack.c and recompile. (Put them before #include rarcrack.h )

#define _FILE_OFFSET_BITS 64

While you’re there you can fix the error message’s English 😉 I leave it to you to find it. 😉

Raspberry Pi powered carputer.

I got myself a raspberry pi couple of weeks ago. First I tried to make a HTPC out of it using XBMC but the interface was too slow for my taste. So I decided to build a carputer. 🙂 I have very basic electronic knowledge, so this will be a learning process for me too.

So far what I need is this list below:

  • a car (Check)
  • a 12V to 5V converter: I have cheap lighter to USB adapter. I’ll start with that but I’m thinking about this in the future.
  • a 5V power source activated when the car power is shut: For this one I’m going to start with a circuit I had in hand that I was using to charge my wifey’s phone using a small solar panel. It has a 2000mAh Li-Po battery on it. (That battery is most probably flat. I’ll need a new one)
    I will need this power source for only maybe 1 min. Read next bullet point.
  • a relay circuit that will detect that the car power is shut off and will send a GPIO signal to Rpi to shut itself off. Otherwise there will be corruption at some point of time. 😛 I believe I should write a simple script to shutdown to tie it to that GPIO signal.
  • a 7″ touchscreen screen (possibly with an HDMI input. I have couple of candidates.)
  • a software to play music and video. Biggest candidate so far is XBMC.

Nice to have:These will require a USB hub since I only have 2 USB inputs. (I need to look at the power requirements for the USB hub)

  • a wifi/bluetooth solution for phone interaction.
  • a GPS interface.

More update weekly. (hopefully!)


Airlink Ultra Mini USB Adapter with Linux

We recently bought this Ultra mini usb wifi adapter for our laptop that had it’s internal wifi card fried. Since this laptop was acting really bad with Windows XP, we installed Ubuntu on it.

At first Ubuntu couldn’t recognize the adapter. Then I wanted to try ndiswrapper. All I had to do was to install ndisgtk (sudo apt-get install ndisgtk). It installs ndiswrapper-utils package as a dependency. Then point the ndisgtk to the .inf file of the driver.  (net8192cu.inf)

Here is a more detailed write-up for generic ndiswrapper configuration from ubuntu.

The ID for this adapter is: 0bda:8176
When you run lsusb it shows as: Bus 001 Device 002: ID 0bda:8176 Realtek Semiconductor Corp.
The manufacturer id is: AWLL5088