Do NOT ever use BTRFS.

BTRFS has far fewer superblocks than ext4. Do not use it. I had a memory corruption, and it wiped out both superblocks for my BTRFS partition. Now my data is complete gone. As my work colleague said, GG.

root@illustrious:/mnt# dumpe2fs /dev/mapper/illustrious-root | grep -i superblock
dumpe2fs 1.42.11 (09-Jul-2014)
Primary superblock at 0, Group descriptors at 1-6
Backup superblock at 32768, Group descriptors at 32769-32774
Backup superblock at 98304, Group descriptors at 98305-98310
Backup superblock at 163840, Group descriptors at 163841-163846
Backup superblock at 229376, Group descriptors at 229377-229382
Backup superblock at 294912, Group descriptors at 294913-294918
Backup superblock at 819200, Group descriptors at 819201-819206
Backup superblock at 884736, Group descriptors at 884737-884742
Backup superblock at 1605632, Group descriptors at 1605633-1605638
Backup superblock at 2654208, Group descriptors at 2654209-2654214
Backup superblock at 4096000, Group descriptors at 4096001-4096006
Backup superblock at 7962624, Group descriptors at 7962625-7962630
Backup superblock at 11239424, Group descriptors at 11239425-11239430
Backup superblock at 20480000, Group descriptors at 20480001-20480006
Backup superblock at 23887872, Group descriptors at 23887873-23887878

root@illustrious:/home/fangfufu/btrfs-progs# ./btrfs-show-super -a /dev/sdb3
superblock: bytenr=65536, device=/dev/sdb3
———————————————————
csum 0×66895990 [match]
bytenr 65536
flags 0×1
magic _BHRfS_M [match]
fsid f0e867d9-33aa-4f9d-9f7a-972b0688ac1b
label
generation 160984
root 194638618624
sys_array_size 97
chunk_root_generation 160534
root_level 1
chunk_root 194414379008
chunk_root_level 1
log_root 194606780416
log_root_transid 0
log_root_level 0
total_bytes 233396240384
bytes_used 117715746816
sectorsize 4096
nodesize 4096
leafsize 4096
stripesize 4096
root_dir 6
num_devices 1
compat_flags 0×0
compat_ro_flags 0×0
incompat_flags 0×1
csum_type 0
csum_size 4
cache_generation 160984
uuid_tree_generation 322
dev_item.uuid 29760bff-4fc9-4632-8a6b-16de18d60fa5
dev_item.fsid f0e867d9-33aa-4f9d-9f7a-972b0688ac1b [match]
dev_item.type 0
dev_item.total_bytes 233396240384
dev_item.bytes_used 149395865600
dev_item.io_align 4096
dev_item.io_width 4096
dev_item.sector_size 4096
dev_item.devid 1
dev_item.dev_group 0
dev_item.seek_speed 0
dev_item.bandwidth 0
dev_item.generation 0

superblock: bytenr=67108864, device=/dev/sdb3
———————————————————
csum 0xb1ebb733 [match]
bytenr 67108864
flags 0×1
magic _BHRfS_M [match]
fsid f0e867d9-33aa-4f9d-9f7a-972b0688ac1b
label
generation 160984
root 194638618624
sys_array_size 97
chunk_root_generation 160534
root_level 1
chunk_root 194414379008
chunk_root_level 1
log_root 0
log_root_transid 0
log_root_level 0
total_bytes 233396240384
bytes_used 117715746816
sectorsize 4096
nodesize 4096
leafsize 4096
stripesize 4096
root_dir 6
num_devices 1
compat_flags 0×0
compat_ro_flags 0×0
incompat_flags 0×1
csum_type 0
csum_size 4
cache_generation 160984
uuid_tree_generation 322
dev_item.uuid 29760bff-4fc9-4632-8a6b-16de18d60fa5
dev_item.fsid f0e867d9-33aa-4f9d-9f7a-972b0688ac1b [match]
dev_item.type 0
dev_item.total_bytes 233396240384
dev_item.bytes_used 149395865600
dev_item.io_align 4096
dev_item.io_width 4096
dev_item.sector_size 4096
dev_item.devid 1
dev_item.dev_group 0
dev_item.seek_speed 0
dev_item.bandwidth 0
dev_item.generation 0

