Tag Archives: Ubuntu

Cloning Linux Mint Setups

Recently I swapped in an SSD to be the new primary drive on my media center PC which was running Linux Mint 18.0 on the spinning SATA drive.

This post is basically a brief documentation of the basic steps involved in cloning or upgrading/cloning Linux Mint. Most likely this works fine for Ubuntu as well as Debian as they share a common ancestry. There are most likely limits to this scheme. I imagine things would break badly trying to do this across 17.3 and 18 for example. The base on those is a different version of Ubuntu, 14.04 vs 16.04. I might try to do a clone when the next whole number version of Mint comes along. Just pop in a drive that I don’t care about, or do it on a VM, such as Virtualbox for an experiment.

Plans

The plan is to relieve some of the storage duties of the spinning drive which was filling up. Plus a speed increase as the SSD can move data 4x faster than the spinning drive but more importantly with no moving parts the access time is minute in comparison the the spinning drive. Applications open much faster, boot time is cut by 75%, etc. If the machine needs to use swap it won’t grind down to a halt as well with a fast disk. This machine is a bit older, SATA II, but a Solid State Drive (SSD) still makes a big difference.

The idea is to clone over the home folder but exclude large data such as  the ~/Music folder and leave that on the old drive and mount the drive as additional storage and use a symlink to it.

Old Setup 160GB Spinning Drive
Old Setup: 160GB Spinning Drive
New Setup: 80GB Primary SSD
New Setup: 80GB Primary SSD

Goal

The goal of this post’s example is to  do an upgrade to Linux Mint 18.3 from 18, clone over my user settings and reinstall all programs. Over the past year and a half that the machine has been in use there have been quite a few programs that have been installed on this machine. Many of them run from the command line or are libraries related to some of the machine learning code that gets run in the background on the machine. Needless to say it would be very hard to remember them and a lot of little things would be broken.

Step 1: Install Linux Mint from USB Stick or DVD

This step is pretty basic and is covered elsewhere on the web…

Linux MintUbuntu , Debian

But needless to say you want to create a user that has the same name and User ID (UID) and Group ID (GID) as on the drive that you will be cloning from.

Step 2: Login on the new machine/drive setup kill your home directory and rsync the old one over

Mount the old drive, doing this from the GUI folder is a fine way to do it. Make note of where it mounts. You can always execute df from the command line to find where it mounted as well

It sounds crazy but, it does work. Login, open a terminal and execute…

rm -rf /home/yourusername

Everything is in memory that the OS needs right now to get through the next step, so nothing will crash and this will give you a blank slate to work with.

Next rsync over your home folder from the old drive ( /dev/sda in my case) making sure that you use the archive option. Using the v and h options as well is helpful as well to produce a lot of output in case you have to trace through a problem.

-v : verbose
-a : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
# -h : human-readable, output numbers in a human-readable format

Example:

For me it went something like this…

rsync -avh /media/erick/B0B807B9-E4FC-499E-81AD-CDD246817F16/home/erick /home/

Next log out and then back in. Almost like magic everything should look familiar. The wallpaper on the desktop should look like whatever it was on the old setup, fonts and other desktop sizing customizations should be there. Open the browser and it should be like you left it in the old setup. It is almost like you hibernated the old setup and woke it up after teleporting it’s soul into the new drive.

But, wait the software needs attention

Step 3: Bring over the software too, sort of…

