Linux: use a file as an encrypted partition with cryptsetup

Categories: Linux, Slackware
Published on: December 28, 2011

I’ve decided to move my encrypted /home partition from losetup to cryptsetup.
Instead of using a device (a disk partition) i used a 1o GB file and to do this i’ve upgraded cryptsetup to version 1.3.1 since Slackware 13.37 has the 1.2.0 one.
I just compiled the new version using the 1.2.0 SlackBuild, it works.
I’m following the README_CRYPT.TXT Slackware howto.
First, let’s create the crypted file that will “host” our new /home:

dd if=/dev/urandom of=/crypt_home bs=1M count=10000

Now prepare the partition for encryption (choose a good password!):

cryptsetup -s 256 -y luksFormat /crypt_home 

WARNING!
========
This will overwrite data on /crypt_home irrevocably.

Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase:
Verify passphrase:

We’ll call our mapped device “crypthome”, just like in the Slackware howto:

cryptsetup luksOpen /crypt_home crypthome

Create an ext4 filesystem (just for example):

mkfs.ext4 -j /dev/mapper/crypthome

I’ve add in my /etc/rc.d/rc.local:

echo  "MOUNTING CRYPTED HOME.."
cryptsetup luksOpen /crypt_home crypthome
mount /dev/mapper/crypthome /home/simplex

That’s all.

Qt 4.8 libraries released :)

Categories: News
Tags:
Published on: December 17, 2011

Today is a good day, if you’re a Qt developer :)

http://blog.qt.nokia.com/2011/12/15/qt-4-8-libraries-released-stand-alone/

The full SDK will be released in january.

Smartmontools: test an hard disk with smartctl

Categories: BSD, Linux
Published on: December 15, 2011

I’ve just discovered some i/o read error in a zfs pool:

[root@main-server ~]# zpool status
  pool: rpool
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
	attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
	using 'zpool clear' or replace the device with 'zpool replace'.
   see: http://www.sun.com/msg/ZFS-8000-9P
 scrub: none requested
config:

	NAME                                            STATE     READ WRITE CKSUM
	rpool                                           ONLINE       0     0     0
	  mirror                                        ONLINE       0     0     0
	    gptid/680dc84c-e5e0-11df-aa34-406186f3d8c4  ONLINE       5     0     0
	    gptid/6ae63950-e5e0-11df-aa34-406186f3d8c4  ONLINE      13     0     0

errors: No known data errors

Now i want to test both disks to see if there’s something wrong.
I’m going to use Smartmontools.
To do a quick test just type: smartctl -t short /dev/adx where x is the hard drive that you want to test.

[root@main-server ~]# smartctl -t short /dev/ad4
smartctl 5.42 2011-10-20 r3458 [FreeBSD 8.1-RELEASE-p5 amd64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Short self-test routine immediately in off-line mode".
Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 2 minutes for test to complete.
Test will complete after Thu Dec 15 10:44:09 2011

Use smartctl -X to abort test.

To see the output/log of the test use this command: smartctl -l selftest /dev/adx:

[root@main-server ~]# smartctl -l selftest /dev/ad4
smartctl 5.42 2011-10-20 r3458 [FreeBSD 8.1-RELEASE-p5 amd64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%     14457         -

Now let’s do a more complete (and long) test with: smartctl -t long /dev/adx

[root@main-server ~]# smartctl -t long /dev/ad4
smartctl 5.42 2011-10-20 r3458 [FreeBSD 8.1-RELEASE-p5 amd64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 153 minutes for test to complete.
Test will complete after Thu Dec 15 13:19:20 2011

You can see the log even if the test is still running:

[root@main-server ~]# smartctl -l selftest /dev/ad4
smartctl 5.42 2011-10-20 r3458 [FreeBSD 8.1-RELEASE-p5 amd64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Self-test routine in progress 60%     14458         -
# 2  Short offline       Completed without error       00%     14457         -

ZFS: replace a dead disk in a pool

Categories: BSD
Tags: , ,
Published on: November 28, 2011
[root@pr0nserv ~]# zpool status
  pool: pr0nserv
 state: DEGRADED
status: One or more devices could not be opened. Sufficient replicas exist for
        the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
   see: http://www.sun.com/msg/ZFS-8000-D3
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        pr0nserv    DEGRADED     0     0     0
          mirror    ONLINE       0     0     0
            ad4     ONLINE       0     0     0
            ad6     ONLINE       0     0     0
          mirror    DEGRADED     0     0     0
            ad8     UNAVAIL      0     0     0  cannot open
            ad10    ONLINE       0     0     0

errors: No known data errors

Put the disk offline:

[root@pr0nserv ~]# zpool offline pr0nserv ad8
[root@pr0nserv ~]# zpool status
  pool: pr0nserv
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
        Sufficient replicas exist for the pool to continue functioning in a
        degraded state.
action: Online the device using 'zpool online' or replace the device with
        'zpool replace'.
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        pr0nserv    DEGRADED     0     0     0
          mirror    ONLINE       0     0     0
            ad4     ONLINE       0     0     0
            ad6     ONLINE       0     0     0
          mirror    DEGRADED     0     0     0
            ad8     OFFLINE      0     0     0
            ad10    ONLINE       0     0     0

errors: No known data errors

Power off, replace the faulty disk (i use to put a small label on disks so i know immediately which one is dead).
Restart and “replace” the disk in the ZFS pool:

[root@pr0nserv ~]# zpool replace pr0nserv ad8
[root@pr0nserv ~]# zpool status
  pool: pr0nserv
 state: DEGRADED
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
 scrub: resilver in progress for 0h0m, 0.00% done, 5h18m to go
config:

        NAME           STATE     READ WRITE CKSUM
        pr0nserv       DEGRADED     0     0     0
          mirror       ONLINE       0     0     0
            ad4        ONLINE       0     0     0
            ad6        ONLINE       0     0     0
          mirror       DEGRADED     0     0     0
            replacing  DEGRADED     0     0     0
              ad8/old  OFFLINE      0     0     0
              ad8      ONLINE       0     0     0  4.62M resilvered
            ad10       ONLINE       0     0     0

errors: No known data errors

Volunia, much more than a search engine

Categories: Interwebz
Tags:
Published on: November 12, 2011

Massimo Marchiori introduces Volunia, much more than a search engine.

page 1 of 11»
Please support our sponsors ;)
Welcome , today is Wednesday, February 22, 2012