Xubuntu on Sager NP9758-S mobile workstation

This is my new baby:
  • 15.6" 4K QFHD Matte Display with G-SYNC Technology (3840 x 2160)
  • Guaranteed no dead or partially-lit pixels for first 30 days of purchasing
  • Nvidia GeForce GTX 980M GPU with 8GB GDDR5 Video Memory
  • 6th Generation Intel® Core™ i7-6700 Processor ( 8MB Smart Cache, 3.40GHz)
  • IC Diamond Thermal Compound - CPU + GPU
  • Windows® 10 Home 64-Bit Edition Preinstalled
  • 16GB Dual Channel DDR4 SDRAM at 2133MHz- 2 X 8GB
  • 250GB Samsung 850 EVO M.2 SSD (as Storage Drive)
  • 1TB 7200rpm SATA2 Hard Drive
  • Intel Dual Band Wireless-AC 8260 M.2 AC Wireless LAN + Bluetooth Module
  • 230W 110V/240V autoswitch AC Adapter

I chose this guy as primarily a Linux workstation.  This laptop has a desktop CPU and a mobile Nvidia GPU.  Most importantly, though, the Nvidia chip doesn't use Optimus.  While the newer Nvidia binary blob drivers handle Optimus better (I've had some success with an older Alienware laptop with Optimus.)  But I definitely didn't want to have to screw with that on my main Linux  workstation especially since I like to play games under Crossover's wine.
My only complaint about the laptop as it shipped was that I requested that the SSD be used for storage, rather than the Microsoft boot drive.  Since the SSD was smaller than the conventional hardrive, I was able to use 'dd' to migrate the Microsoft installation to the conventional hardrive.

