Archive

Archive for February, 2014

Cloud Saves for Minecraft

February 21st, 2014 No comments

I’ve recently become addicted to Minecraft. I realize that I’m late to this game, having only recently discovered it despite its popularity over the past couple of years. As readers know, I typically switch between a few different machines throughout my day, and indeed between a few different operating systems. Luckily, Minecraft is portable and can be played on any platform – but how to go about transferring saved games?

By default, Minecraft puts your user data and game saves in a hidden folder within your home folder. In particular, save game data is stored at ~/.minecraft/saves/. My solution to the cloud save problem was to create a minecraft folder in my DropBox, and then symlink the default save folder to this location.

Start by creating a folder in your DropBox (or other cloud share platform) folder:

jonf@UBUNTU:~$ mkdir ~/Dropbox/minecraft
jonf@UBUNTU:~$ mkdir ~/Dropbox/minecraft/saves

Next, back up your existing save games folder. We’ll restore these once the symlink has been created.

jonf@UBUNTU:~$ mv ~/.minecraft/saves/ ~/.minecraft/saves.old

Now create the symlink between the new DropBox folder and the save game location:

jonf@UBUNTU:~$ ln -s ~/Dropbox/minecraft/saves/ ~/.minecraft/saves
jonf@UBUNTU:~$ ls -la ~/.minecraft
total 24
drwxrwxr-x  3 jonf jonf  4096 Feb 21 08:58 .
drwx------ 43 jonf jonf 12288 Feb 21 08:55 ..
lrwxrwxrwx  1 jonf jonf    38 Feb 21 08:58 saves -> /home/jonf/Dropbox/minecraft/saves/
drwxrwxr-x  2 jonf jonf  4096 Feb 21 08:55 saves.old

As you can see, the saves folder under the .minecraft folder now points to the saves folder that we created inside of our DropBox folder. This means that if we put anything inside of that folder, it will be automatically written to the DropBox folder, which will be synced to all of my other computers.

Finally, let’s restore the existing saved games folder into the new shared folder:

jonf@UBUNTU:~$ mv ~/.minecraft/saves.old/ ~/.minecraft/saves

If I take the same steps on my other machines, then I can play Minecraft from any of my machines with my saved games always available, no matter where I am. Keep in mind that the ln syntax for Mac OSX is slightly different than the example above. The steps remain the same, but you’ll want to check the docs if you’re trying to adopt these steps for a different platform.




On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.

Extend the life of your SSD on linux

February 9th, 2014 1 comment

This past year I purchased a laptop that came with two drives, a small 24GB SSD and a larger 1TB HDD. My configuration has placed the root filesystem (i.e. /) on the SSD and my home directory (i.e. /home) on the HDD so that I benefit from very fast system booting and application loading but still have loads of space for my personal files. The only downside to this configuration is that linux is sometimes not the best at ensuring your SSD lives a long life.

Unlike HDDs, SSDs have a finite number of write operations before they are guaranteed to fail (although you could argue HDDs aren’t all that great either…). Quite a few linux distributions have not yet been updated to detect and configure SSDs in such a way as to extend their life. Luckily for us it isn’t all that difficult to make the changes ourselves.

Change #1 – noatime

The first change that I do is to configure my system so that it no longer updates each files access time on the SSD partition. By default Linux records information about when files were created and last modified as well as when it was last accessed. There is a cost associated with recording the last access time and including this option can not only significantly reduce the number of writes to the drive but also give you a slight performance improvement as well. Note that if you care about access times (for example if you like to perform filesystem audits or something like that) then obviously disabling this may not be an option for you.

Open /etc/fstab as root. For example I used nano so I ran:

sudo nano /etc/fstab

Find the SSD partition(s) (remember mine is just the root, /, partition) and add noatime to the mounting options:

UUID=<some hex string> /               ext4    noatime,errors=remount-ro

Change #2 – discard

TRIM is a technology that allows a filesystem to immediately notify the SSD when a file is deleted so that it can more efficiently manage the underlying storage and improve the lifespan of the drive. Not all filesystems support TRIM but if you are like most people and use ext4 then you can safely enable this feature. Note that some people have actually had drastic write performance decreases when enabling this option but personally I’d rather have that than a dead drive.

To enable TRIM support start by again opening /etc/fstab as root and find the SSD partition(s). This time add discard to the mounting options:

UUID=<some hex string> /               ext4    noatime,errors=remount-ro,discard

Change #3 – tmpfs

If you have enough RAM you can also dedicate some of it to mounting specific partitions via tmpfs. Tmpfs essentially makes a fake hard drive, known as a RAM disk, that exists only in your computer’s RAM memory while it is running. You could use this to store commonly written to temporary filesystems like /tmp or log file locations such as /var/logs.

This has a number of consequences. For one anything that gets written to tmpfs will not be there the second you restart or turn the computer off – it never gets written back to a real hard drive. This means that while you can save your SSD all of those log file writes you also won’t be able to debug a problem using those log files on a computer crash or something of the like. Also being a RAM disk means that it will slowly(?) eat up your RAM growing larger and larger the more you write to it between restarts. There are options for putting limits on how large a tmpfs partition can grow but I’ll leave you to search for those.

To set this up open /etc/fstab as root. This time add new tmpfs lines using the following format:

tmpfs   /tmp    tmpfs   defaults  0       0

You can lock it down even more by adding some additional options like noexec (disallows execution of binaries on the filesystem) and nosuid (block the operation of suid, and sgid bits). Some other locations you may consider adding are /var/log, /var/cache/apt etc. Please read up on each of these before applying them as YMMV.

Categories: Hardware, Tyler B Tags: , , , , ,

Change the default sort order in Nautilus

February 9th, 2014 No comments

The default sort order in Nautilus has been changed to sorting alphabetically by name and the option to change this seems to be broken. For example I prefer my files to be sorted by type so I ran

dconf-editor

and browsed to org/gnome/nautilus/preferences. From there you should be able to change the value by using the drop down:

 

Seems easy enough

Seems easy enough

Unfortunately the only option available is modification time. Once you change it to that you can’t even go back to name. This also appears to be a problem when trying to set the value using the command line interface like this:

dconf write /org/gnome/nautilus/preferences/default-sort-order type

I received an “error: 0-4:unknown keyword” message when I tried to run that.

Thanks to the folks over on the Ask Ubuntu forum I was finally able to get it to change by issuing this command instead:

gsettings set org.gnome.nautilus.preferences default-sort-order type

where type could be swapped out for whatever you prefer it to be ordered by.

Great Success!

Great Success!