Categories: Linux

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.

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         -

Linux kernel 3.0 is out.

Categories: Linux
Tags:
Published on: July 22, 2011

Linus Torvalds told us on Google+.
Let’s see how much we’ll have to wait to see it in Slackware -current :)

HP-2137sl volume bar configuration

Categories: Linux, Slackware
Published on: July 6, 2011

Like described in the previous post, find both codes for increase/decrease volume with xev:

KeyPress event, serial 34, synthetic NO, window 0x3400001,
root 0x15d, subw 0x0, time 979988, (423,-222), root:(1017,104),
state 0x10, keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyPress event, serial 34, synthetic NO, window 0x3400001,
root 0x15d, subw 0x0, time 978476, (423,-222), root:(1017,104),
state 0x10, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

Add those codes to ~/.xmodmaprc file:

keycode 121 = F24
keycode 122 = F25
keycode 123 = F26

And the corrispondent commands to ~/.xbindkeysrc:

# Muto
"amixer -c 0 sset Speaker,0 toggle"
m:0x10 + c:121
Mod2 + F24

# Abbassa volume
"amixer -c 0 sset Master 5%-"
m:0x10 + c:122
Mod2 + F25

# Alza volume
"amixer -c 0 sset Master 5%+"
m:0x10 + c:123
Mod2 + F26

I’ve added this command at the end of ~/.bashrc to have the key bindings loaded when X start:

xbindkeys -f /home/simplex/.xbindkeysrc

That’s all.

Audio mute/unmute hotkey on HP DV6-2137sl with Slackware/Linux

Categories: Linux, Slackware
Published on: July 6, 2011

It could be useful sometimes, so…
Use xev to know the code generate by the button, type xev in a terminal and after a bit of some unnecessary codes, press the audio button, you will see something like this:

KeyRelease event, serial 34, synthetic NO, window 0x3800001,
root 0x15d, subw 0x0, time 7145078, (-71,-326), root:(523,0),
state 0x10, keycode 121 (keysym 0x1008ff12, XF86AudioMute), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False

The important part is keycode 121, in my case.
Create the file ~/.xmodmaprc and put in it:

keycode 121 = F24

F24 is an arbitrary code chosen by me, you can use whatever you want but i suggest F+number, greater than 12.
Now install xbindkeysrc, you can find it at slackbuilds.org, compile and install.
Then do

xbindkeys --defaults > /home/simplex/.xbindkeysrc

to create the default configuration.
Add the part for audio mute/unmute at the bottom:

# Muto
"amixer -c 0 sset Speaker,0 toggle"
m:0x10 + c:121
Mod2 + F24

Replace the 121 and F24 with your codes, the part in “” is the command that you want to run when the button is pressed, in this case the mute/unmute of our notebook speakers.
Next time, the volume bar!

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