Sunday, November 27, 2011

Backups

Since SSD-s are still viewed as not as durable storage devices as hard disk drives, one needs at least to consider doing backups. Preferably to a HDD. Since I have accumulated a good deal of files and pictures over the years and like to keep them present for some time I decided also to join the SSD-are-probably-not-as-durable-as-HDD-s band and start doing backups of my files. I have 2 external HDD-s. One is my old 80GB 5400rpm drive that came with my T60. The other is an upgrade to that, 256GB 7200rpm. Now that the T60 is gone I can use them both to hold my backup data. Since my SSD drive holds only 128GB - not big enough for all the data I'd like to store - I decided to use the 80GB drive as a storage device and the 256GB drive for backups.

So I included both of my external HDD-s to /etc/fstab, so automounting is easy (mount -a). Once that is done, I move files that I don't need on my laptop to the external 80GB drive. Then I run the backup script:

.backup.sh

sudo sh -c "
rsync -av --delete-excluded --exclude-from=.backup.lst / /media/backup/;
touch /media/backup/BACKUP
"

Backup is done using the program called rsync. What the script does is it is taking every file from root folder recursively (/) and copying it to /media/backup/ folder that is the mountpoint of my 256GB external HDD. The script will exclude every file included in .backup.lst file (there sould be definitely an entry for the mountpoint of the backup drive to avoid infinite loop, in my case /media/backup/):

.backup.lst

#Include
+ /dev/console
+ /dev/initctl
+ /dev/null
+ /dev/zero

#Exclude
- /dev/*
- /proc/*
- /sys/*
- /tmp/*
- lost+found/
- /media/backup/*



Usually the locations that contain runtime data for the operating system are excluded.

So the simple steps to backing up my data include:
1) connect the external drives to laptop
2) mount -a
3) move neccesary files to 80GB drive
4)./.backup.sh

and done.

Sunday, October 16, 2011

Archlinux and Thinkpad T410s

So, shit. It appears that I was not paying attention when I was making partitions to my SSD. Everybody knows that you are supposed to make your swap partition at least the size of your usable RAM, right? Well it seems I did not make it that big. How do I know that? Simple, pm-hibernate is not hibernating.

One thing though: SSD is fast. I have read some articles where new SSD owners state that they are never going to switch back to HDD drives, even if the statistics shows that SSD-s will break up several times per year (worst case). It's because SSD is fast and you should backup your data anyway. I agree with them.

Of course, my 128GB drive is small compared to standard HDD-s that ship with modern laptops, but for programs and some pictures and files it's big enough. For backup I have 2 external HDD drives. They also store files that I don't plan to use frequently.

Tuesday, October 11, 2011

Archlinux and Thinkpad T410s

 II


Thinkpad laptops (and laptops in general) have special actions mapped to certain keys, which can be accessed with "Fn" key. For example, "Fn+F4" will suspend the laptop to RAM. Of course that happens only in the pre-installed Windows 7. If you install linux you usually have to configure those keys to do the actions they're supposed to yourself. There are some keys that work out of the box, for example the "Fn+PgUp" will toggle the Thinklight, and also the screen brightness can be adjusted using the predefined keys ("Fn+Home" and "Fn+End"). In my old Thinkpad T60, the volume buttons were also working (probably hardwired), but in T410s this is not so.

Fortunately Awesome (also Openbox, and probably other WM-s and DE-s) will allow you to define global keys. In rc.lua (usually placed in ~/.config/awesome) you can define your own key codes and map some action to them. Here's an example:

awful.key({}, "XF86AudioPrev",function () awful.util.spawn("mocp -r") end)


What this does is it maps the key "XF86AudioPrev" to do the action "mocp -r". In Thinkpads "XF86AudioPrev" is mapped to "Fn+Arrow left". This is supposed to select previous song from some audioplayer. What it does in my system is it will select previous song in MOC.

To assign the actions to the keys you need to know the key names and of  course some program to do the task (preferably something similar to the task that was configured under Windows). For the key names I used a program called xev that prints out different data it receives by events (key presses etc.) generated by X.

Here is a list of various configured keys in my system:

globalkeys = awful.util.table.join(
...
awful.key({}, "XF86AudioPrev",function () awful.util.spawn("mocp -r") end),
awful.key({"Control"}, "XF86AudioPrev",function () awful.util.spawn("mocp -k -10") end),
awful.key({}, "XF86AudioNext",function () awful.util.spawn("mocp -f") end),
awful.key({"Control"}, "XF86AudioNext",function () awful.util.spawn("mocp -k 10") end),
awful.key({}, "XF86AudioPlay",function () awful.util.spawn("mocp -G") end),
awful.key({"Control"}, "XF86AudioPlay" ,function () awful.util.spawn("mocp -p") end),
awful.key({"Control", "Mod1"}, "XF86AudioPlay",function () awful.util.spawn("mocp -S") end),
awful.key({}, "XF86AudioStop",function () awful.util.spawn("mocp -s") end),
awful.key({"Control"}, "XF86AudioStop",function () awful.util.spawn("mocp -x") end),
awful.key({}, "XF86AudioRaiseVolume",function () awful.util.spawn("amixer set Master unmute 2%+ > /dev/null") end),
awful.key({}, "XF86AudioLowerVolume",function () awful.util.spawn("amixer set Master unmute 2%- > /dev/null") end),
awful.key({}, "XF86ScreenSaver",function () awful.util.spawn("slock") end),
awful.key({}, "XF86AudioMute",function () awful.util.spawn("amixer set Master toggle > /dev/null") end),
...
)



So, for locking the screen I use slock, suspend works via pm-utils. Music is served through MOC server and since the audio functionality is provided by ALSA, all the volume actions are done through amixer. One thing to note with the volume buttons is that when the volume is muted, pressing the volume up or down button will unmute it and then increase or lower the volume. So for every time the volume raise or volume lower button is pressed you have to explicitly unmute the mixer for the keys to work as expected (of course you could make a script that checks if the volume is muted and only then unmute it).

Going to go ahead and add hibernation functionality now, see how it goes (on T60 it stopped working correctly after some use so I had to disable it).

Monday, October 10, 2011

Archlinux and Thinkpad T410s

I


Since I've been using linux (more specifically Archlinux) for a long time now, I decided to use it as an OS on my new Thinkpad T410s. The following is a series of notes on how the integration of these two goes.

So first some pictures

Archlinux desktop view. The window  manager I use is Awesome
The desktop view is quite minimalistic, and that, I think, is a good thing. In the upper left corner one can see the links for the 6 different desktops (first one is selected). The upper right corner shows the date and time, current CPU usage, memory usage, battery level and CPU temperature.

Some windows open. In the background there is Thunar filemanager and in the foreground there is chrome running with google search page displayed. What is neat is that the desktop theme I use under Awesome is also available for chrome and it seems google+ also uses somewhat similar theme.


The desktop theme I use is Elegant Brit and the icon set is area.o43 (the Awesome theme is Zenburn with slight modifications to fit the desktop theme). These two seem to fit nicely together.

So this is the gist of what can be seen with an eye. There is a lot more that goes on under the cover, but more about it in next posts.

First!

I win, lol.