Quantcast
Viewing all articles
Browse latest Browse all 10

Upgrades and Solutions

Let’s face it, upgrading a distribution sucks. In my entire career in Linux, I have had to upgrade my distribution of choice at least once (usually because I’m changing distributions and upgrades are done every 6 months). Out of each and every distribution upgrade I have done, every single one broke my system. Not always to the point that I lost all my data, that only happened maybe once or twice. But, stability and speed usually would take a nose dive every time. There is a simple and easy solution to this that I want to go over.

Installation.

That’s right, do not upgrade, just install the latest version. This will give you a fresh install every 6 months and if your system is set up just right, will seem more like an upgrade because none of your data or settings will change. First, I need to go over partitioning.

If you are running your operating system on one sole partition, you need to be shot. There are so many benefits to partitioning your hard drive that it only makes sense to. Let me go over some of the benefits.

  1. Speed. There is a slight increase in seek times if there is a smaller partition that needs to be scanned for a file.

  2. Security. Easily specify which partitions should have noexec permissions or read-only file systems mounted, cutting down on a lot of maliciousness.

  3. Organization. Knowing where everything is and should be makes life a whole lot easier.

And now the list of down sides to partitioning.

  1. Takes slightly more time to set up.

Okay, now that is out of the way, next up is what to do with your brand new hard drive. Think of it in this manner.

[Operating system]|[User space]

Now, those two should be jailed off from each other. This will make sure that all user data will stay in one location, untouched by any system operations (unless specified to). Now, within the [Operating system] space, there are more splits needed for things like SWAP space, logs and tmp files. Here is my current partition scheme on my main desktop.

[~]$ df -ht ext4
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6              47G  7.2G   38G  17% /
/dev/sda5             4.7G  138M  4.4G   4% /tmp
/dev/sda1             958M   58M  851M   7% /boot
/dev/sda8             861G  360G  457G  45% /home

Now, the thing you have to see is, I have 4 partitions on my hard drive. Really, for my main desktop, that is all I need. Now, of course, if this was a production server, well, it wouldn’t be a production server. But, I will go over a little bit on this.

/home is my home directory. This is where all my user data and user installed games and applications go. By “user installed” I am talking about games and programs which had a binary already in the tarball or zip and did not require installation into /usr to run. This partition will remain untouched by our installation process so we will never have to deal with it.

/boot is always supposed to be the first partition and placed in the beginning, I don’t feel like I should have to explain why.

/tmp is, of course, the temp directory. It has it’s own partition because of security reasons (remember I mentioned that before?). This partition will get mounted with noexec at boot time. This will prevent someone from running arbitrary code from there.

And the last partition is /. Nothing else really needs to be said about that. (I could have put /var/log on its own partition, but, like I said, this is a desktop, not a server.) The only other partition that is not displayed in the output of df is the SWAP partition. And that is because, really, you shouldn’t have direct access to that.

Now, out of those 4 partitions, there is only one that will ever get touched when doing an upgrade, that is the root(/) partition. All of your settings and configurations are stored in ~/.config (for the most part). So, even if you uninstall an application, the users configuration file will still be there, just in case if they decide to reinstall it later.

Now, when it comes time to upgrade your distribution, you just need to download the ISO, burn it to CD, boot off it and when it gets to the part of the installation where it asks to partition your hard drive, you select to do it manually and all you have to do is tell it to format /dev/sda6, set its mount point to root(/) and tell it to mount the other partitions without touching them. And now, you have the latest version of your distribution and all of your data is still in tack. But, there are some other things that will require you truly get your system back to the way it was. And for this, it requires a lot of leg work early on, but makes it so much more simpler later on. You need to create a bash script to handle downloading and installing all third party repositories and installing all other applications that were installed after the initial installation. I will show you my script to give you an example of what I had to do.

# Install packages from Ubuntu
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y a7xpg a7xpg-data abuse abuse-lib abuse-sfx audacity audacity-data eclipse eclipse-jdt eclipse-pde eclipse-platform eclipse-platform-data eclipse-plugin-cvs eclipse-rcp gimp gimp-data gimp-data-extras gunroar gunroar-data hwinfo kobodeluxe kobodeluxe-data moc mplayer mu-cade mu-cade-data nautilus-open-terminal noiz2sa noiz2sa-data parsec47 parsec47-data pavucontrol pidgin pidgin-data pidgin-libnotify rrootage rrootage-data sound-juicer titanion titanion-data torus-trooper torus-trooper-data ubuntu-restricted-extras val-and-rick val-and-rick-data xchat xchat-common virtualbox-ose virtualbox-guest-additions thunderbird chromium-browser build-essential dpkg-dev checkinstall xz-utils libsdl1.2-dev cmake compizconfig-settings-manager php5-cli
if [ $? != 0 ]; then
echo "The Install failed!"
else
echo "The install finished. Moving on to step two."
fi
# Add Wine PPA and install
sudo add-apt-repository ppa:ubuntu-wine/ppa
if [ $? != 0 ]; then
echo "Could not add the Wine ppa!"
else
echo "Added the Wine ppa."
fi
sudo apt-get update
sudo apt-get install -y wine
if [ $? != 0 ]; then
echo "Installation of Wine failed!"
else
echo "Installed Wine."
fi # Add PlayDeb and install games
sudo echo "deb http://archive.getdeb.net/ubuntu lucid-getdeb games" | sudo tee /etc/apt/sources.list.d/getdeb-games.list
if [ $? != 0 ]; then
echo "Failed installing the playdeb repo!"
else
echo "Added GetDeb Repository"
fi
wget -q -O- http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
if [ $? != 0 ]; then
echo "Failed to install the PGP key for Playdeb!"
else
echo "Installed the PGP key for Playdeb."
fi
sudo apt-get update
sudo apt-get install -y astromenace astromenace-data vavoom autodownloader nazghul nazghul-data soulfu soulfu-data violetland violetland-data warzone2100 warzone2100-data urbanterror urbanterror-data teeworlds teeworlds-data
if [ $? != 0 ]; then
echo "Failed to install the games!"
else
echo "Installed the games."
fi

Yes, I did put checks at almost every step of the script and there is one part that I will have to manually edit every time, but once I change the location of the getdeb repository, all I have to do is run that script and everything I installed will be reinstalled on the new version. The only problem is, writing this script took a really long time all because I had to generate the list of applications AFTER having them all installed already. Here is an easy method if this is the first time you installed Ubuntu. After your fresh install, run the following command…

dpkg -l | tr -s “ “ | awk '{ print $2 }' > fresh_install_package_list&lt

This will place a list of all packages installed. Then, when you are ready for the upgrade, run the same command to a different file, then use diff to make a list of all names that are in the second list but not in the first to get a complete list of all programs you installed after the initial installation.

diff –normal <first file> <second file>

This will produce an output something like this.

[~]$ diff --normal list1 list2
7a8,10
> abuse
> abuse-frabs
> abuse-sfx

The “7a8,10” can be omitted as well as the greater-than symbols. But, there you have it. Another method to handling distribution upgrades. Like I said, yes, this is a slight pain in the ass to set up, but once you are done, it makes life all that much better.


Viewing all articles
Browse latest Browse all 10

Trending Articles