Quick recovery of Linux boot (Grub) or Windows MBR

One of the common problems in Linux installations is to lose or damage the the boot loader (Grub), specially if on the same machine coexists other OS from Microsoft family.

On the other side, while you are testing Linux you can loose your Windows Boot.

I used to repair this kind of problems in the old-school way: Booting a Linux liveCD+mount HD partition+chroot+install grub+cross fingers. But this is not a method recommended for novice users…

Recently I’ve discovered an utility that is designed specially for this! The utility is called Boot Repair CD (you have to burn the ISO to a CD or USB) and after booting, an assistant will appear and magically solve your boot problems 🙂

Boot Repair Disk (Easy way)

Boot Repair Disk (Easy way)

Even they will help you if the utility can’t repair your boot area:

Launch Boot-Repair, then click the “Recommended repair” button. When repair is finished, note the URL (paste.ubuntu.com/XXXXX) that appears on a paper, then reboot and check if you recovered access to your OSs. If the repair did not succeed, indicate the URL to boot.repair@gmail.com in order to get help.

For advanced users, it also have a bunch of options related to Grub and MBR:

Boot Repair Disk (Advanced mode)

Boot Repair Disk (Advanced mode)

Give it a try!

Resize a mounted Linux partition

Today I’ve learnt that a Linux partition (which is mounted) can be grown “a la brava” (means “the hard way” in Catalan) directly modifying it through Fdisk and then resizing with resize2fs. That’s it….

With my own conservative way I’d boot the machine into Gparted (A very useful small distro that boots into Gparted directly), resize the partition (unmounted), and then reboot again.

The only condition is that the partition which has to be grown is the last one. If not… things get more complicated (or not, if the last partition is a swap one, which can be erased and recreated without problems). Other condition is that particion can only be grown (not shrink).

The process it’s easy:

  • First grow the disk physically (can be a VM disk, a new bigger disk just cloned, or simply a partition that does’nt fill the entire disk).
  • With Fdisk, remove the partition.
  • Without exiting Fdisk, create a new partition. Carefully note that the first sector match the previous first sector. The last sector can be the end of the disk i.e.
  • Verify/toggle Boot flag, must be activated.
  • Save and exit. Cross your fingers and reboot.
  • Once rebooted, grow the filesystem with resize2fs.


Bye backups… hi ZFS snapshots!

Today an entire folder disappeared from my Owncloud instance. It is an entire mystery why has disappeared. And I haven’t backups since owncloud data supposedly is synced between all client computers…

But, who wants backups when you have ZFS snapshots? I have all my private Owncloud data into a ZFS volume, and a cron job that do snapshots at midnight. Unlike Solaris, ZFS on Linux doesn’t have snapshotting natively so we have to use this set of pretty scripts: zfs-auto-snapshot

ZFS snapshots can be accessed like if they were a regular filesystem and they show you the files as it were just at the snapshot moment. The good thing is that the space occupied is *very* low (only stores changed data like it were an incremental backup).

So you only have to copy the missing data from the snapshot folder into the original place.

zfs list shows us all the datastores, mountpoints and snapshots:


We want to restore the latest snapshot from May 12th at 04:25am. First we have to ensure that snapshots are visible to us. We’ll set RomaniHD/Magatzem datastore to show snapshots. It will be located hidden on the datastore root (/datastore/.zfs)


Voilà, we have a virtual copy of our datastore of the last week:

Now we have to enter the desired folder (day) and copy the contents into the correct place.

In my case, I restored Owncloud data, so after copying the missing data I had to do a content refresh. First become www-data user and tell owncloud to refresh its entire data folder:


Streaming audio to two different targets (or networks)

It may sound strange, but one radio station (or somebody) may want to stream audio to two different networks. I had this special need in Boca Ràdio (a local Radio Station from Barcelona) because this station broadcasts through a provider and also broadcasts into Guifi.net (A community based, open and neutral network).

So, the box that transcode analog audio coming from the station’s sound mixer, it has to send it to:

  • Streaming provider in Shoutcast format
  • Localhost in Icecast format. In the same box there is an Icecast server listening to Guifi network clients. (Note that Icecast server may be running on another location).

I utilize this little transcoder: Darkice that reads configuration from /etc/darkice.cfg and sends analog audio coming from the Soundboard to the specified targets and in the specified format. It is available in Debian repo.

Configuring Icecast server is pretty straightforward but be sure that this items are properly configured:


Multiple internet WAN at home or office

It’s not uncommon to see on many offices that the Internet connection comes from several WAN connections (for redundancy, or whatever). Even on the more freak homes I’ve seen a multiwan setup (i.e., one wan from the ISP, other from a guifi.net vpn, and other wan being stolen from the neighbors).

I know three methods for managing automatically more than one WAN connection. Best yet, automatically but meeting several rules (i.e.: youtube transit sent to wan1, bittorrent to wan2 and HTTPS transit to wan3).

Method 1: RouterOS PCC

Mikrotik routers can handle natively a multiwan setup through PCC (Per Connection Classifier). Packets must be marked with a routing mark and then the PCC chosses where to send them. Best references:

Method 2: OpenWRT MWAN3

MWAN3 is a package for OpenWRT that do the job and can be configured in a easy and visual way. So you need a powerful router fully compatible with OpenWRT and MWAN3. I have an ex-coworker that uses this stuff and wrote this excellent post:

Method 3: Linux

Method 1 and 2 requires a special router, but this method only requires a Linux Box with two or more ethernet cards. I’ve not tested it but it seems very interesting because it’s not hardware-dependant. In fact, that software is designed for, given more than one WAN connection, discard the first that gets disconnected (hence the title of the project).

FTTH a la porta de casa

Qui m’ho havia de dir, que en un poble de 15.000 habitants a 40km al nord de Barcelona… em posarien una caixa de distribució de FTTH just a 20cm del meu balcó! Doncs sí, ja ha arribat la FTTH a Canet de Mar.

De totes formes, actualment amb una ADSL de Pepephone per 23€ mensual que m’aporten 9mbps de baixada i 1mbps de pujada….no crec que cap solució amb FTTH arribi en aquests preus tant econòmics i per tant, ADSL fins que el coure ens separi!