I then booted an Xubuntu flash drive and proceeded to install Xubuntu.  Coming from a Fedora background I wasn't that versed in Xubuntu conventions, and clicked through the install quickly.  I wasn't able to choose LVM for the filesystems (something I really wanted because I planned to run lvmcache on the SSD.)
I thought the problem was because Microsoft was installed first and I had fully patched it so it had created a bunch of new partitions.  I decided to whack the whole thing and start over and ensure that Microsoft was installed on limited number of partitions.  (If you are saying, but weren't they GPT partitions you don't have to worry about having too many partitions. you'd be right and would be skipping ahead).  I downloaded Microsoft version 10 and installed on 3 partitions.  I didn't let Microsoft finish patching and immediately installed Xubuntu.  But wait, why didn't the installer give me the option to use LVM?
A bunch of googling later, and I learned that the LVM option is only when you have a single OS installation of Xubuntu.  But there was a way I could try to set up the LVM partitions before I started the installer from the Xubuntu flash disk.
So I setup LVM then proceeded with installing Xubuntu.  I didn't choose anything special in the install other than I want my home directory encrypted, but not the entire filesystem.  Yes, yes, I know that an unencrypted swap file could lead to someone recovering data, but I prefer an encrypted home directory as the long term storage of my data is encrypted.

After rebooting into the Xubuntu system, I enabled the Nvidia binary driver (don't tell Linus) as well as the Intel binary blob under Settings -> Additional Drivers





Next step let's get google chrome on here as well as firefox
since I'm trying to covert to ubuntu, I'll just use the directions here: http://askubuntu.com/questions/510056/how-to-install-google-chrome

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 
sudo sh -c 'echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update 
sudo apt-get install google-chrome-beta

Apparently installing beta Google Chrome results in a second apt source being created.  This causes an error when running `sudo apt-get update`.  To fix `sudo vi /etc/apt/sources.list.d/google-chrome-beta.list` and comment the deb repository.


Now it is time to enable lvmcache using the SSD on /dev/sda.  I used about 170G of the 230GB for Microsoft, Steam games and ReadyBoost.  Now I created a new partition for Linux LVM.

fdisk /dev/sda
Device         Start       End   Sectors   Size Type
/dev/sda1       2048 359370751 359368704 171.4G Microsoft basic data
/dev/sda2  359370752 488397134 129026383  61.5G Linux LVM

pvcreate /dev/sda2
vgextend -v xubuntu-vg /dev/sda2
lvcreate -n temp -l 16 xubuntu-vg /dev/sda2
lvcreate -n CacheMetaLV -L 64M xubuntu-vg /dev/sda2
lvcreate -n CacheDataLV -l 100%FREE xubuntu-vg /dev/sda2
lvremove xubuntu-vg/temp
lvconvert --type cache-pool --poolmetadata xubuntu-vg/CacheMetaLV xubuntu-vg/CacheDataLV
lvconvert --type cache --cachepool xubuntu-vg/CacheDataLV xubuntu-vg/root
lvs -a xubuntu-vg

echo "dm_cache" >> /etc/initramfs-tools/modules
echo "dm_cache_mq" >> /etc/initramfs-tools/modules
echo "dm_persistent_data" >> /etc/initramfs-tools/modules
echo "dm_bufio" >> /etc/initramfs-tools/modules

cat > /etc/initramfs-tools/hooks/lvmcachechech.sh <<'EOF'
#!/bin/sh

PREREQ="lvm2"

prereqs()
{
    echo "$PREREQ"
}

case $1 in
prereqs)
    prereqs
    exit 0
    ;;
esac

if [ ! -x /usr/sbin/cache_check ]; then
    exit 0
fi

. /usr/share/initramfs-tools/hook-functions

copy_exec /usr/sbin/cache_check

manual_add_modules dm_cache dm_cache_mq
EOF

chmod 700 /etc/initramfs-tools/hooks/lvmcachechech.sh
apt-get install thin-provisioning-tools
update-initramfs -u -k all



Reboot and Wham-o, Grub prompt :(

Dang it.  Because of my custom layout, Xubuntu decided to install without using /boot.  This works for normal booting since grub can read the lvm volumes to retrieve the initrd and kernel.  It doesn't work so well with lvmcache because grub would need extra pieces that it doesn't have.
Not being a grub master, I decided the easiest thing to do is to whack the lvmcache and boot the system to try to force the boot files onto /boot.
I booted the Xubuntu liveCD on USB and then:

sudo su -
apt-get update
apt install thin-provisioning-tools
vgchange -a y xubuntu-vg
mount /dev/mapper/xubuntu--vg-root /mnt
mount /dev/sdb2 /mnt/boot
chroot /mnt
# looked around for a bit
exit
lvm
    lvremove xubuntu-vg/CacheDataLV
lvs -a
init 6

Sometimes it hurts to be stupid and this is one of those times.  I either didn't configure /dev/sdb2 to mount as /boot during the install, or it was overridden and ignored.  I am my own enemy with this lvmcaching situation.  Booting back into the LiveCD to fix the pathing ( can't do it live since some files are open under /boot on /).



Crap that was ugly.  Trying to move an EFI boot with grub2 from the lvm root to a separate partition provided to be to involved.  Instead, I decided it was better to just re-install Xubuntu.  This time I was very careful in the early stages to mount /boot on /root, with /boot being a standard partition with ext2 filesystem.  I also configured (using the same steps I have above) the lvmcache before installation.  It might just be an illusion but the install seemed to be much quicker.  Hoping against hope, I decided to reboot after installation but without doing the custom scripting and see if the installer would just include all of the dm_* modules but no go.

A quick boot into the LiveCD again, and deleted the lvmcache brought me back up and then once up, I redid the lvmcache one more time.


Ok, let's put on some utilities that I'm used to using

sudo apt-get update


sudo apt-get install xscreensaver xscreensaver-data-extra vim xscreensaver-gl nedit xbacklight fonts-droid fonts-inconsolata fonts-ubuntu-font-family-console fonts-ubuntu-title fonts-wine-development ttf-ubuntu-font-family ttf-xfree86-nonfree xfonts-base curl rxvt-unicode-256color rxvt screen ctags xdaliclock fortune xfonts-100dpi xscreensaver-data openconnect network-manager-openconnect{,-gnome} openjdk-8-jdk libbonobo2-bin libgnomevfs2-bin libgnomevfs2-extra gnome-mime-data libice-doc libsm-doc libxcb-doc libxt-doc openjdk-8-demo ruby awscli xfce4-artwork xfce4-battery-plugin xfce4-cpufreq-plugin xfce4-datetime-plugin xfce4-diskperf-plugin xfce4-goodies xfce4-mixer xfce4-sensors-plugin seahorse rdesktop xfsprogs btrfs-tools openssh-server dump ttf-bitstream-vera ri ruby-dev bundler xsensors attr quota cifs-utils xfonts-terminus xfonts-terminus-oblique ntp devilspie2  dos2unix terminator
sudo fc-cache -f -v





Now I'll repeat the above procedure and select the binary blob Nvidia driver as well as the Intel blob.
After that, I'll update the apt repositories to allow me to install Google Chrome Beta.  I've stuck with beta ever since I was able to use the beta branch and user-agent switching to get Netflix working with Google Chrome way back when.

I prefer to use a Logitech Trackball for my most of my pointing needs.  (Would someone please tell Logitech to start making wired versions of these again so I can stock up?)  Anyway, while I have this connected, I am finding that I accidentally bump the Synampics Touchpad while typing which results in random cursor movement and garbage output.  Luckilly XFCE gives a way to help prevent that.  I don't just want to disable the device because I won't always have the Trackball connected.  Under the options for the Synaptics Touchpad there is an option to "Disable touchpad while typing."  Set it to "11" and we are good to go.
With a 4k monitor, I like to set the Trackball to accelerate a lot but only if I move it a good deal.  These settings seem to allow me to do fine movements in a small area but zip around the screen when I need to.


Now being an old TWM fan, I prefer focus follows mouse and click to raise.  XFCE has a few menus for tweaking the window manager.


Then there is the window manger tweak tool:




Ok, now my work VPN solution is Cisco based.  Luckily the Openconnect clients work just fine.
sudo apt-get install openconnect network-manager-openconnect{,-gnome}
Then click on the Network icon in the top bar and configure a new VPN connection.  So simple I like living in the future.




We use perforce at work so I need to install the p4 and p4v utilities.  Because this get updated at a regular pace but don't have automatic updating, I have historically dumped these into version specific directories in /usr/local and then used alternatives to provide the likes to the latest.  Googling around shows that under Xubuntu, that will be update-alternatives.
Download the p4v tarball and p4 binary from perforce.
Then
cd /usr/local
(umask 022; sudo tar zxvf /tmp/p4v.tgz)
export P4VER=p4v-2015.2.1315639

sudo mv /tmp/p4 /usr/local/${P4VER}/bin
sudo chmod 0755 /usr/local/${P4VER}/bin/p4
sudo chown -R bin:bin ${P4VER}
sudo mkdir -m 0755 -p /usr/share/icons/perforce
sudo update-alternatives --install /usr/local/bin/p4 p4 /usr/local/${P4VER}/bin/p4 201502
sudo update-alternatives --install /usr/local/bin/p4v p4v /usr/local/${P4VER}/bin/p4v 201502 \
 --slave /usr/share/icons/perforce/P4-Merge_96x96.png P4-Merge_96x96.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_96x96.png \
 --slave /usr/share/icons/perforce/P4-V_16x16.png P4-V_16x16.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_16x16.png \
 --slave /usr/share/icons/perforce/P4-Merge_32x32.png P4-Merge_32x32.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_32x32.png \
 --slave /usr/share/icons/perforce/P4-Merge_16x16.png P4-Merge_16x16.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_16x16.png \
 --slave /usr/share/icons/perforce/P4-Admin_96x96.png P4-Admin_96x96.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_96x96.png \
 --slave /usr/share/icons/perforce/P4-Merge_48x48.png P4-Merge_48x48.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_48x48.png \
 --slave /usr/share/icons/perforce/P4-Merge_24x24.png P4-Merge_24x24.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_24x24.png \
 --slave /usr/share/icons/perforce/P4-Merge_48x48-badge.png P4-Merge_48x48-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_48x48-badge.png \
 --slave /usr/share/icons/perforce/P4-V_96x96-badge.png P4-V_96x96-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_96x96-badge.png \
 --slave /usr/share/icons/perforce/P4-Admin_48x48-badge.png P4-Admin_48x48-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_48x48-badge.png \
 --slave /usr/share/icons/perforce/P4-V_48x48-badge.png P4-V_48x48-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_48x48-badge.png \
 --slave /usr/share/icons/perforce/P4-Admin_32x32.png P4-Admin_32x32.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_32x32.png \
 --slave /usr/share/icons/perforce/P4-Admin_24x24.png P4-Admin_24x24.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_24x24.png \
 --slave /usr/share/icons/perforce/P4-V_96x96.png P4-V_96x96.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_96x96.png \
 --slave /usr/share/icons/perforce/P4-V_48x48.png P4-V_48x48.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_48x48.png \
 --slave /usr/share/icons/perforce/P4-Admin_16x16.png P4-Admin_16x16.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_16x16.png \
 --slave /usr/share/icons/perforce/P4-V_32x32.png P4-V_32x32.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_32x32.png \
 --slave /usr/share/icons/perforce/P4-Admin_48x48.png P4-Admin_48x48.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_48x48.png \
 --slave /usr/share/icons/perforce/P4-Admin_96x96-badge.png P4-Admin_96x96-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_96x96-badge.png \
 --slave /usr/share/icons/perforce/P4-Merge_96x96-badge.png P4-Merge_96x96-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_96x96-badge.png \
 --slave /usr/share/icons/perforce/P4-V_24x24.png P4-V_24x24.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_24x24.png



Jetbrains Rubymine time...  Download the latest version you are licensed for.  For me that is 7.1.
Unpack in /usr/local and then set up alternatives.
cd /usr/local
(umask 022; sudo tar zxvf /tmp/RubyMine-7.1.4.tar.gz)
sudo chown -R bin:bin RubyMine-7.1.4
sudo mkdir -p -m 0755 /usr/share/icons/rubymine
sudo update-alternatives --install  /usr/local/bin/rubymine.sh rubymine.sh /usr/local/RubyMine-7.1.4/bin/rubymine.sh 1 \
  --slave  /usr/share/icons/rubymine/rubymine.png   rubymine.png   /usr/local/RubyMine-7.1.4/bin/rubymine.png \
  --slave  /usr/share/icons/rubymine/RMlogo.svg   RMlogo.svg   /usr/local/RubyMine-7.1.4/bin/RMlogo.svg

cd /usr/local
(umask 022; sudo tar zxvf /tmp/RubyMine-8.0.1.tar.gz)
sudo chown -R bin:bin RubyMine-8.0.1
sudo mkdir -p -m 0755 /usr/share/icons/rubymine
sudo update-alternatives --install  /usr/local/bin/rubymine.sh rubymine.sh /usr/local/RubyMine-8.0.1/bin/rubymine.sh 801 \
  --slave  /usr/share/icons/rubymine/rubymine.png   rubymine.png   /usr/local/RubyMine-8.0.1/bin/rubymine.png \
  --slave  /usr/share/icons/rubymine/RMlogo.svg   RMlogo.svg   /usr/local/RubyMine-8.0.1/bin/RMlogo.svg
sudo chmod 644 /var/lib/dpkg/alternatives/rubymine.sh



Perforce / Rubymine integrations
~/bin/run-p4v
#!/bin/bash
PATH=${HOME}/bin:${PATH}
export PATH
function startXnest ()
{
  /usr/bin/Xnest -name P4V-Xnest -geometry 1920x1080+0+80 :1 &
  sleep 2
  /usr/bin/twm -display :1 &
  /bin/true
}
function startP4v ()
{
  export DISPLAY=:1
  ( /usr/local/bin/p4v $@ )&
  sleep 2
  /bin/true
}

#if ! ncat -4 -i 1 -l localhost 6001 2>&1 | grep -q "already in use"; then
#  startXnest
#  startP4v
#else
#  startP4v
#fi

( /usr/local/bin/p4v $@ )&
sleep 2
exit 0


~/bin/run-rubymine-as-a-tool.sh
#!/bin/bash
if echo "${1}" | grep -q '...$'; then
  DIR="`dirname ${1}`"
else
  DIR=${1}
fi
exec /usr/local/bin/rubymine.sh "${DIR}"

~/bin/run-rubymine.sh
#!/bin/bash
TMPDIR=`mktemp -d /tmp/rubymine.XXXXXXXXXXXXXX` || exit 1
cd ${TMPDIR} || exit 2
exec /usr/local/bin/rubymine.sh $@


Flash is way too insecure
sudo apt-get remove flashplugin-installer


Install rvm so I can have easy ruby management
/usr/bin/curl -sL https://get.rvm.io | bash
time rvm install ruby
gem install bundler
gem install capistrano -v 2.15.7
gem install aws-sdk-v1
gem install aws-sdk:1.66.0
gem install pry-nav
gem install aws-sdk

sudo ln -s /usr/bin/env /bin/env   # fedora compatibility


sudo apt-get install libcurl4-gnutls-dev
gem install curb -v '0.8.8'
sudo apt-get install libmysqlclient-dev libmysqld-dev
gem install mysql2 -v '0.3.20'


cd /usr/local
(umask 022; sudo tar zxvf /tmp/p4v.tgz)
export P4VER=p4v-2015.2.1458499
export ALT_VER=20150202

sudo mv /tmp/p4 /usr/local/${P4VER}/bin
sudo chmod 0755 /usr/local/${P4VER}/bin/p4
sudo chown -R bin:bin ${P4VER}
sudo mkdir -m 0755 -p /usr/share/icons/perforce
sudo update-alternatives --install /usr/local/bin/p4 p4 /usr/local/${P4VER}/bin/p4 ${ALT_VER}
sudo update-alternatives --install /usr/local/bin/p4v p4v /usr/local/${P4VER}/bin/p4v ${ALT_VER} \
  --slave /usr/share/icons/perforce/P4-Merge_96x96.png P4-Merge_96x96.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_96x96.png \
  --slave /usr/share/icons/perforce/P4-V_16x16.png P4-V_16x16.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_16x16.png \
  --slave /usr/share/icons/perforce/P4-Merge_32x32.png P4-Merge_32x32.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_32x32.png \
  --slave /usr/share/icons/perforce/P4-Merge_16x16.png P4-Merge_16x16.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_16x16.png \
  --slave /usr/share/icons/perforce/P4-Admin_96x96.png P4-Admin_96x96.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_96x96.png \
  --slave /usr/share/icons/perforce/P4-Merge_48x48.png P4-Merge_48x48.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_48x48.png \
  --slave /usr/share/icons/perforce/P4-Merge_24x24.png P4-Merge_24x24.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_24x24.png \
  --slave /usr/share/icons/perforce/P4-Merge_48x48-badge.png P4-Merge_48x48-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_48x48-badge.png \
  --slave /usr/share/icons/perforce/P4-V_96x96-badge.png P4-V_96x96-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_96x96-badge.png \
  --slave /usr/share/icons/perforce/P4-Admin_48x48-badge.png P4-Admin_48x48-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_48x48-badge.png \
  --slave /usr/share/icons/perforce/P4-V_48x48-badge.png P4-V_48x48-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_48x48-badge.png \
  --slave /usr/share/icons/perforce/P4-Admin_32x32.png P4-Admin_32x32.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_32x32.png \
  --slave /usr/share/icons/perforce/P4-Admin_24x24.png P4-Admin_24x24.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_24x24.png \
  --slave /usr/share/icons/perforce/P4-V_96x96.png P4-V_96x96.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_96x96.png \
  --slave /usr/share/icons/perforce/P4-V_48x48.png P4-V_48x48.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_48x48.png \
  --slave /usr/share/icons/perforce/P4-Admin_16x16.png P4-Admin_16x16.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_16x16.png \
  --slave /usr/share/icons/perforce/P4-V_32x32.png P4-V_32x32.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_32x32.png \
  --slave /usr/share/icons/perforce/P4-Admin_48x48.png P4-Admin_48x48.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_48x48.png \
  --slave /usr/share/icons/perforce/P4-Admin_96x96-badge.png P4-Admin_96x96-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Admin_96x96-badge.png \
  --slave /usr/share/icons/perforce/P4-Merge_96x96-badge.png P4-Merge_96x96-badge.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-Merge_96x96-badge.png \
  --slave /usr/share/icons/perforce/P4-V_24x24.png P4-V_24x24.png /usr/local/${P4VER}/lib/p4v/P4VResources/icons/P4-V_24x24.png









Still on the To-Do list
  • perforce (p4v, p4)
  • java
  • RubyMine
  • Google Chrome Profiles
  • printer setup
  • bind9
    • caching and forwarding configuration
  • openssh server
  • Codeweavers Crossover
    • microsoft steam
      • softlinking common directories to save space
      • try putting these on btrfs lv and use deduplication to reduce space
    • heidisql
  • Linux Steam
  • workrave
  • vncviewer
  • devilspie2
  • custom scripts ~/bin
  • rxvt, other terminals?
    • need to get urgent window notifications working
  • skype?
  • virtualbox
  • solution for managing ~/.cache directory
































Comments

Popular posts from this blog

Xubuntu Home Server on Dell XPS 13 9370

Cygwin + syslog-ng

Installing Fedora 21 on a (late 2014) Mac Mini