A bit about

Hello, everyone! All you can see below is just my bank of information. Some material I've found in the fathomless net, some I've learned myself. Don't think all of the information here is right or actual, but may be it could be of use for you :) All feedback is welcome, especially constructive ones :)

Thursday, March 26, 2009

Shell: Reading a file line-by-line as is

I faced this problem when I had to copy one file to another, but change or skip some lines. It's mandatory that all spaces of the copied lines were left unchanged. First of all I've tried this script:
cat "$original_file" | while read str; do
{some analysis of str variable}
echo "$str" >> "$new_file";

But it cut all leading and trailing spaces in the new line (it's a feature of "read" tool). Fortunately, it provides $REPLY variable if run without arguments. In this case $REPLY contains the line as is, with all spaces. So the working code was:
cat "$original_file" | while read; do
{some analysis of str variable}
echo "$str" >> "$new_file";

Wednesday, March 18, 2009

apt-get MergeList problem

If you have the following error while calling apt-get update:
# apt-get update
E: Dynamic MMap ran out of room
E: Error occurred while processing util-linux (NewVersion1)
E: Problem with MergeList /var/lib/apt/lists/ftp.debian.org_debian_dists_etch_main_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.

The first solution is to try removing all downloaded lists:
# rm -vf /var/lib/apt/lists/*
Or move to some backup directory and remove from there later if there're no other problems.

If it doesn't help, try to find same of very similar repositories in the /etc/apt/sources.list and remove one of them. They can conflict with each other. Don't forget to repeat the first solution in order to clear cache

Tuesday, March 10, 2009

Experience with Sabayon 4 (Linux)

Yesterday I tried to install Sabayon 4 on my desktop. The reason for this was double-side DVD with 2 Linux distributives which goes with Linux Format magazine. I realized that if I have several different Linux'es why don't I just install them for several weeks and try.

After that I decided to rearrange my primary HDD. Before this I had 3 partitions on my 80Gb HDD: the first for Windows (40Gb) because I used to play some gluttonous games, the second (~30Gb) for Linux and the rest for Linux swap. I made the following changes: left Win partition unchanged, left swap unchanged, reduced Linux partition to about 14Gb. On the freed space I created 8Gb partition for the temporary Linux system and 4Gb partition for home directories. So, everything was ready for the new installation.

Insert Boot DVD and see the initial screen which offers boot from LiveCD (with ability to install OS, like in Ubuntu), try a 3D game (I don't remember it's name), start text-mode installation and start graphical installation.

A few words about LiveCD. It boots quite long (comparing with Ubuntu 8.10 from the previous LXF), but in the end you have quite stylish desktop, with running compiz, Firefox, several 3D games and lots of tools. I could easily surf the Internet a bit, communicate with friends using Pidgin and enjoy the 3D-desktop. A few disadvantages were - resolution of my screen, which was something like 1024x768 or 800x600 (native monitor's resolution is 1680x1050) and keymap switching. Languages were installed, but I couldn't switch them by means of keyboard (ctrl-shift, alt-shift, shift-shift, nothing...) even after some settings. The only way, I could deal with this problem was to click on the language icon by mouse. Hope it won't appear in permanent installation.

After that I tried to reboot and install it through graphical installer. When I was in LiveCD version, I read article about Sabayon and Gentoo (base of Sabayon) in Wikipedia and my expectations were OS like Slackware ot smth. else. Simple, fast and stable. I was wrong.

The first thing that I didn't like was packages selection. I was provided by several general options like "Install KDE", "Install Gnome", "Install 3D games" and so on. 8 points if I'm not mistaken. Of course, I could look through it's contents, but I couldn't select. Ok, I will install or remove required or unnecessary soft after the installation.

The next screen asked me about default services (Samba, NFS, CUPS...), and then I should choose the partitions. Without any doubt I pointed on 8Gb partition as root and the 4Gb as "/home". Click on "Forward"... What's this??.. I see a small window, which says that I'm trying to install the system on 8Gb partition, which is much smaller than 12Gb. I was shocked. It's Linux, which is famous for the ability of installation on diskette, telling me this. It's not Mandriva or other fat desktop distributive, with big amount of the latest software. It's a Gentoo based "true" Linux. And it said "pish!" on my 8Gb partition and asked for 12Gb. Why not 20Gb? Or may be 60Gb? What's the problem I can pull my HDD and it will enlarge! Easily. Seems like Windows Vista requires less...

But nevertheless, it's just a notification. I proceeded with installation, was asked about root passwords, new users, about GRUB loader and installation started offering me to "relax in my chair", just like Win98. When it was ~55% of installation I got an unhandled exception with some useless details and Installer exited. A bug in the Graphical installer. No matter, sometimes it happens. Reboot and select text installer.

Menu structure is the same, phrases are the same, but... Where is the Package selection window? I was asked about desktop environment and nothing more. I'm puzzled, why I'm limited in the text installer options. But hope, it's default selection is Ok. Answer on the rest known questions and, again, start the installation.

Don't remember how much it installed, but "No space left on device" reported one of the tools, which struggled through installer's interface directly on my console. Finish. So, it really requires so much space, and text-installer can't deselect packages. Graphical installer drops during installation (I tried several times). What should I do with this distributive?

It was midnight by the moment and I decided to think about this next day. Today I had another idea - I noticed "Update installer" button in the graphical installation yesterday. May be this exception will disappear in the new version. But... Somehow I damaged my DVD a little bit :( It's double-side and it's hard to use such a disk. I should have copied it on two DVD's before. It will be a lesson for future for me.

My resume about this distributive is the following. Probably it's quite useful and good-looking distributive, with integrated compiz and lots of useful soft. But the installer is quite buggy and useless. I didn't like that I can't select packages and even categories in the text mode. I think I'll try to install it again if have and an opportunity to get another DVD with this or next version.

Wednesday, March 4, 2009

.tgz vs .tar.gz

Comparing the result, there is no difference between "old-style" archival of directories (by means of pipe: tar -c dir1 | gzip > arch1.tar.gz) and "new-style" (by means of integrated ability of tar: tar -czf arch1.tgz dir1).

But there is a huge difference in speed. I tried to archive a large directory these 2 ways and obtained completely the same archives. I used "time" Linux tool to measure execution time. The first method (with pipe) took about 40 minutes to complete. The second method - 12.

The reason of the difference, I guess, in usage of pipe in the first method. Shell creates a temporary file for each pipe and all stdout of one application is stored into this file. Another application gets this file as stdin. We obtain the next sequence: reading of source directory, writing pipe temporary file, reading the temporary file and writing the archive file. In the second method we have only two of these actions: reading of source directory and writing to the target archive file.