More like apt-get install it over is closer to the truth. I tried following a post on how to do this (https://askubuntu.com/questions/25633/how-to-migrate-user-settings-and-data-to-new-machine) but, what was described in it did not lead to success. The suggestion was the following…

oldmachine$ sudo dpkg --get-selections > installedsoftware
newmachine$ sudo dpkg --set-selections < installedsoftware
newmachine$ sudo apt-get --show-upgraded dselect-upgrade

It didn’t work but, it at least did the collection part. So I wound up using the first part…

oldmachine$ sudo dpkg --get-selections > installedsoftware

…and then brute forced an install by doing some grep,rev,cut,rev again on the input file. Which basically flips every line in the file and removes the word “install” which is now at the beginning and backwards then flips it back over line by line.

The next line with the awk command prepends sudo apt-get install to the front of each line and saves the output to reinstall-software.sh

 installedsoftware-to-apt-get-install.sh
 #!/bin/bash
 cat installedsoftware | grep "install" | rev | cut -c 12- | rev > cleaned-installed-software
 awk '{printf "sudo apt-get install "$0"\n"}' cleaned-installed-software > reinstall-software.sh

Run the reinstall-software.sh script and it will do just what it says, install all of the software that was on the old setup. I believe there is an option for apt-get to preanswer Yes when it comes up and asks you the yes or no question about installing. I left it off so that I could review all the larger sized software being loaded. A few times I hit no by accident so had to re-run the script, no big deal.

Reboot is best now to avoid side-effects

Before going much further a reboot is probably in order as so much has changed on the machine.

For me, during the software install process, I was presented with a question about picking LightDM or another X- windows manager. I picked LightDM because I think that is what I had been using. After I was all done, I put the machine in suspend and it had a bit of trouble coming out of it, having a temporary error related to the X-windows manager. A blue screen came up and had a message about removing a temporary file. Just rebooting the machine cleared this up as the /tmp directory is flushed. Apparently this was something that was set before the upgrade, clone and software install process and did not get unset. Other than that I have seen no side effects from the process of upgrade, clone, software install.

Other Items

If you had files configured outside of the home directory such as /etc/hosts, you will obviously have to copy that over. Also, if you have any /etc/cron.hourly,weekly,monthlies that you put on the old machine. Also, it pays to do a dump of crontab’s using crontab -l > crontab-dump.txt on the old setup so they can be reconfigured to the same settings.

Cloning old to new box

This entire process can be used to clone one computer setup to another, old box to new one for example. Which brings us to…

Final Thoughts: Twin Machines

It is entirely possible to keep two machines in sync using the methods outlined above. I have not tried this but I am tempted to test it out at least. What I am thinking of is a laptop and desktop for instance. The desktop with it’s ability to hold multiple drives with ease works nice here It has one drive with the same OS as the “twin” laptop and is setup as multi OS boot. The steps above are executed, cloning the laptop setup and data to the desktop. It is entirely possible to keep cloning the home folder contents back and forth between the two to keep them sync’d. Even the software can be kept in sync using the method used above to re-install it.

It is possible to do this directly between them, both on at the same time. Or, through a server where they both get backed up to. The only caveat is overwriting and deletions. Such as care when using the –delete option with rsync. There is a potential for a race condition of sorts if settings and files get changed and then clobbered by a sync operation. If I were to try this I would start with a one direction sync. One device is the master and the other the slave. Deletions and settings changes get cloned from master to slave automatically only.

Upgrade from Ubuntu 13.04 to Ubuntu 14.04 LTS in 5 steps

When we got back from house sitting this winter and back into my regular house, I finally got around to installing a newer version of Lubuntu Linux on my desktop at home, I wanted to get away from using Windows XP and didn’t feel like installing a new version of Windows. The original Wildcat video card on the PC didn’t support Linux well, so I installed an old GeForce card I had sitting in a box from a carcass machine. It was a moment where I said, why didn’t I think of this years ago! I first installed Linux 5 years ago on it, saw that the video didn’t work quite right and didn’t really dig any deeper than trying a lot of settings changes, the gave up and lived with it. I used XP heavily on it and I have to admit I was pretty OK with the way XP was working on it, so it was a case of leave it alone if it is OK.

I actually left the other video card ( an expensive Wildcat card, large unit fits the full footprint for the bay. It cost $2K for the company that bought it for CAD/CAM usage originally) in place. I found a setting in the BIOS for Legacy detection of video, it was set to AGP, I switched it to auto, seems to work!

But, now I have it pretty much set up and working good. The machine has 2 identical hard-drives that have copies of the same stuff and 2 copies of Win XP, one on each drive. Plus I back it up to an external server, when I remember to, its been too long already! I can start it in Linux (Lubuntu 14.04 LTS or Ubuntu Server 12.04, for testing) or one of the 2 XP’s, but I am pretty much going to keep using Lubuntu Linux on it, faster than XP was and doesn’t crash, it just works better in general.

Tutorial Page

The tutorial page below  worked well. I had the Lubuntu 13.04 CD for Lubuntu from trying it out on one of my old servers a few years back. I used it to install on my desktop because the unit  doesn’t have a DVD player and Lubuntu 14.04 LTS is just a tad oversized for a CD. When the install was going on I just selected the root directory to go in the same place (on sdb5 in my case) as the old 9.10 Ubuntu install. At this question it was choose OTHER and not side by side or wipe drive for me.

Then I used the steps in the tutorial to migrate from Lubuntu 13.04 to Lubuntu 14.04 LTS. (I did try Lubuntu 15.04 which fits on a CD, but it did not run, checked the disc and MD5 sum too, but it just might not be compatible with the machine). The only things I did above and beyond the tutorial was to run..

sudo apt-get update && sudo apt-get upgrade

…before and after installing Lubuntu 14.04 LTS. And after the final update and upgrade I ran…

sudo apt-get autoremove

…to remove pieces of Lubuntu 13.04 that were not needed with Lubuntu 14.04 LTS.

http://www.tuxtrix.com/2014/03/upgrade-from-ubuntu-1304-to-ubuntu-1404.html

Fermented Figs Timelapse

Nothing beats combining two things that are interesting together. I’ve been into fermenting foods and beverages since the late 1990’s and have been experimenting with timelapse photography since late in 2013 ( One of the first projects I set up and Ubuntu Server for ). Combining them together has been an interesting experience lately.

Recently I bought a 50.5 Ounce glass container with a gasketed lid. I got the idea from reading The Art of Fermentation by Sandor Ellix Katz, a must have if you are considering getting serious about fermentation, it covers a lot of territory on the fermentation landscape. This jar is ideal for some fermentation experiments as any pressure built up in the container would vent via the gasketed lid.  A lot of times, I don’t worry about pressure build up, because I am close to home and can vent it manually. But this time I was going to be away so this jar would be good to use. I decided to try to ferment some figs in it and create a time lapse video by taking photos every 4 minutes. I ran it for a week, almost 2400 frames.

The Ferment Mixture

The figs were a bit on the hard side so they were not getting used up to much and I decided that they would be good candidates for a fermentation experiment. The fermentation was started by cutting up the figs into small bits and added some sugar water and a pinch of bread yeast. Normally I would have let them ferment naturally based on what wild yeasts are present on the fruit, but I wanted a vigorous fermentation that got going quickly in order to capture the action for the timelapse video.

Timelapse Video Setup

The setup for the timelapse video was a laptop running Ubuntu with Apache and a webcam. The program used to take the frames for the timelapse video is fswebcam ( which I cover in the post on Bread Dough Rising Timelapse GIF ). The frames were taken every four minutes and saved into a folder underneath my home directory. Additionally a frame was copied to the /var/www directory to allow it to be seen on the web. Plus, I have a symbolic link from /var/www to a directory called fswebcam under my home directory. This directory holds the scripts to run fswebcam, under this is a directory called timelapse which collects all of the frames. This allows me to flip through these from the web as well, so I can keep track of the fermentation progress.

I went away for a few days while I was running the timelapse frame capture and it was nice to be able to view it to check on the progress. To get it online, I basically added a virtual server on the router for port 80, pointing to the internal IP address of the laptop, which was hooked to the router via WiFi. This worked flawless and I was able to periodically check in on the fermentation while on the road.

Fig Fermentation Timelapse Photography Setup
Fig Fermentation Timelapse Photography Setup

 

Timelapse Video AVI

Fermenting Figs 1 frame every 4 minutes for 31s of video