superblock: bytenr=274877906944, device=/dev/sdb3
———————————————————
btrfs-show-super: ctree.h:1984: btrfs_super_csum_size: Assertion `!(t >= (sizeof(btrfs_csum_sizes) / sizeof((btrfs_csum_sizes)[0])))’ failed.
csum 0xAborted

Snippets from Horizon – 1982-1983: Killer In The Village

I used to study biology. I love good documentaries about biology. This episode of Horizon is probably one of my favourite.

30 years after the broadcast of this episode of Horizon, they still haven’t found a cure for AIDS. Ah well…

http://www.bbc.co.uk/iplayer/episode/p01z2lbp/horizon-19821983-killer-in-the-village

__________________________________________________________

1026
00:52:33,880 –> 00:52:35,600
COUNSELLOR: What if I told you that

1027
00:52:35,600 –> 00:52:37,880
the diseases that are going around now have no cure,

1028
00:52:37,880 –> 00:52:39,880
and they lead to death within a year?

1029
00:52:39,880 –> 00:52:42,400
Oh, I’d move. HE WHISTLES IN AWE

1030
00:52:42,400 –> 00:52:44,960
That you can catch it through sexual contact,

1031
00:52:44,960 –> 00:52:47,520
and that the more sexual contacts you have with people,

1032
00:52:47,520 –> 00:52:49,680
the higher your risk of catching it?

1033
00:52:49,680 –> 00:52:51,040
What would you do now?

1034
00:52:52,760 –> 00:52:54,880
Oh, that’s tough.

1035
00:52:54,880 –> 00:52:56,480
COUNSELLOR: Assuming I told you

1036
00:52:56,480 –> 00:52:59,240
the more times you have sex with different people,

1037
00:52:59,240 –> 00:53:02,280
the higher your chances of coming down with this.

1038
00:53:02,280 –> 00:53:04,280
Yes, I would stop having sex with people.

1039
00:53:04,280 –> 00:53:06,680
- Oh, definitely. – Very definitely.

__________________________________________________________

913

00:46:25,160 –> 00:46:27,800

‘Prisoner Castronova’s speech is affected.

914

00:46:27,800 –> 00:46:31,080

‘He may have toxoplasmosis as well as the pneumonia.

915

00:46:31,080 –> 00:46:32,960

‘This is one of his better days.’

916

00:46:32,960 –> 00:46:35,560

MRS CASTRONOVA: You look a lot better. He looks good today.

917

00:46:35,560 –> 00:46:37,440

And if it wasn’t for my wife…

918

00:46:39,120 –> 00:46:41,000

..I don’t know what I’d be doing.

919

00:46:44,240 –> 00:46:49,920

She’s been there with me every day – intensive care…

920

00:46:49,920 –> 00:46:53,000

I was in intensive care.

921

00:46:53,000 –> 00:46:58,720

Er, I left here for, what, four months?

922

00:46:58,720 –> 00:47:01,000

- Mm-hm. – Went back to prison…

923

00:47:02,440 –> 00:47:05,080

..and they shot me right back here.

924

00:47:06,400 –> 00:47:10,040

And they have no cure for it at all.

925

00:47:10,040 –> 00:47:15,280

What’s rough now is, I don’t know if I’ll ever see my kids again.

926

00:47:15,280 –> 00:47:19,760

You know? Like a walking time bomb.

927

00:47:19,760 –> 00:47:21,200

You know?

928

00:47:21,200 –> 00:47:23,560

But that’s what they said.

929

00:47:23,560 –> 00:47:26,720

“You’re like a walking time bomb.”

930

00:47:27,720 –> 00:47:29,680

Aww.

931

00:47:29,680 –> 00:47:32,520

- Huh? – No, they’ll find a cure for it.

932

00:47:32,520 –> 00:47:35,080

Some day, but it might be too late.

933

00:47:36,680 –> 00:47:38,440

You know?

934

00:47:38,440 –> 00:47:43,160

So you people that are out there shooting dope – give it up.

935

00:47:44,880 –> 00:47:47,800

Because I’ll never make it through.

936

00:47:49,120 –> 00:47:52,200

You know, if you’ve got any value for your life…

937

00:47:53,680 –> 00:47:54,920

..give it up.

938

00:47:56,520 –> 00:47:59,120

‘Soon after that day, Castronova died.

Guess the block device

Which block devices produce these results? Please put your answer in the comment box below. The output are generated by hdparm -Tt.

Device A:
Timing cached reads: 392 MB in 2.00 seconds = 195.80 MB/sec
Timing buffered disk reads: 62 MB in 3.07 seconds = 20.17 MB/sec

Device B:
Timing cached reads: 6276 MB in 2.00 seconds = 3145.45 MB/sec
Timing buffered disk reads: 732 MB in 3.00 seconds = 243.72 MB/sec

Device C:
Timing cached reads: 1754 MB in 2.00 seconds = 876.83 MB/sec
Timing buffered disk reads: 374 MB in 3.01 seconds = 124.12 MB/sec

 

Tiny Tiny RSS as a replacement for Google Reader

Google is discontinuing Google Reader by July this year. I subscribe to quite a lot of RSS feeds. It is therefore important for me to find a replacement for it. Personally I prefer to use an always-online solution. I know there are plenty desktop clients. However they require your computer to be physically on to check the feeds. This is less than ideal. You might miss out on those frequently updated feeds, by not turning on your computer. There are quite a few commercial solution on the web, such as feedly and The Old Reader. However we all agree that is cooler to have something that you have total control, right?

Tiny Tiny RSS look very similar to Google Reader. It is also available in Debian Unstable repository. Even if you are not running Debian Unstable, you can still install only some packages from Debian Unstable. If you don’t want to change the settings for your package manager, you can try and download the package itself and install it directly. You might need to run “apt-get –f install” to fix dependency after the installation. It is really easy to set up the package.

I have tried running Tiny Tiny RSS on my Raspberry Pi. My Raspberry Pi is from one of the first batches of version B. It only has 256MB of ram. It is painfully slow. So please don’t do that. I think part of the problem is that I am running Transmission and I2P on my Raspberry Pi. The load average hovers around 0.6 normally anyway.

Anyway, if you can’t be bothered to set your own Tiny Tiny RSS up, you are free to use mine.

Tips on Installing I2P on Raspberry Pi

I2P is one of those software that’s best left running forever. Raspberry Pi is one of those platform that’s perfectly suitable for such task. I suppose you could leave your Raspberry Pi running “behind the enemy line”, and you can access it through the I2P darknet.

Installing I2P on Raspberry Pi is simple. Although you need to install a JVM first. You can do that by running:

sudo apt-get install default-jre-headless

You can follow the standard procedure described in I2P website. I installed mine to /opt/i2p. That folder is owned by a local user. I then installed I2P as a service, by running

/opt/i2p/i2prouter install

I then configured i2prouter to run as a local user.

Now here is the important part, the default JVM at its default configuration is very slow. According to various posts, it doesn’t seem to doing Just-In-Time(JIT) compilation, it actually interprets Java bytecode. If you simply start I2P now, your load average will shoot through the roof.

You need to modify /opt/i2p/wrapper.config, added these lines at the appropriate location:

# Use CACAO to increase execution speed
wrapper.java.additional.5=-cacao

I added it after

“wrapper.java.additional.4.stripquotes=TRUE”.

An alternative for using CACAO would be installing Oracle Java SE 8 (with JavaFX) Developer Preview for ARM. This is actually how I actually run my I2P. More instruction is available at here. If you don’t use Java SE 8, then you need to revert your modification to wrapper.config.

If you run I2P now, the load average should be between 0.5 to 1, your mileage may vary though.

You might want to change your I2P’s settings so you can access I2P from other computers within your network.By default I2P only listen to the localhost. More instructions are here. You shouldn’t modify runplain.sh, because we are not using it here. You shouldn’t move the integer library, they seem to have fixed it. You might want to change 0.0.0.0 to a specific adapter’s IP address, for security reason. For example, rather than having:

clientApp.0.args=7657 ::1,127.0.0.1 ./webapps/

I have

clientApp.0.args=7657 ::1,127.0.0.1,192.168.0.1 ./webapps/

I hope this post helps.

 

 

A script to reset the network when ping fails

I live in a place with dodgy wifi connection, sometimes the Wifi adapter says that it is connected, but I can’t send packets. Therefore I have this in my root’s crontab. It works quite well.

EDIT: reset is now called wifi_reset, because reset is actually a command on its own.

#!/bin/bash

function wifi_reset {
echo
echo “Disabling wlan0″
echo
/sbin/ifdown wlan0
echo
echo “Re-enabling wlan0″
echo
/sbin/ifup wlan0
echo
echo “Done!”
}

ping -c 1 www.google.com > /dev/null 2>&1

if [ $? -ne 0 ]; then
echo “Network down!”
wifi_reset
fi

HOSTS=”www.google.com”
COUNT=10
for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep ‘received’ | awk -F’,’ ‘{ print $2 }’ | awk ‘{ print $1 }’)
if [ $count -le 5 ]; then
# 50% failed
echo “Poor network performance!”
wifi_reset
fi
done

Installing WordPress on Debian

Right, if you want to install WordPress, then don’t bother with the one in the repository. It over-complicates things by putting the WordPress scripts outside /var/www. Perhaps it is better for security, but the resulting installation is a pain to use and maintain. You can’t do auto-update, and you can’t install plugins without installing a FTP server.

You should follow the tutorial at:http://codex.wordpress.org/Installing_WordPress, before you start, remember to set the owner of /var/www to www-data:www-data, and set the permission of the folder to 775.

If you want to use permalink like me, you need to enable Apache rewrite mod by typing “a2enmod rewrite” as the root, then modify the your /etc/apache2/sites-available/default according to  http://tymonn.wordpress.com/2009/07/31/how-to-enable-mod_rewrite-in-apache2-debianubuntu/

And that’s about it. If you use the WordPress package in the repository, you will have a “fun” time of setting the whole thing up.

OpenVPN IPv6 Tunnel Linux Client Configuration

I have finally decided to give my Raspberry Pi proper IPv6 access. I assume you have followed my previous guide on configuring OpenVPN IPv6 tunnel broker. You need to add these lines to your OpenVPN client configuration file:

script-security 2

up “/etc/openvpn/turing-up.sh”

down “/etc/openvpn/turing-down.sh”

This is the content of turing-up.sh:

#!/bin/bash

/sbin/dhclient -6 -pf /var/run/turing.ipv6.pid tap0

This is the content of turing-down.sh:

#!/bin/bash

kill $(echo $(cat /var/run/turing.ipv6.pid))

rm /var/run/turing.ipv6.pid

Basically the modification automatically attaches a dhclient on the new tap interface, and kill it when the tunnel is torn down.