Thursday, January 01, 2009

4 Ways to Make a Linux Reinstall Easier

I tend to grow dissatisfied with my current Linux distribution from time to time, and start looking around at other distributions. As I've done this, I've learned a few tricks that make it a lot easier and faster to get the new setup running and working for me.

1) Separate partition for /home


I can not stress this point enough. All of your configuration settings are stored in your user account under /home. All of your documents, downloads, wallpapers, etc. are stored in your user account. Any program settings are stored in /home. Generally, all files that you have created or worked on live somewhere in /home. If you have a separate partition for /home then you can reinstall Linux and have it configured (on a user level) the same way the old install was.

If you don't currently have a separate partition for /home, then you should make sure to create one during your next Linux install. It will make all future installs a lot easier.

If you have any important files elsewhere in your filesystem (like a webpage you've put in /var/www) then you might want to consider making that a separate partition as well, or at least have backups.

The only issue I've ever had with this is with the default user id the distributions use. You need to make sure that the your users have the same uid as they had on the previous distribution, or chown their home directories so that they belong to the proper users.

2) Multiple partitions for installing


This one is a little less obvious, but it has been very good to me. I like to have more than one partition for installing Linux. I alternate which partition I use for every install so that I always have my previous install to go back to. If something isn't working in my latest Arch install, I can just boot back into Debian. If the latest Ubuntu install has issues then I can boot into the previous version.

I like to have 10 GB partitions for linux installs. I usually only use about half of that, but it leaves room for growth without eating up too much disk space. The rest of my disk is usually reserved for my home partition.

3) Keep a list of your commonly installed packages


If you're switching from one Debian based distro to another, then a combination of dpkg and dselect can be very useful. Look here for more information: http://mybrainrunslinux.com/node/2

Whether you're using yum, rpm, yast, pacman, or dpkg you can get a list of installed packages and use that as a guide for what you'll need to reinstall in your new distribution. If you do this very often you will probably become very familiar with the packages you need to get everything back to normal.

4) Use Foxmarks (if you use Firefox)


Ok, this one isn't very useful if you're reinstalling on the same computer and using a separate partition for home, but it is very nice if you are installing on a different computer or if you don't have a separate home partition. Foxmarks is a Firefox extension that synchronizes bookmarks. If you use it then all you have to do in a fresh install is install the plugin and synchronize your bookmarks. Where this plugin really shines for me is multiple computer use. Whether I'm using my work computer, my home computer, or any other computer where I have an account, I have the same set of bookmarks. I love it. If you're concerned about hosting your bookmarks on somebody else's server, you can always configure Foxmarks to save its file on your own server.

Conclusion


I titled this post "4 Ways to Make a Linux Reinstall Easier", but most of the points in here could equally apply to making it easier to move to a new computer. Some of them make it easier to simultaneously use multiple computers that all have the same user settings and data. Hopefully some of these tips can make the process a lot easier for you.

