Restore OS from bare metal


My computer failed last week and restoring C drive, the OS partition, cannot boot my Windows 10. What need to be backed up so that Windows can boot up as long as the hardware is good? Here is a list of items I came up with:

  1. The BIOS setup: for UEFI, the boot file location, e.g EFI/ubuntu/grubx64.efi
  2. The GPT header and partition table
  3. The EFI partition: holding grub2 boot loader and kernel
  4. The OS partition: C drive for Windows, and root partition for Linux.

Tools used: CD burned from http://www.system-rescue-cd.org, run PartImage, which create image by calling PING 4.7.3

Advertisements

Connecting to a server behind the firewall


Some of our servers are behind the stadium’s firewalls, and we don’t have control over those firewalls. Our AWS servers, accessible by ssh on the internet, needs to connect to our physical servers behind the stadium’s firewall. I found the quickest way with minimum system-wide impact is to use so-called “ssh remote forwarding”.

If we call the host behind firewall HF, and the host in AWS HA, there are two steps to let HA connect to HF’s port 80. 1. HF runs ssh to connect to HA. 2. HA connects to HF by connecting to HA’s local port.

Here are the commands:

  1. on HF: ssh -R 8083:localhost:80 HA   , which forwards HA:8083 to HF:80
  2. on HA: browser to: http://localhost:8083 , which actually connects to HF:80.
  3. Optional.:GatewayPorts is needed only if other machines need to connect to HF through HA

“remote” means remote to sshd. In another words, sshd and the forwarding destination is not on the same local network.

Headless Ubuntu Server Installation with GeniCam cameras


To test GeniCam cameras, I installed headless Linux, Ubuntu Server 16.04.4 LTS, on a laptop, without graphics, to mimic our AWS servers, none of which have GUI. The whole process takes about one hour, excluding research time, of course. Some key notes are listed below.

  1. Download: https://www.ubuntu.com/download/server  over 800M, only half size of the Ubuntu desktop version.
  2. Bootable USB: created from the .iSO above, by rufus-2.18p.exe
  3. Boot from USB: Boot in UEFI mode. Booting from CD needs legacy mode.
  4. Boot manager: GRUB2 version 2.02
  5. Partitions: sda1: UEFI boot partition, sda5: Linux OS boot volume, I set it to 10G. The default AWS Root Device is only 8G
  6. Wireless: different from Desktop Network Manager. Some key commands are: (wlp6s0 is wireless interface name)
    1. sudo ifconfig wlp6s0 up
    2. sudo iwlist wlp6s0 scan
    3. sudo iwconfig wlp6s0 essid “RwAtt” key mypassword
    4. sudo dhclient -v wlp6s0
  7. GeniCam Camera driver installation(Smartek as example):
    1. install libnl-route-3-200
    2. build kernel module from source, which ends up as /lib/modules/4.4.0-116-generic/kernel/drivers/video/u3vdrv.ko
    3. add configuration to /etc/ld.so.conf.d
  8. Pitfalls: I always get boot failure with message “no bootable device found” whenever trying to if=/dev/sda5, or changing boot mode to Legacy then back to UEFI. I think it’s BIOS bug. Fix: tell BIOS the GRUB binary location by typing in \EFI\ubuntu\grubx64.efi in boot options in BIOS

Minimum requirement to display GUI on Windows for Linux


I manage multiple Linux servers in AWS, none of which has display server installed, neither x nor Wayland. Display servers run on my Windows machine. I prefer portable application over setup.exe. By portable, I mean no changes to registry, and all change are limited to the local folder that holds the download. There are some portable packages on Windows that can do this well, listed in reference section.

I wanted to go one step further: not only portable, but getting rid of terminal emulator, e.g. PuTTY. The solution on Windows includes two parts: x server and ssh.exe. Here are the key points.

  1. x server: downloaded as zip file. Both Xming and VcXsrv are tested well.
  2. sh.exe: can be copied, instead of installed, over from either git or installed Cygwin.
  3. It’s very important to set DISPLAY variable on both Linux and Windows. On windows it’s like this: set DISPLAY=127.0.0.1:04.

X11 forwarding can be removed too: (only tested on the same LAN)

  1. take out -X option when starting ssh.exe
  2. run “DISPLAY=MyWindowHost:0” on Linux.
  3. explicitly tell x server who is allowed to connect. e.g. edit X0.hosts for Xming.

References:

  1. http://www.straightrunning.com/xmingnotes/portable.php
  2. http://www.scrc.umanitoba.ca/doc/tutorial/T19_3a_xsrvputty.htm