Repair GRUB2 for UEFI after Windows Installation



A windows installation wipe out your old GRUB2. You want to repair.


Suppose that /dev/sdaX is where your ubuntu was installed and /dev/sdaY is where you want to install GRUB2.

Boot with Ubuntu LiveCD. Open a terminal, then do the following:

# We call the Ubuntu from the LiveCD the Live Ubuntu
# We call the Ubuntu on our local partition /dev/sdaX the Local Ubuntu

sudo mount /dev/sdaX /mnt # mount the Local Ubuntu into the Live Ubuntu

sudo mount /dev/sdaY /mnt/boot/efi # mount the GRUB2 partition into the Local Ubuntu

for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
# This step is NECESSARY. It makes the Local Ubuntu see what the Live Ubuntu see. Then the update-grub can work correctly.

sudo chroot /mnt # Now we switch from the Live Ubuntu to the Local Ubuntu

sudo grub-install /dev/sdaY # Install GRUB2

sudo update-grub # Update GRUB2


Subequations in Lyx

Original post is here:

Subequation Numbering

If you want to group the equation numbers as, for example, (1a) and (1b), then you must do the following:

  1. Add \usepackage{amsmath} to the document preamble.
  2. Before the equation block, hit CTRL-L to add a LaTeX block, and type \begin{subequations}.
  3. After the equation block, hit CTRL-L to add a LaTeX block, and type \end{subequations}.

The document should now look like this:


and result in:


A sample document can be found here: MultilineEquationNumbering.lyx

Additional Options

If you want to add a cross-reference to the entire block of equations, e.g. (1) rather than (1a) or (1b) in the example above, you need to add a label to the subequations block. Just move your mouse immediately after the \begin{subequations} LaTeX block, then add a label. You can then add a Cross-Reference to this label as normal.

Build Your Own Cloud: Extra Comments

Alternatives to OwnCloud:

(1) Bittorrent Sync: Its P2P idea is very attractive, but currently it is not reliable even with its basic purpose: sync and update with the right version of a file.  Sometimes, it accidentally delete files;  Sometimes, it overwrites new files with way old files.  This happened to me just twos before I was going to submit my critical project deadline.  Many other users also reported similar data lose.  I will never use it before they have reliably implemented conflict management.

Secondly, Bittorrent Sync is closed source.  Its company is so money hungry that advertizes and charges for such beta software without conflict management, not caring about the damage it could bring to its users.  As closed source, it is not sure how secure their btsync is.  In their forum, they lock discussion on btsync’s alternatives and questions on its security.  Such attitude drives me away.

Third, btsync runs in background without telling the user with a task bar icon.  It is very sneaky.  If some one install on your computer, then it becomes a backdoor.  Your data is sent somewhere without telling you.  Damn!  Keep far away from this software and this irresponsible company until they prove they are trustful.

Do not use Bittorrent Sync until they have implemented conflict management, if you really care about your data safety.

(2) AeroFS: AeroFS runs on virtual machines.  This is both good and bad.  I eventually gave it up because on a Linux host machine with wireless connection, its guest machine cannot have a unique MAC, but must use the same as the host machine.  It may introduce many trouble in your LAN.  If you use a Windows as a host, it shall be fine.  By the way, their virtual machine appliance is really resource hungry.  In comparison, OwnCloud takes much less resource.

Build Your Own Cloud: Part II, Set Up OwnCloud Server

It is easy to setup an OwnCloud server on Ubuntu.

(1) Install OwnCloud following instructions here:

The installation is automatic.  In the process you will be asked for MySQL’s administrative credentials.

After installation, type localhost/owncloud in a browser, you will see the configuration page of OwnCloud.  If you satisfy with SQLite, then you can following the instructions to finish the configuration.  If you want to use MySQL which is recommended by OwnCloud, you shall take the following effects.

(2) Create a MySQL user for OwnCloud and a database for OwnCloud with the following commands

mysql -u root -q # Login MySQL.  Following parts are in mysql.

CREATE USER ‘owncloud’@’localhost’;

SET PASSWORD FOR ‘owncloud’@’localhost’ = password( ‘YourPassWordForMySQL’ );


GRANT ALL ON owncloud.* TO ‘owncloud’@’localhost’;


(3) In a browser, type localhost/owncloud, and follow configuration instructions on the webpage.

If you choose MySQL, then on the second page, select MySQL and set these parameters:

database user: owncloud

database: owncloud

database password: YourPassWordForMySQL

host: localhost

After successful configuration, if you would like to tighten security, you can take the following effort.

(1) Enforce https.

(1a): Install ssl certificate for your apache server.  Below are useful informaiton:

(1b) Enforce https in OwnCloud’s administrative panel.

(2) In your router, remove port 80 from your “Virtual Server” for port forwarding.

(3) In your router, enable MAC filtering, only allowing those devices that you permit to use the cloud.