If all you want to do is try out a new distribution, you do have an alternative--Virtual Box (or VMWare, or etc). You can install Linux in a virtual machine (whether you're running Linux, Windows, or Mac) and run it without having to worry about partitions and without erasing your current operating system.

Tuesday, December 16, 2008

Heroes and relativity

I don't want to make this a theme, but I really feel like complaining about Heroes right now.

If you haven't seen last night's episode (Season 3 Episode 13 - Dual), then you might not want to read this. I'll try to keep spoilers to a minimum, but I need to spoil a little bit to get my point across.

Last night's episode wasn't bad, but their physics were horrible. I am always more than willing to suspend my belief for a good story. I love the super powers--flight, time travel, all that weird stuff Sylar and Peter can do, etc.. If you're going to explain how the powers work though, at least tell us something acceptable. Maybe Daphne's ability is related to time. Maybe she can move really fast because she's really just slowing time down. Maybe when coupled with Ando's new power she can manipulate time even better and is able to travel back and forth through time.

Don't feed us a bunch of crap about how she can travel through time because she runs so fast that she can travel through time. The theory of relativity doesn't work that way, so don't tell us that it does. Find some other way to tell the story. You can let Daphne time travel without lying to us about physics.

Here's to a new season of Heroes. May it be better than the last couple of seasons.

Wednesday, December 10, 2008

Maze generation in Python

When I was in school, I created (as an assignment) a program that created mazes and allowed the user to run through it in 3D. I used a recursive backtracking algorithm to create the maze. While this isn't a bad way to do it, I wanted to try implementing a different solution in python.

Enter Kruskal. Kruskal's algorithm is an algorithm used to find a minimum spanning tree for a graph. If this doesn't sound like a good way to build a maze, just hang on. I'm getting there. A lot of the time, the most difficult part of applying an algorithm to a problem is fitting it into some sort of data structure. A maze makes a perfect graph--every square is a node in the graph. Every square that is not separated by a wall is connected.

For more details on graph theory or Kruskal's algorithm, Wikipedia is your friend.

Back to the point: I love how simple the python implementation is.


width, height = 20, 20

# create a list of all walls
# (all connections between squares in the maze)
# add all of the vertical walls into the list
walls = [(x,y,x+1,y)
for x in range(width-1)
for y in range(height)]
# add all of the horizontal walls into the list
walls.extend([(x,y,x,y+1)
for x in range(width)
for y in range(height-1)])

# create a set for each square in the maze
cell_sets = [set([(x,y)])
for x in range(width)
for y in range(height)]

# in Kruskal's algorithm, the walls need to be
# visited in order of weight
# since we want a random maze, we will shuffle
# it and pretend that they are sorted by weight
walls_copy = walls[:]
random.shuffle(walls_copy)

for wall in walls_copy:
set_a = None
set_b = None

# find the sets that contain the squares
# that are connected by the wall
for s in cell_sets:
if (wall[0], wall[1]) in s:
set_a = s
if (wall[2], wall[3]) in s:
set_b = s

# if the two squares are in separate sets,
# then combine the sets and remove the
# wall that connected them
if set_a is not set_b:
cell_sets.remove(set_a)
cell_sets.remove(set_b)
cell_sets.append(set_a.union(set_b))
walls.remove(wall)


I'm sure there are things here that could be improved, but I really like the way Python works. If I were to implement this in C++, it might run faster (not that it needs to, the mazes are generated fast enough in Python) but it would take a lot longer to write and would end up with a lot more code.

Tuesday, December 09, 2008

Wall-E is bad science fiction

I should go ahead and write this down before I try searching about it on google, because I'm pretty sure that somebody else has already written something very similar.

I realize that Wall-E is intended for kids. I don't care. It doesn't work. I don't even care about the political agenda they are trying to push. Go ahead and push it, but at least make a few details plausible.

Even if it is possible for the earth to become that polluted and devastated, at least give some reason on how that could have happened. I just can't believe that people would be able to create that much waste without realizing that there was a problem and doing something about it. In addition, it seemed that most of the garbage was some form of metal. It would probably be easier to melt it down and reuse it than it would be to mine fresh ore out of the earth.

How could a seed have possibly sprouted on an earth that had been barren for 700 years? Where did it come from? If by some miracle a seed had been able to survive and still be viable after 700 years of crop withering weather, how could it have started growing? I didn't see any water, and it didn't get any sun--it was growing on the inside of a refrigerator.

The people kept having children for 700 years, even though they didn't seem to ever talk to each other in person or ever touch each other. The only thing that I can think of is that the robots harvest the seeds and grow the babies in tubes somewhere.

When the people (with major bone density loss) return to earth, they are able to walk with no problems, even though they have never walked in their lives. They never even walked in space. They were completely helpless if they ever even fell out of their chairs.

On earth, the plant was re-planted. Somehow, this plant, which was discovered on earth, was able to turn into millions of plants. It was able to cover the entire earth. Not only was it able to cover the entire earth, it was able to grow an endless variety of plants. I also saw, during the credits, birds, animals, and fish. This was not some remnant of earth life that somehow survived the 700 lifeless years. The flora and fauna came from nowhere.

I take umbrage. Please, please, if you are going to make science fiction movies, at least make them a tiny bit plausible.