Friday, October 30, 2020

Installing rancheros on virtualbox

Rancheros is a simple linux operating system, equipped with docker for easy deployment of docker in a virtual machine.

In this example, we will use virtualbox as our hypervisor.


First, download the rancheros iso from here

$ wget https://releases.rancher.com/os/v1.5.6/rancheros.iso


Then, fire up virtualbox and create a linux 64-bit virtual machine with 1GB memory, 8GB hard disk, and a bridged network.


Next mount the rancheros.iso file to the cdrom of the virtual machine we just created above, and boot the virtual machine.


Once booted, open the virtual machine console, change the password, and get the ip address of the virtual machine.

$ sudo passwd rancher

$ ip address


In this example, I will use 10.0.0.10 as the ip address of the virtual machine. Now, fire up your terminal, and ssh into the virtual machine.

$ ssh rancher@10.0.0.10


Once logged in, we will create a pair of ssh key for the user

$ ssh-keygen


We need to keep the private key in our host machine, so that we can use it to login to the virtual machine once we have installed rancheros to disk. So open another terminal, and download the private key we just generated above.

$ scp rancher@10.0.0.10:~/.ssh/id_rsa ~/rancher_id_rsa


Now we have to create a cloud-config.yml file, that is needed for rancheros installation to disk. We will have to include the ssh public key generated above, into the cloud-config.yml

$ echo -e "ssh_authorized_keys:\n  - $(cat ~/.ssh/id_rsa.pub)" > cloud-config.yml


Install rancheros to disk using ros command.

$ sudo ros install -c cloud-config.yml -d /dev/sda


Once finished, you can ssh into the rancheros on virtual machine's disk, by including the rancher_id_rsa file into your ssh command

$ ssh -i ~/rancher_id_rsa rancher@10.0.0.10


Once logged in, you can now start using docker.

$ docker version


Monday, October 26, 2020

Modifying termux keyboard to get extra keys

I use termux quite a lot when working with shell using my android phone. The older version of tmux has a good vertical keyboard, with essential keys like tab and arrow keys are all accessible in the main keyboard interface. The newer version of tmux, however, does not provide the full arrow keys in the main interface, like below. You can see that only up and down arrow keys are provided.

One good thing about termux is, it is customizable. And you can put whatever key you want on the keyboard interface, like below, just by following simple steps.

1. Open your termux

2. You need to edit a file called "~/.termux/termux.properties". Create the directory if it does not exist.
$ mkdir ~/.termux

3. Start editing the file. You can use any editor like nano or vim (needs to be installed). For the sake of simplicity, I just use cat. Run below command and press enter to edit.
$ cat > ~/.termux/termux.properties

4. Paste the line below to add 2 rows of extra keys. The first row will be populated with ESC, |, HOME, up arrow, END, PGUP and DEL keys, and the second row will be populated with TAB, CTRL, ALT,  left arrow, down arrow, right arrow, page down and backspace keys. Please customize this setting to your liking. You can find the supported keys here
extra-keys = [ \
 ['ESC','|','/','HOME','UP','END','PGUP','DEL'], \
 ['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN','BKSP'] \
]

5. Press ctrl-d to save the file.

6. Reload termux settings, by running "termux-reload-settings" command.
$ termux-reload-settings

Your vertical keyboard is now added with more keys as per the configuration you have just put in.

Happy typing.


Monday, October 12, 2020

Transferring a proxmox VM to a different proxmox installation (backup and restore)

 To backup a vm, you can use vzdump command. The command just need a vm ID to start the backup process.


Get the VMID

# qm list


Start the backup process. You can choose a compression option, between no compression, gzip or lzo.

# vzdump --compress gzip 655


The command will generate 2 files, a data file and a log file. Transfer the data file to the other proxmox installation, using whatever methods. I just use scp.

# scp vzdump-qemu-655-2020_10_10-13_51_13.vma mynewproxmox.ip.add.ress:


Once transferred, restore the file into a VM, by providing the VMID. This command will restore the dump file into a VM with VMID 300.

# qmrestore ~/vzdump-qemu-655-2020_10_10-13_51_13.vma 300


Oh, and all this can be done via GUI, but for this tutorial, I will just cover the command line part :).


Enjoy.

Thursday, October 8, 2020

Troubleshooting proxmox pve-cluster down

Out of the blue, one of my proxmox node becomes offline in the web ui. All the VMs in that node is still working though, and the node is reachable via ssh, so network is not an issue. After searching around, it is because pve-cluster is down on that node, causing it to be invisible to the cluster altogether.

Looking around for clue, I found out that /etc/pve is empty, and "ls /etc/pve" returned "transport endpoint is not connected". journalctl command returned something more subtle, as below:

"host1 pmxcfs[29698]: [main] crit: fuse_mount error: Transport endpoint is not connected”

After searching around some more, I found out that the mountpoint is gone, and I need to remount /etc/pve back to get pve-cluster running.

Normal and forced unmount does not work. Thanks to this post, lazy unmount worked. So in order to restart pve-cluster, I have to lazy unmount /etc/pve first, the restart the pve-cluster.

# umount -l /etc/pve

# systemctl restart pve-cluster

# systemctl status pve-cluster

...

Active: active 

...


And my node is now back online in the proxmox webui.