Sunday, 17 April 2011

I've just realized that the reiserfs partitions of an old PC are not associated with their corresponding UUID in /etc/fstab. I usually use UUIDs in fstab to avoid problems when adding/removing disks.

This particular PC has several partitions with reiserfs filesystem. Many years ago I preferentially used reiserfs instead of ext2 for obvious reasons. With the advent of ext3 I stopped using the reiser filesystem on new installations. But my old PCs remained with reiserfs. That happened (and remained) over the time with non-system partitions (home, chroot, etc...)

Out of curiosity I've tried to find out how old these partitions are, but I have not been able (perhaps a seasoned forensic guru can help me ... debugreiserfs does not show this information). The oldest files I can see have access dates of 2004 but I'm sure the partitions are much older .... enough rambling!

Turning back to the UUID issue. The reiser partitions are not associated with a corresponding UUID:

The second command, which edits "/etc/fstab" entries replacing each /dev/sdXY string with its corresponding UUID, is detailed in the following steps:

as the first command we use "mount -t reiserfs" to get the list of reiserfs partitions (mounted) in the system.

as before, we pass each line from the output to ''$part'' using bash's "while". Remember that ''${part%% *}'' will correspond to each of the partitions in the format '/dev/sdXY'.

For each reiserfs partition we execute sed infile editin the /etc/fstab file. The sed command can be divided into:

3.1) a first part where you select only the lines of the reiserfs partitions. Those with the format:

/dev/...............reiser............

3.2) on the previous selection sed will just edit the field "/dev/sdXY".
3.3) and sed will replace it with two lines: a comment header (just to remember which was the original partition's name), and the corresponding fstab's entry with the UUID.

3.3.1) I get the UUID value with "blkid" keeping just the UUID value, which corresponds to the last field in the output if we divide it into spaces (awk NF). For example if you originally had lines with the format: