Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, January 3, 2024

Cryptsetup basic cheatsheet

To format a partition (e.g. sda1) as LUKS with an HMAC integrity layer:

cryptsetup luksFormat --type=luks2 --integrity hmac-sha256 /dev/sda1

Or without an integrity layer: (you probably want this for most usecases)

cryptsetup luksFormat --type=luks2 /dev/sda1

To open the encrypted partition:

cryptsetup open /dev/sda1 sda1_crypt

Alternative was to open it while permanently marking the LUKS device to accept discard (TRIM) operations:

cryptsetup open /dev/sda1 sda1_crypt --allow-discards --persistent 

This will create a decrypted device for the same partition which you can format like so: (-i 4M for storing files around 4MiB each, -m 0 to avoid reserving space for the root user, change the Label to whatever you like)

mkfs.ext4 -i 4M -m 0 -L Label /dev/mapper/sda1_crypt

Then close it:

cryptsetup close /dev/mapper/sda1_crypt

Disconnect the device and reconnect it (or mount it however you normally do) to see if everything works.

Parallelizing LAME MP3 conversions

In Linux, the P4 parameter below will launch 4 LAME instances in parallel to process all the FLAC files into MP3 with the given LAME settings.

find . -name '*.flac' -print0 | xargs -P4 -0 -I{} lame -q0 -V6 {}

Finding (non) writable files under a directory

To find all writable by the current user files under the working directory:

find . -writable

To find the non writable ones:

find . ! -writable

Tuesday, January 2, 2024

Force unmount stuck LUKS on Linux Mint

If Linux Mint refuses to mount an encrypted external drive that was abruptly disconnected and gives you a message like "file already exists" or something like that, instead of rebooting the system you can try unmounting it from the command line:

 
sudo udisksctl unmount -b /dev/mapper/luks-xxx-xxx-xxx-xxx-xxx

or

sudo dmsetup -f remove /dev/mapper/luks-xxx-xxx-xxx-xxx-xxx

Just type until luks and then press tab twice to see what's the id in your case.

LXDE/Raspberry language layout switching

Adding

setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll de,us

