Ubuntu: how to install grub on the second disk.

I had two disks on my Dell Latitude E6540: HDD (/dev/hda) and SSD (/dev/sdb). These disks had different operating systems and grub was installed only on HDD. The second SSD disk: ssd
was installed in the mSATA slot which in fact was WWAN port at my laptop.

So it happened. One day my HDD stopped working completely it was dead. I was not able to boot my operating system I had on SSD disk because the grub was only on HDD. To fix the problem I installed the grub on SSD using the Live USB Ubuntu.

This was my procedure:

  • mount the partition with the system (in my case it was /dev/sda1):
  • sudo mount /dev/sda1 /mnt
  • bind the following directories:
  • sudo mount --bind /dev /mnt/dev
    sudo mount --bind /dev/pts /mnt/dev/pts
    sudo mount --bind /proc /mnt/proc
    sudo mount --bind /sys /mnt/sys
  • change the directory to /mnt with chroot:
  • sudo chroot /mnt
  • install grub:
  • grub-install /dev/sda
    grub-install --recheck /dev/sda
  • final clean up:
  • exit
    sudo umount /mnt/sys
    sudo umount /mnt/proc
    sudo umount /mnt/dev/pts
    sudo umount /mnt/dev
    sudo umount /mnt

    And one more thing. It is really important to check the disk with new grub whether it has set the flag boot if not the disk will be not bootable. This can be easily done with GParted.

    How to detach a process from the Terminal

    There is a number of methods which allow you to run the process in the background detached from the terminal, e.g. tmux, nohup, screen. However recently I have started using the most basic unix method I have just forgotten for many years, I mean the combination of bg and disown.
    I will use my everyday scenario, I usually start my eclipse from the terminal:

    $ ./eclipse

    Sometimes I forget to add & at the end but there is a way how to place it to the background and detach from the terminal. You need to press CTRL+Z to suspend the process then list the jobs by typing

    $ jobs

    to receive the job number, e.g.:

    [1]+  Stopped                 /home/runner/work/eclipse

    next you need to move eclipse (job 1) to the background:

    $ bg %1

    and detach it from the terminal:

    disown %1

    when you close the terminal the eclipse will be still working.

    Git: how to temporary ignore changes in file

    Sometimes I don’t want to commit changes in the specific file. I often use git commit -a -m '...' so it automatically adds all the changed files to the commit and in most of the cases it’s what I want to do. Fortunately there is a possibility to mark a file to be not considered during this commit:

    git update-index --assume-unchanged file

    and to mark it back:

    git update-index --no-assume-unchanged file

    GWT: how to implement long click for mobile browsers and disable context menu

    I one of my previous posts GWT: how to implement long click I provided an example of the long click which works on PC’s browsers. However this solution has a drawback when it comes to mobile browsers. In most of the cases the long click (or better said touch) does not launch the long click logic but the Context menu.
    To fix this problem it’s enough to register the ContextMenu handler for a widget from my example which is supposed to handle the long click:

    widget.addHandler(new LogoContextMenu(widget), ContextMenuEvent.getType());
    protected class LogoContextMenu implements ContextMenuHandler {
    	private CustomImage image;
    	public LogoContextMenu(CustomImage image) {
    		this.image = image;
    	public void onContextMenu(ContextMenuEvent event) {
    		//long click logic

    Bash: tmux script

    In one of my development scenarios I need to login to 3 different remote machines and execute there some commands. To make it more simple I wrote the bash script which invokes tmux to split the terminal window into 3 pieces:

    tmux new-session -d 'ssh foo@bar'
    tmux split-window -h 'ssh -t foo@bar2 "cd foo/bar && exec bash -l"'
    tmux split-window -v 'ssh foo@bar3'
    tmux resize-pane -D 10
    tmux attach-session -d


    Android: pay on time App

    Recently I have started new Android project. I want to write a simple application which will remind me about coming payments. My code is kept in a public github repo
    Probably I will publish this app in the Google play, it will be for free without any ads.

    The app consist with two activities: MainActivity with RecyclerView and InvoiceAcitivity with the payments details. The third activity will be the Settings. Data are handled by the means of the private ContentProvider.

    When the UI will be in more advanced state I will provide more detailed description with screenshots attached.