May 3, 2018

Add a thin provisioned logical volume to rescue a fulled Proxmox lab

It's a great & it's so efficient to have VM running on thin provisioned disks. However, I just learnt that Proxmox will quietly put a VM into some stalled status (web GUI shows a darkened icon but without green triangle, and the console will not respond) if the volume is fulled. Having Proxmox to reset or to boot with a .iso is possible, but sooner or later, all will hit the wall again.
I don't want to lose my VM, so my solution was to move a virtual disk out from the volume. I added a small USB drive (actually a mSATA SSD, seems performed ok) to the box, created a new thin pool volume, and move one VM out. Now I can keep the VMs running again.

Create a volume group on the USB (assuming a new group "external" on the disk /dev/sdc1):
vgcreate external /dev/sdc1 Create the volume (naming it "extdata") (yes, it's small):
lvcreate -L 14G -n extdata external Convert to a thin-provisioning volume:
lvconvert --type thin-pool external/extdata It's time to add the storage using web GUI (naming it "ext" here):
[WebGUI] > [Datacenter] > [Storage] > [Add] > ID: ext, Volume group: external, Thin pool: extdata > [Add] Finally, move the virtual disk: [WebGUI] > [999 (bustedVM)] > [Hardware] > [Hard Disk (virtio0)](the disk to move) > [Move disk] > Target storage: ext > [Move disk]

Installing CUDA for deep learning while having IGP for display

Note for installing CUDA for deep learning, while keeping the integrated graphic processor handling display.
(Tested on Debian Stretch 9.3)

Credit goes to:
https://unix.stackexchange.com/questions/218163/how-to-install-cuda-toolkit-7-8-9-on-debian-8-jessie-or-9-stretch
https://www.linkedin.com/pulse/installing-nvidia-cuda-80-ubuntu-1604-linux-gpu-new-victor
https://devtalk.nvidia.com/default/topic/991849/-solved-run-cuda-on-dedicated-nvidia-gpu-while-connecting-monitors-to-intel-hd-graphics-is-this-possible-/

1. Download CUDA installation runfile.
(`cuda_9.1.85_387.26_linux.run` in my case)
(This may take a while, 1.6GB)

2. Install requirements
sudo apt-get install linux-source sudo apt-get source linux-image-$(uname -r) sudo apt-get install linux-headers-$(uname -r) sudo apt-get install gcc g++ libxi-dev libglu1-mesa libglu1-mesa-dev libxmuu-dev linux-headers-amd64 linux-source
3. Install NVIDIA driver and CUDA
(As root, although the runfile will prompt for sudo password if necessary.)
chmod +x cuda_9.1.85_387.26_linux.run ./cuda_9.1.85_387.26_linux.run --no-opengl-libs
(y)es to "install on an unsupported configuration"
(y)es to "install NVIDIA Accelerated Graphics Driver"
(n)o to "run nvidia-xconfig"
(y)es to "CUDA Toolkit"

December 22, 2017

Joining Active Directory

Test on freshly installed Debian 9.
Credit goes: https://www.tecmint.com/integrate-ubuntu-to-samba4-ad-dc-with-sssd-and-realm/

Make sure the hostname has been updated. (hostnamectl set-hostname newhostname).
apt install adcli realmd sssd sssd-tools packagekit policykit-1 apt install samba-common-bin samba-libs samba-dsdb-modules apt install krb5-user Join the "the.domain.name" domain:
realm join the.domain.name
Update /etc/sssd/sssd.conf: (Optional)
(I prefer to have use_fully_qualified_names = False and customize fallback_homedir)
(Also, default_shell = /usr/bin/zsh for me. ) [sssd] domains = the.domain.name config_file_version = 2 services = nss, pam [domain/the.domain.name] ad_domain = the.domain.name krb5_realm = THE.DOMAIN.NAME realmd_tags = manages-system joined-with-adcli cache_credentials = True id_provider = ad krb5_store_password_if_offline = True default_shell = /bin/bash ldap_id_mapping = True use_fully_qualified_names = False fallback_homedir = /home/%d/%u access_provider = ad
Add pam_mkhomedir.so to /etc/pam.d/common-session
session optional pam_mkhomedir.so skel=/etc/skel umask=077 Restart sssd service systemctl restart sssd
Try to identify a domain user with id id Administrator
The output should be something like this:
uid=900000500(administrator) gid=900000512(domain admins) groups=900000512(domain admins),900000520(group policy creator owners),900000519(enterprise admins),900001105(dc backup hosts),900001103(computers),900000518(schema admins),900000513(domain users),900000572(denied rodc password replication group),900001104(dc slave hosts)

August 17, 2017

Active Directory with Samba 4 Domain Controller on Raspberry Pi


This is just a collection of tutorials for a home network experiment.
The goal is to setup a small Active Directory domain to ease account management and local sharings.
The Domain Controller will be based on Samba 4 running on a Raspberry Pi. I'll have my other machines: several Windows, a few Debians, a Synology NAS, and potentially Mac OS X joining the domain.

Setting up Active Directory

(EDIT: Eventually, I found this guide. My DC just works with a bit tweak for static IP and unmask samba-ad-dc.service.)
Create an Active Directory Infrastructure with Samba4 on Ubuntu – Part 1 https://www.tecmint.com/install-samba4-active-directory-ubuntu/

(EDIT: This can be a good reference, but I failed somewhere. At some point, I realized that I don't really need a Samba DC Router, just too complicated.)
Samba 4 Domain Controller on Raspberry Pi
http://www.virtualfrontiers.co.uk/domain_controller.htm

Tweaking for user home folder
https://wiki.samba.org/index.php/User_Home_Folders

Joining Active Directory

Joining a Debian Client to Active Directory
https://wiki.debian.org/AuthenticatingLinuxWithActiveDirectory
http://www.alandmoore.com/blog/2015/05/06/joining-debian-8-to-active-directory/

Simplier version:
Join in Windows Active Directory Domain.
https://www.server-world.info/en/note?os=Debian_9&p=realmd

Complicated version:
Linux: Connecting a Linux server to Active Directory. All of the needed steps.
http://www.techpository.com/linux-connecting-a-linux-server-to-active-directory-all-of-the-needed-steps/

November 26, 2015

python3 twitter downloader with mongodb

mongodb credit goes to Liam Bowen (original post: http://hut8.io/posts/mongodb-3-on-debian-jessie/) 1. install mongodb 3.0
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo 'deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main' | sudo tee '/etc/apt/sources.list.d/mongodb-org-3.0.list'
sudo apt-get update
sudo apt-get install -y mongodb-org
2. tweak the settings
sudo mkdir /mongodb
sudo chown -R admin:admin /mongodb    # "admin" because of using AWS debian AMI
sudo nano /etc/mongod.conf            # change [storage.dbPath] and [systemLog.path], "wiredTiger" part is more optional
3. start mongodb in background
mongod --config /etc/mongod.conf --fork
# to report mongodb stats every 60 seconds
# mongostat 60
# to shutdown 
# mongo --eval "db.getSiblingDB('admin').shutdownServer()"
python and twitter 1. get the packages
sudo apt-get install python3-pip
sudo pip3 install twitter pymongo
2. tweaks
sudo nano /etc/hostname 
echo $HOSTNAME

September 21, 2015

Disable date/time sync between VirtualBox client and host

by msa.operation @ forum.virtualbox.org
original post: https://forums.virtualbox.org/viewtopic.php?t=8535

vboxmanage setextradata [VMname] "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

Note: replace [VMname] with the name of target virtual machine; replace "1" with "0" to turn the sync back on.

July 28, 2015

connect to local area network through PPTP VPN (Synology DSM)

Credit goes to this forum post by vibrationbaby

In short, assign PPTP managed IPs into the same pool of local private network.
  1. login as root through SSH.
  2. go to /usr/syno/etc/packages/VPNCenter/pptp
  3. edit the two lines for localip and remoteip pptp.conf. (@vibrationbaby provided the setting below. i used .200 and .201-205 while my DHCP managed 100-199. just choose some addresses that is not overlapping with existing DHCP pool.)
    localip 192.168.1.210
    remoteip 192.168.1.211-220
    
  4. then it should work after restart the VPN Server through DSM web interface.