Categories: BSD

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

find: remove directories from output

Categories: BSD, Linux
Tags:
Published on: April 9, 2011

To remove the full path to your find results add:

-exec basename {} \;

to your search:

bash-4.1$ find . -type f -name "*.pdf" -exec basename {} \;
FreeBSD_Portability_With_VMware_BSD_04_2011.pdf
Network_Security_Hakin9_02_2011.pdf

Apache: _default_ VirtualHost overlap on port 443, the first has precedence

Categories: BSD, Linux
Published on: April 8, 2011

If you have just added another VirtualHost with SSL and Apache is giving to you this error:

[warn] _default_ VirtualHost overlap on port 443, the first has precedence

Probably you miss a

NameVirtualHost *:443

at the top of your httpd-vhosts.conf file.

FreeBSD: add or remove an user to a group

Categories: BSD
Tags: , , ,
Published on: April 5, 2011

If you need to add an user to an existing group, or more than one, do:

pw usermod username -G group1,group2,group3

Remember that the user will be inserted ONLY in the groups that you have specified in the grouplist. If your user is in the wheel group and you do a -G ftp,games he’ll be removed from wheel and you’ll not be able to su- to root.

If you need to create a group:

pw groupadd groupname

If you need to see the users of a group:

pw groupshow groupname

If you need to remove an user from a group (for example, group2) you have to set a new list of groups and you’ve to know in which groups the user is currently:

id -Gn username
pw usermod username -G group1,group3

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