to your ~/.bashrc (or manually running it after LXDE has started will allow toggling between German and US English keyboard layouts using the Alt-Shift keys on the Raspbian. I've also used this same method in other situations where there was no graphical way to add and/or switch keyboard layouts. The scroll lock light will indicate the active layout when including "grp_led:scroll". "alt_shift_toggle" can be replaced with another key combination. Running

setxkbmap -option

will reset your layout settings.

(This post is based on an old pastebin with notes I got form who knows where. I don't know if more recent versions of Raspbian have a better way to achieve this but the command is still useful anyhow)

Mounting VirtualBox VDI files on Linux

The following commands, will mount a VirtualBox VDI file on Linux. First make the directory where you'll mount the virtual partition files inside the VDI (that's the best description I can give you of this, you'll know what I mean when you later see the contents of the directory):

sudo mkdir -p /mnt/vdi/expanded

Now mount the VDI file:

sudo vboximg-mount -i <path-to-vdi> -o allow_other /mnt/vdi/expanded

Then make a directory for the volume you want form inside the VDI: (you probably want vol1 but it depends on your case)

sudo mkdir /mnt/vdi/vol1

Then mount the volume onto the directory: 

sudo mount /mnt/vdi/expanded/vol1 /mnt/vdi/vol1

When you are done, you can unmount everything with:

cd /mnt
sudo umount /mnt/vdi/vol1
sudo umount /mnt/vdi/expanded
sudo rm -rf /mnt/vdi

Be careful with that last command.

Printing all files in subdirectories sorted by date

On Linux:

find -printf "%TY-%Tm-%Td %TT %p\n" | sort -n

will show sorted by modification date all the files under the working directory. You can replace the %T parts with %A for access time sorting or with %C for creation time sorting.

The command may partially fail if you have filenames with weird unprintable characters.

Finding shared library dependencies of ELF binaries

If you have an ELF binary in your current directory named luajit, run the following command to see which shared libraries it depends on:

readelf -d luajit | grep NEEDED

How to store command output in bash variable

x="$(head -15 testfile.txt)"

This would store the first 15 lines of testfile.txt in variable x.

Monday, July 13, 2020

Liquid Archiver v1.5

A new version of Lar is out. The archive format is the same so this is version 1.5.

Changes:

  • Fixed a cosmetic bug when ran under Lua 5.3 or later.
  • Fixed a non-critical bug that could, maybe, create slightly different archives when ran under Lua 5.3 or later instead of earlier versions. The archives would still be perfectly valid and working.
To install Lar, save the script that you can find here as ~/bin/lar and "chmod a+x lar" it and you should be able to run it by just typing lar.

Friday, April 10, 2020

Liquid Archiver v1.4

A new version of Lar is out. The archive format is the same so this is version 1.4.

Changes:

  • Fixed a bug that would occur at least in Lua 5.1.x on Raspbian 32bit when you run multiple parallel lar operations and they would be unable to create some temp files because they would pick the same "random" name.
  • File with newline characters in their filename are not supported.
    To install Lar, save the script that you can find here as ~/bin/lar and "chmod a+x lar" it and you should be able to run it by just typing lar.

    Tuesday, March 31, 2020

    Liquid Archiver v1.3

    A new version of Lar is out. The archive format is the same so this is version 1.3.

    Changes:

    • Fixed a race condition. In some cases Lar 1.2 would try to write a file before the creation of its containing folders had finished.
    • Fixed a bug in v1.2 that affected the target of symbolic links.
     There is also a known bug/limitation since v1.1: files with newline characters in their filename are not supported.
    To install Lar, save the script that you can find here as ~/bin/lar and "chmod a+x lar" it and you should be able to run it by just typing lar.

    Wednesday, March 18, 2020

    Liquid Archiver v1.2

    A new version of Lar is out. The archive format is the same so this is version 1.2.

    Changes:

    • Much faster when archiving millions of small files. File metadata is gathered in a way more efficient way.
    • File sorting within the archive is done more quickly.
    • It does not spawn "sha256sum" processes all the time directly, instead it will spawn a "sh -s" process and feed it the required commands to run sha256sum with proper piping to named pipes. This makes a huge difference when compressing 100K files or more.
    • Apparently, when you were archiving the current directory (".") the entry for the directory was included in the archive. This was not intended as I did not want Lar to touch the metadata of the current directory when extracting an archive. I fixed it so that it will ignore any "." entries in current archives and will also not put any such entries in future archives.
    • Progress indication when creating archives is now a percentage of data processed, not a percentage of files processed.
    • Some more minor improvements in speed and memory usage.
    To install Lar, save the script that you can find here as ~/bin/lar and "chmod a+x lar" it and you should be able to run it by just typing lar.

    Tuesday, March 3, 2020

    Liquid Archiver v1.1

    I swear I am not trying to post once a year, it's really a coincidence. :-)

    I've been using Linux as my main OS for some years now and I still don't like working with TAR, one of the most basic Unix utilities. Every time I think I know how to use TAR, I get hit by some quirk I didn't know or didn't remember about. Like how the order of parameters matters in some cases as tar will ignore "--exclude" arguments if placed in the wrong position and apparently the order is different depending on the implementation of TAR. Also I've never managed to get the exclusions working on the first try as I expect them to, especially if I need to combine multiple of them. Am I trying to match the filename only? The whole path? Is it the relative path or the full path? Etc.

    So I had enough and made Lar, an alternative to TAR. Initially it meant "Lua ARchive" because a) it's written in Lua and b) it uses Lua patterns instead of regex for inclusions and exclusions. But then I decided that it would be better to mention something about the nature of the format in the name rather than the language of the first implementation. So "Lar" now stands for "Liquid ARchive" because of how archives flow in and out of output, without ever requiring to seek back to a previous position in the data stream.

    I had a few goals in mind when I starting writing Lar. Some of the goals even had some unfortunate consequences, more on that below.

    The goals were:

    1) I love pipes. Other than reading the file and directory structure that you are trying to archive or creating the file and directory structure that you are trying to extract, there should be no direct reading or writing of the archive itself from the filesystem. Archives are read purely from stdin and written out purely to stdout. That means no ability to seek inside the Lar archive that you are reading and no going back to write a header at the start of the archive you are writing.

    2) I wanted deduplication. I honestly just wanted to experiment with this. I did not know at the time how useful it would be to me but, I thought, since I'm bothering to make a new archive format, let's put something interesting in it.

    3) I want something that I find easier to use than Tar. That's subjective af, and I can subjectively say I succeeded. :-P I don't have trouble writting inclusions and exclusions, and I find the switches and the general behaviour of the program easier to predict. Of course I'm biased but I made this for myself after all so you can try it and see if you like it as well.

    Goal #1 and goal #2 have the unfortunate consequence that it is impossible to extract a subset of the archive without also temporarily extracting useless data. Deduplication is done at a 1MiB block level by default but when Lar encounters a block in the archive, it doesn't know yet if it's useful or not for the files it wants to extract. The only way to know if a block is useful would be to have an index of files and which blocks are used for these files placed at the end of the archive, but since Lar cannot seek, it cannot read that index before it encounters the actual blocks. And it cannot write the index on the front of the archive because that would also require it to seek back to the start of the archive after writing all the blocks, and seeks are not allowed because of goal #1.

    4) I don't care (yet) about allowing custom ordering of the files within the archive but the default ordering should try to bring similar data close to each other. So files are ordered primarily by extension, secondarily by their filename, and thirdly by their path.

    5) No absolute paths. The archive is always anchored to the place you are when you run the command to create it. You are free to scan only a specific (sub-)*sub-directory for files to include and even use patterns to only include specific files (and directories) from your scanned subdirectory.

    After those goals were achieved, I started adding more goals to reach:

    6) I wanted differential archives. I wanted to backup my computer one day in a Lar archive, and the next week I wanted to do the same backup but I would pass the old archive in Lar's input and Lar would create a new archive in its output which contains all the information about file metadata (filenames, locations, modification dates etc) but it would not contain any blocks that already exist in the previous week's backup. In fact, I wanted to be able to pass an arbitrary number of older archives, possibly including archives that were already differential themselves, into Lar while creating a new archive which would contain none of the data blocks found in those base archives. Obviously, to extract a differential archive, all the other archives that I used during its creation should be passed to Lar during the extraction as well.

    7) Once I had differential archives I got pissed off at how useless differential archives were when backing up MySQL dumps. Think about what happens to the MySQL dump of a 100MiB table when you insert one row in the middle of that table. You have 50MiB of duplicate data before the inserted row, which are exactly the same as the first 50MiB in last week's backup so they are properly deduplicated. But the other 50MiB that are coming AFTER the inserted row, while exactly the same as last week, are shifted by a few bytes and now none of the blocks match any of the blocks from last week, so deduplication doesn't work. I wanted deduplication to work for these cases as well.

    The way I solved that last issue was to find a way for blocks to "resynchronize" after the point where data has been inserted or removed. It was obvious that I needed dynamically-sized blocks where the size depends on the contents of the block. Perhaps I could score each possible place in a datastream by a "cutting" score and try to have a block that ends at the best possible cutting point which is not closer than 0.5MiB to the starting point and no further than 1.5MiB from the starting point of the block. That way two desynchronized datastreams will eventually end a block at the same cutting point, and after that, they will continue to deterministically end the next blocks at the same points. If the above doesn't make sense to you, check the help page of lar. If that doesn't make sense either, leave a comment and I'll try to explain.

    After writing the code for the self-synchronizing blocks, as I call them, I tried to find if someone else has done something similar. It seems that rsync have a somewhat similar way of finding common substrings in files and also Microsoft had used a very similar algorithm for copying files with small changes over the network. They use a different "cutting score" function and minimum/maximum sizes (I think they don't have a minimum size?) but the algorithm is pretty much the same. Also, fuck patents. Seriously. I spent hours trying to shift through all the shitty little patented things related to differential backups that every asshole has patented. I didn't see any patent covering my algorithm per se, but I saw patents covering my algorithm or some similar one in specific usecases but none of them was for differential archives/backups. Then I remembered that I'm in Europe and software patents don't exist here, as far as I know at least. But, still, patents are disgusting. Any law trying to legislate code is disgusting and people should eventually grow the fuck up and stop feeling entitled to every little shitty idea they come up with when some weird guy on the internet can reinvent it after giving it two days worth of thought.

    So yeah, that was the list of goals I guess. Notice how being performant is not one of them. :-D Not that I don't try to speed up things that I can but since I'm almost always piping my Lar archives through lzip, lzip is the bottleneck and not Lar.

    Eventually I may turn this into a C program that provides some core functions like SHA256 hashing and filesystem functions to the Lua script which will be embedded inside the C program. Right now this is a pure Lua script, single file, no imported libraries, which depends on sha256sum and other standard Linux binaries to do what pure lua cannot do (e.g. set modification dates and permissions). I could already replace some of them with some Lua Rocks, but I don't like rocks. I'm not sure why but I never use them. I've tested Lar on Linux Mint, Raspbian and Ubuntu and it seems to work as long as you have sha256sum installed. You should be able to install it with "apt install coreutils".

    For testing, other than some really minimal unit tests inside the code, I have a suit of weird edge cases that I had encountered that I run the code against every time I change it and I'll keep expanding that suit with more cases.

    I have also been using Lar to archive and backup pretty much everything I archive and backup and I haven't seen any data corruption since the very first versions of the program. I've even used Lar to backup and restore a whole Minecraft server that I help admin with multiple shards (deduplication works so nicely for these cases) to a new box.

    To install Lar, save the script that you can find here as ~/bin/lar and "chmod a+x lar" it and you should be able to run it by just typing lar.

    This is version 1.1, released under GNU/GPL v3. The first number is the file format version, the second is the program version. If I even advance the file format version I will reset the program version (i.e. there will be a 1.14 and then a 2.1).

    Here's the help page of Lar with more info about the currently available features:

    lar - Liquid Archive version 1.1
    Lar reads archives from stdin and writes archives to stdout. Existing files are
    overwritten during extraction, if permissions allow that. Liquid archives are
    designed to be streamable both during creation and during extraction. They also
    eliminate redundancy on a 1MiB block level (or smaller for files smaller than
    1MiB). A side effect of these two design goals is that during extraction with
    inclusion or exclusion filters, all the data needs to extracted on disk and then
    partially discarded. Lar ignores file ownership both when archiving and when
    extracting. For excellent and efficient compression of lar archives we suggest
    pipping the output through "mbuffer -q -m 1G" and then through "lzip -9" if you
    have these tools available.

    Usage: lar -c [-v] [-p|-P] [-B SIZ] [-s SNC] [-d NUM] [-b DIR] [-i INC] [-e EXC]
           lar -x [-v] [-p|-P] [-d NUM] [-i INC] [-e EXC] [-f]
           lar -l [-v] [-p|-P] [-d NUM] [-i INC] [-e EXC]
           lar -m [-v]
           lar -C N,T
           lar -H [-v]

    -c Create archive. Outputs to stdout an archive of DIR as seen from
    the current directory.

    -x Extract archive. Reads an archive form stdin and extracts the
    contents to the current working directory.

    -l List contents. Same as extract but it will not touch your local
    filesystem. You can even combine it with -i and -e to view just
    some of the files. It does not fully test the archive for all
    kinds of inconsistencies though. Some will only be detected when
    you actually extract the archive.

    -m Create an empty archive, useful if you want to create empty base
    archives for a differential archive.

    -i Only include files and directories that match the INC Lua
    pattern. Works with -c, -x and -l. Additionally, "|" may be used
    to separate multiple Lua patterns as a logical OR.
    https://www.lua.org/manual/5.3/manual.html#6.4.1

    -e Exclude files that match the EXC Lua pattern. Works with -c,
    -x and -l.

    -v Be more verbose.

    -b DIR is the directory or file that will be added to the archive.
    It can only be used with -c.

    -d Create or extract a differential archive. You need to
    sequentially pipe NUM base archives in the stdin when you create
    a differential archive. The same base archives need to be passed
    in the stdin (in any order) when you want to extract the
    resulting differential archive. Differential archives will not
    repeat blocks of data that exist in the base archives, so they
    are ideal for incremental backups. You may use differential
    archives as base archives for a new differential archive. Doing
    so will not cause the new differential archive to require the
    base archives of its base archives during its extraction. This
    allows you to create a sequence of differential archives where
    each one depends on the NUM previous archives.

    -p Create a text only archive that contains only printable
    characters and whitespace at the cost of an increased archive
    size and slower archival. It can only be combined with -c.

    -P Same as -p but this time even whitespace is disallowed.

    -f Force extraction of files with missing blocks. This will allow
    you to partially extract a differential archive even if some of
    its base archives are missing.

    -B Change the block size to SIZ. Default is 1048576 (1MiB). Bigger
    blocks are faster but deduplication is done at the block level
    so smaller blocks (but not very small) will result in more data
    savings. Don't change this if you are not sure. It can only be
    used with -c.

    -s Enable self-synchronizing block splitting for files matching the
    SNC Lua pattern. Data blocks will not be of a fixed size
    anymore, they will vary between 66% and 134% of the size defined
    by -B (or the default 1MiB). The sizes are picked in such a way
    that if you have two files with different sizes but a sustantial
    amount of common data at their end, there is a high probability
    that the blocks will synchronize, improving the deduplication of
    data. This is especially useful if, for example, you are trying
    to make differential backups of a MySQL dump file every day when
    only a little data changes but also the size of the file
    changes. Archival will be much slower. It can only be used
    with -c.

    Suppose you have these two data streams:
    abdefghijklmnopqrstuvwxyz
    abdefghijklm123nopqrstuvwxyz

    If you split them with fixed size blocks they will look like:
    ab|de|fg|hi|jk|lm|no|pq|rs|tu|vw|xy|z
    ab|de|fg|hi|jk|lm|12|3n|op|qr|st|uv|wx|yz

    Deduplication will work fine for the blocks before the digits
    but after the digits the blocks are offset in such a way that
    they will never resynchronize and even though the ends of both
    streams are the same, deduplication is impossible.

    Self-synchronizing blocks will split these data streams like:
    ab|def|g|h|ij|kl|mno|pq|rs|t|u|vwx|yz
    ab|def|g|h|ij|kl|m1|23n|op|q|rs|t|u|vwx|yz

    The blocks eventually resynchronize (after "rs" in the example)
    so deduplication of the end of this data stream is possible.

    -C This is a handy calculator for differential backups. N is the
    number that you intend to pass to -d, i.e. the number of base
    archives that each of your differential archives will be based
    on. T is the number of differential archives that you intend to
    keep. Type those two numbers in (e.g. -C 4,8) and the calculator
    will give you information about how much space they will take
    and how many archives will be recoverable.

    -H If you pipe a Liquid archive through "lar -H", you will get
    a special "thin" version of the archive in the output that
    contains only the hashes of the blocks in the input. This can be
    used to greatly reduce the amount of data transmitted over the
    wire in cases where you are creating a differential backup with
    the base files being piped over the network as it will move the
    block hashing to the remote server instead of transferring the
    data to be hashed locally.

    Examples:

    lar -cv -b Images > Images.lar
    Archive all files in the Images folder and name the archive Images.lar.
    Verbose output.

    lar -xv < Images.lar
    Recreate the Images folder that archived in the previous example under
    the current working directory. Verbose output.

    lar -xv -i '%.c$|%.h$' -e 'example' < code.lar
    Extract the archive code.lar into the current directory. Only extract
    files and directories that end with ".c" or ".h". Do not extract files
    or directories that include the word "example" in their full path.

    cat old.lar older.lar | lar -cd 2 -b Images > new.lar
    Archive all files in the Images folder and name the archive new.lar. The
    output archive will be a differential archive and will not contain any
    blocks of data that exist in old.lar and older.lar.

    cat old.lar older.lar new.lar | lar -xd 2
    Extract the archive that was created in the previous example. Only
    new.lar will be extracted but old.lar and older.lar are needed because
    they contain data that was omitted from new.lar during its creation. The
    order of old.lar and older.lar may be reversed but new.lar, the archive
    that you are actually trying to extract, must be the last one.

    (cat DB2.lar.gz | gunzip; cat DB.lar.gz | gunzip) | lar -cvb DB -d 2 | gzip > DB3.lar.gz
    Archive all files in the DB folder, pass through gzip to compress the
    archive and name it DB3.lar.gz. The output archive will be a
    differential archive and will not contain any blocks of data that exist
    in DB2.lar.gz and DB.lar.gz.

    cat yesterday.lar > lar -d 1 -cvb serverbackup/ -s '%.sql$|%.csv$' > today.lar
    Archive all the files in the serverbackup folder and turn on
    self-synchronizing blocks for files with ".sql" or ".csv". Do not
    include the data blocks that exist in yesterday.lar so the resulting
    today.lar will be a differential archive. Self-synchronization helps
    with redundancy detection in files like SQL dumps or other files that
    may have data inserted or removed from one archive to the next one.

    (ssh 'user@192.168.0.5' "cat /home/user/backup1.lar.gz" | gunzip | lar -H; ssh 'user@192.168.0.5' "cat /home/user/backup2.lar.gz" | gunzip | lar -H; ) | lar -v -d 2 -c -b . | gzip | ssh 'root@192.168.0.5' "cat > /home/user/backup0.lar.gz"
    ssh 'root@192.168.0.5' "rm /home/user/backup5.lar.gz"
    ssh 'root@192.168.0.5' "mv /home/user/backup4.lar.gz /home/user/backup5.lar.gz"
    ssh 'root@192.168.0.5' "mv /home/user/backup3.lar.gz /home/user/backup4.lar.gz"
    ssh 'root@192.168.0.5' "mv /home/user/backup2.lar.gz /home/user/backup3.lar.gz"
    ssh 'root@192.168.0.5' "mv /home/user/backup1.lar.gz /home/user/backup2.lar.gz"
    ssh 'root@192.168.0.5' "mv /home/user/backup0.lar.gz /home/user/backup1.lar.gz"
    Create a differential archive of the current directory with 2 base
    archives. The base archives are stored on a remote server at 192.168.0.5
    and are remotely processed with "lar -H" so that only the hashes of the
    blocks they contain are transferred over the wire. The resulting
    differential archive is also stored back at the same remote server.
    After the archival is done the archives are renamed and 5 of them in
    total are kept. backup1.lar.gz will be the newest archive and
    backup5.lar.gz will be the oldest.

    To see what 5 differential archives (each based on the previous 2
    archives) mean, you can run "lar -C 2,4" which will give you the
    following output:

    If your differential archives are based on the last 2 archives (-d 2)
    and you keep a total of 5 archives, then you should expect to have 3
    recoverable archives. Archives older than the last 3 will not have all
    their base archives available and you will therefore be unable to
    extract them. You should expect that all 5 archives together will take
    about the same space as 1.7 full size (non-differential) archives, but
    in some cases they will take up about the same space as 2 full size
    archives.


    Verbose output:

    3% (input=134B output=111.74MiB) ./readme.txt (regular file) [NNNHP]
    |          |              |            |            |           |
    |          |   Data written to stdout  |        File type       |
    |          |                    Current filename                |
    |  Data read from stdin                                         |
    |                            Current file's blocks (N=new, P=previously seen in
    Percentage of files done     current archive, H=previously seen in base archive)


    Copyright 2019-2020 Tritonio (www.inshame.com)

    This program is free software: you can redistribute it and/or modify it under
    the terms of the GNU General Public License version 3 as published by the Free
    Software Foundation.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.  See the GNU General Public License for more details.

    If you have not received a copy of the GNU General Public License along with
    this program then see https://www.gnu.org/licenses/gpl-3.0.txt or download it
    using BitTorrent: magnet:?xt=urn:btih:ftlm2r4zr3eepxypisejceebq7gx3wn7

    Tuesday, November 3, 2009

    Ctrl+H

    In Linux you can toggle the viewing of hidden files by pressing Ctrl+H. This doesn't happen in Windows where you have to take a small trip through the explorer menus and options to toggle this setting, accept the changes, se your hidden files and then go through the same trip to hide them again. Ctr+H comes to fill in this feature. Copy it to any folder and run it once. It will ask you if you want to register it so that it starts up with your system. After that it will popup a message over your clock telling you it's running. Its tray icon will soon dissapear but Ctrl+H is still running. Then you will be able to show or hide hidden files by pressing Ctrl+H just like on Linux. Click here to download Ctrl+H.

    Saturday, July 5, 2008

    Windows XP and Vista running on Ubuntu

    Here is a new video that I uploaded to YouTube. It's my system running Windows XP and Vista at the same time, virtualized with VirtualBox on Ubuntu. The theme I am using is Ubuntu Satanic Edition (with a different background). You can also see the Desktop Cube that Compiz offers. :-)



    Still not switched to Linux? ;-) You won't miss Windows this way...

    PS: The FPS aren't that slow as they seem to be on the Video. Also, some horizontal red stripes that appear while rotating the cube are a glich in the capture and don't really exist.

    Monday, June 23, 2008

    Windows 2.03 on a Virtual Machine

    Virtual Machines can be proven very useful tools. I have been using QEmu for some time now but I recently switched to VirtualBox (commercial, but free of charge, edition) because I desperately needed the USB support. Here is a screenshot showing my four desktops while in one of them is a virtual machine running XP in fullscreen mode:


    Apart from running a "useful" OS on the virtual machine (it's useful because I needed to use a 3G GPRS USB modem which doesn't work on Linux) you can also run old or rare OSes. I tried Warp but I couldn't install it just like Windows 1.0. So I tried Windows 2.03 which did install and run properly. I also made a video with a quite lengthy tour showing most of their programs. (it's five minutes long!)

    Here it is:

    Thursday, June 5, 2008

    Ubuntu Hardy Heron on a Sony Vaio VGN-FZ31E

    This article probably also applies to: VGN-FZ38M


    Yeap I bought it. I though that since it had an NVidia card and it was Centrino based etc it wouldn't have any incompatibilities with Linux. (aaaargh if I only knew...) Anyway.

    The laptop came with Vista. I was going to keep them for a week or so just to make sure I don't miss any of the Sony specific programs that was preinstalled. Well I couldn't bare them for more than 24 hours. I made some factory restore CDs and repartitioned the whole drive which now only has Ubuntu installed in it.

    What worked out of the box:

    The SD/MS reader (104c:803b). It works out of the box with SD cards but the MS PRO slot doesn't work for me and I have found no way to make it work.

    Graphics Card (10de:0426): The NVidia GeForce 8400 GT worked perfectly with the closed source drivers that Ubuntu installed. The temperature sensor works OK too.
    Nevertheless I recreated the xorg.conf (for no specific reason). Here is the new one.

    DVD-Drive (PIONEER DVD-RW DVRKD08): It works OK. I recorded a data DVD with Brasero (for some reason it couldn't verify the burned disk afterwards but it worked perfectly). I also installed Diablo 2 through Wine. The CD protection of Diablo 2 works OK and recognizes the original CD.

    CPU (Intel(R) Core(TM)2 Duo CPU T5450 @ 1.66GHz): Both cores are recognized and the temperature sensors work OK. The same goes for frequency scaling.

    Wireless and LAN (8086:4229 and 11ab:4351): They both work perfectly right out of the box.

    What didn't work out of the box but works with some tricks. Before trying the tricks enable the extra repositories (universe, multiverse etc) from System->Administration->Software sources).

    Camera (05ca:183b): HAL loads a wrong module for the camera that in addition to not working, makes the laptop crash when you try to suspend it. So you must remove the misbehaving module from the kernel and prohibit reloading it.

    1. Type the following in a console (you can find the console in Applications->Accessories->Terminal):

      sudo gedit /etc/pm/config.d/unload_modules

      Give your password and then copy and paste the following line at the end of the file:

      SUSPEND_MODULES=uvcvideo


      Save the file and close the text editor.

    2. To download the r5u870 drive you will need svn, so in a console type:

      sudo apt-get install subversion

      (answer yes to any questions you may encounter)

    3. To download the source of the driver, type in the console:

      svn co http://svn.mediati.org/svn/r5u870/trunk r5u870

    4. Now that all files are downloaded go into their directory by typing:

      cd r5u870

    5. Install the build-essential package before trying to compile the drivers by typing:

      sudo apt-get install build-essential

    6. Compile the driver by typing:

      make

    7. and then install the driver by typing:

      sudo make install

    8. Now instead of restarting you may just load the module into the kernel by typing:

      sudo modprobe r5u870

      When you reach this point the camera will only work with some applications like Skype.


      If you open Cheese (a very nice application for capturing video and still pictures from your camera, install it by typing sudo apt-get install cheese) you will notice that it doesn't recognize your camera. That's because the system doesn't recognize it as a Video4Linux camera.

    9. To fix this you will have to download this file and copy it to /usr/share/hal/fdi/information/20thirdparty . If you don't know how to do this just type the following two lines in the console:

      cd /usr/share/hal/fdi/information/20thirdparty
      sudo wget https://bittit.info/publicDro/10-r5u870-webcam.fdi

    10. Now either restart you computer or execute this in the console:
      sudo /etc/init.d/hal restart

      Now you should have a perfectly working camera! Oh, you may now delete the sources by typing:

      sudo rm -r ~/r5u870


    Sleep and Hibernate
    : They don't work initially. The computers go to sleep but when awaken it stays in a black screen. Fixing the camera will fix this problem too. :-)

    Sound Card (8086:284b)
    : Well, playback worked out of the box but when opening the sound options there were no recording controls and the sound was coming out only through the builtin speakers, plugging in headphones changed nothing. To fix all these problems follow these simple steps:

    1. Optional step. I suggest that you don't use Pulseaudio because I found it a bit buggy. To switch back to ALSA go to System->Preferences->Sound and change everything to ALSA.

    2. Type the following in a console:

      echo "options snd-hda-intel model=vaio" sudo tee -a /etc/modprobe.d/snd-hda-intel

    3. Restart you computer.

    4. Open the sound controls by clicking the sound icon next to the clock.

    5. Select File->Change Device->HDA Intel (Alsa mixer)

    6. Then goto Edit->Preferences and select everything.


    7. Play around with the controls. Don't forget to look at all three tabs (in the third tab you will find the record selection switches: Internal Mic, PCM, Mic Jack)

    Bluetooth (044e:3010): It is properly recognized by the system but it will not work. Here is a way to fix it:

    1. In a console type:

      sudo gedit /etc/rc.local

    2. Now append the following line before the exit command (if there is one) near the end of the file:

      hciconfig hci0 reset

    3. Now save the file and close gedit.

    This way the bluetooth will work correctly but if you switch it off and again on (using the hardware switch in the front side of the laptop) it will stop working so you also have to do the following:


    1. Right click on an empty space on your panel and select "Add to panel..."

    2. Then create a new custom launcher and in the command textfield copy and paste this:

      gksudo hciconfig hci0 reset
    This way when your bluetooth stops working, just click on the new launcher that you made and it will ask for your password and then reset the bluetooth device so that it will start working again


    VGA-out:

    Open a console and type:

    cp /etc/X11/xorg.conf ~/xorg.conf.back

    This will back up your xorg.conf file just in case you mess it up.
    Now you will have to install the NVIDIA settings manager. To do this just type:

    sudo apt-get install nvidia-settings

    And then run it by typing:

    sudo nvidia-settings

    The NVIDIA settings manager will open. (you might need to resize this window because for some strange reason it initializes too small)


    Now select X Server Display Configuration and then click on Detect Displays to detect the connected display. Now you will be able to configure the two screens using the options in the Display and the X Screen tabs.

    From ere you may also set the resolution to for your laptop's monitor to the correct one (1280x800). If you select a resolution from the Resolution drop-down-list (it's visible in the above picture) the drop-down-list on its right will be enabled and you can then select the desired refresh rate.

    Afterwords don't forget to click on Save to X Configuration File.

    If you mess up then type this in a console to restore your backup:

    sudo cp ~/xorg.conf.back /etc/X11/xorg.conf

    To delete your backup type:

    rm ~/xorg.conf.back

    Tip: To get rid of the annoying NVIDIA splash screen type this a a terminal:

    sudo gedit /etc/X11/xorg.conf

    Then find all the Device sections and add this line inside them:

    Option "NoLogo" "True"


    Then save and exit.


    What doesn't work and still I have found no solution:

    The Fn buttons don't work. In fact the sound controls work, the next track, previous track, play, stop buttons work too. The S1 (customizable button), the AV MODE and the brightness control buttons doesn't work. I am still looking for a solution. The MS PRO slot doesn't work and I still haven't found any solution.

    What I haven't fully tried yet:

    S-Video out, HDMI output. I'll try them some time... (Shawe in the comments says that HDMI works OK but without any sound.)


    References:
    http://ubuntuforums.org/showthread.php?t=706530
    https://bugs.launchpad.net/ubuntu/+bug/147757
    http://wiki.mediati.org/Installation
    https://launchpad.net/ubuntu/+source/alsa-driver/+bug/33719

    PS: If I fix more problems I will update this post so you might want to check back later. If you find any problems or omissions please leave a comment.

    PS2: It seems like someone did a partial translation of this article into Catalan. Here is a link to it. :-)

    PS3: Thank you for your comments and the info you provided!

    Linux On Laptops

    Monday, June 2, 2008

    ZVista

    There are a few programs that manage to make me angry every time I use them. But nothing compares to Windows Vista. It must be by far the worst OS I have ever used. I mean, Microsoft must have really tried to create such a mess, it can't suck by accident.



    It's sooooo sloooooooowwwww..... I have friends with Vista on their laptops, some of them just use them for office and internet, not a single game or other application. Well it takes around 10 minutes to do a restart! Before some days I was waiting 7 minutes for the shutdown before forcing a power off myself! (no it wasn't even installing updates)



    Apart from the speed issues there are million other problems. It's amazing how they managed to mess up every single aspect of the OS. Even the console (the command prompt) doesn't support drag and drop!!! WHY??? Are they crazy? I mean, did they actually pay someone to do this??? In addition to this the changed the layout of the start menu to a more flat one. They also made changes to Windows Explorer. I was looking into a folder containing C source files with the details view mode, well, Vista insisted to show me artist name, album, etc for every source file! For some unknown reason it though this was a music folder! (Perhaps it wouldn't do so if there was a Visual C++ project file in the directory >:-P ) All of the above make Vista the worst OS for a programmer or even someone that wants to do more than surfing and writing in Microsoft Office!



    Another really stupid aspect is that dialog that pops up every time you try to alter system files. I really like the extra security that it offers but a virus managed to infect a system without even triggering this dialog! (I accidentally run the virus on a friend's computer) So no extra security actually, just extra confirmations to get on your nerves.



    Vista is really a stupid OS for stupid (trendy) people that want to see glossy windows, but even their 3D effects are inferior to what Compiz offers to Linux users (and of course Aero needs even better hardware).



    The funny thing is that I am planning to buy a new laptop but they all ship with Vista preinstalled! Of course the first thing to do will be to get rid of them but I don't even like the idea that I will actually pay for this crap!





    The dialog reads:

    33 days and 0 hours remaining

    Copying 1.506 items (6.03GB)

    from Local Disk (C:) (C:\) to FREECOM HDD (G:) (G:\)

    About 33 days and 0 hours remaining



    Well, this was not Vista's fault (drive G: was problematic) but it describes, a bit dramatically, what you will go through if you use this NOS (Non Operating System)



    Want some more?

    Get a life...



    PS: ZVista is pronounced like the word "delete them" or "clear them" in Greek.

    Thursday, May 1, 2008

    Ubuntu Hardy Heron 8.04

    The new version of Ubuntu has been released! I installed it one day after it got released. Like Gutsy Gibbon, Hardy Heron is really nice and has lots of new features and additions.

    Story 1:

    Installation:
    I made a fresh install on my Acer Aspire 9420. Not a single problem! All of the devices were installed automatically and worked almost perfectly!


    Customization:
    The first thing I was going to do with Hardy was to install the programs that I used with Gutsy. I was really pleased to see some of them (Emesene, Qlandkarte*, Infon) included in the new repositories, as this meant more time to explore the new release. So I went on and added extra repositories: Ubuntu Satanic Edition (wonderful theme!), Medibuntu, Wine.

    Satanic Edition Theme:


    After that I started installing Add-Ons for Firefox. Hardy comes with Firefox 3 beta 5 installed. Although it feels much better than version 2, many of my favourite Add-Ons are not compatible with the new beta (yet...).

    Firefox 3 beta 5:


    I also found a very nice bittorrent client called Deluge. Well, in fact I already knew about Deluge but it's the first time that I actually use it. ;-)

    Deluge:


    I was amused by how easily accessible are encryption and digital signing capabilities in Hardy. Well in fact you have to run seahorse to create your public-private keypair but after that you can simply use the right-click context menu and the Clipboard encryption panel add on.

    How to add the Clipboard Encryption panel add on:


    Seahorse is in the background, a digital signature in the foreground:


    Finally I had to setup all the Compiz plugins once again because for some reason the backup of my old settings didn't seem to work with Hardy... :-( But the result is nevertheless rewarding. :-)

    The four desktops as seen with the Expo plugin:

    Story 2:

    Installation:
    I also decided to install Hardy on my father's PC. I had a serious problem that didn't allow me to run the live CD. After reading about it I managed to solve it by adding the all_generic_ide boot option. It seems that there a major bug in the Live CD but luckily it doesn't affect all PCs. After installing Ubuntu everything worked just fine.


    Anyway. Well done to everybody that worked on Hardy! :-)

    *(I am not sure if Qlandkarte wasn't available on Gutsy's repos)

    Popular Posts