Monday, October 6, 2008

Extending swap on RH LVM

Here: http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/Deployment_Guide-en-US/s2-swap-extending-lvm2.html

1. Disable swapping for the associated logical volume:
# swapoff -v /dev/VolGroup00/LogVol01

2. Resize the LVM2 logical volume by 256 MB:
# lvm lvresize /dev/VolGroup00/LogVol01 -L +256M

3. Format the new swap space:
# mkswap /dev/VolGroup00/LogVol01

4. Enable the extended logical volume:
# swapon -va

5. Test that the logical volume has been extended properly:
# cat /proc/swaps # free

Wednesday, August 13, 2008

Buggy ErrorDocument behavior in httpd 2.2.3

... and apparently earlier, too. I'm seeing lots of posts, and not spotting anything helpful in the documentation.

I've tried several cases for the ErrorDocument directive, and they break variously. (ETA: Actually, the http:// method works. Hooray!)

For the record, under httpd 1.3, the directive was
   ErrorDocument 404 /redirect/notfound.php
within a <VirtualHost, referring to a "redirect" subdirectory within the webroot.

  1. Put the error document outside the webroot, such as in ../error/404.html.

    Directive:
    <VirtualHost>
        ErrorDocument 404 /web/sph/error/404.html
    </VirtualHost>


    Note - all directives are within the virtualhost context. I started to experiment with the directory context, but I'm omitting that part since the results were the same.

    Result:
    A standard 404 with the note, "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

    Error_log:
    [Wed Aug 13 19:39:27 2008] [error] [client 10.0.0.246] File does not exist: /web/sph/html/asf
    [Wed Aug 13 19:39:27 2008] [error] [client 10.0.0.246] File does not exist: /web/sph/html/web

    Where on earth is it getting that "web" part??

  2. Okay, well, let's try putting the errordoc directly in the webroot.

    Directive:
        ErrorDocument 404 404.html

    Result:
    It actually DISPLAYS THE WORDS "404.html".

    Error_log:
    [Wed Aug 13 19:42:17 2008] [error] [client 10.0.0.246] File does not exist: /web/sph/html/asf



  3. Okay, let's put quotes around that last one.
    Directive:
        ErrorDocument 404 "404.html"

    Result:
    Same as above


  4. Fine ... try same location, full path. With and without quotes.

    Directive:
        ErrorDocument 404 /web/sph/html/404.html

    Result:
    Same as #1

    Error_log:
    [Wed Aug 13 19:46:54 2008] [error] [client 10.0.0.246] File does not exist: /web/sph/html/asf
    [Wed Aug 13 19:46:54 2008] [error] [client 10.0.0.246] File does not exist: /web/sph/html/web

  5. Screw you, httpd.

  6. Okay, obviously something different is necessary. Try it with an URL.
    Directive:
        ErrorDocument 404 http://www.whereiwork.edu/errdoc/404.html

    Result:
    If the subdirectory was named "error", I got a warning about an impossible redirect. Since that wasn't coming from anything I'd configured, I guessed "error" was reserved for something and changed it to errdoc. At that point, I got the actual contents of the doc I wanted.

I'd like to understand how this directive is supposed to work, or find the bug report thereon, but I'd like much more to go home.

Friday, July 11, 2008

Enabling NTP on Sol 10

- Create /etc/inet/ntp.conf containing
server ntp.mycompany.com
driftfile /etc/ntp.drift


- Create /etc/ntp.drift containing
0.0

- Start the NTP client
svcadm ntp enable
(Look in /etc/rc2.d on Sol 9)

I have read that Solaris NTP does not start updating until it is 10 minutes out of whack.

Thursday, June 12, 2008

Dumb: Enable telnet client on Vista

You're not losing your marbles -- it really is gone, in the name of "reducing the attack surface" of Vista/Longhorn.

Well, sort of gone -- just gotta check a box under Programs & Feats.

http://blogs.msdn.com/shamit/archive/2006/07/07/659513.aspx

Clicky clicky!

Wednesday, June 11, 2008

Extend a Redhat LVM filesystem

Slightly simpler case than the earlier one ... this is just something I'd like to have spelled out for convenience, since I do it so rarely.

We want to fix this:
/dev/mapper/prod_dg-volOracle
4128448 3918544 192 100% /u01

And we have this:
[root@woogie /]# lvscan
...
ACTIVE '/dev/prod_dg/volOracle' [4.00 GB] inherit
[root@woogie /]# pvscan
...
PV /dev/sdb1 VG prod_dg lvm2 [273.22 GB / 139.44 GB free]


So we do this:
[root@woogie /]# lvextend --size 6G /dev/prod_dg/volOracle /dev/sdb1
Extending logical volume volOracle to 6.00 GB
Logical volume volOracle successfully resized


(lvextend usage: lvextend --size nG logical-path physical-path ... Use the paths from pvscan and lvscan, and absolute or relative sizes denoted by K,M,G, etc.)


[root@woogie /]# umount /u01
[root@woogie /]# resize2fs /dev/prod_dg/volOracle 6G
resize2fs 1.35 (28-Feb-2004)
Please run 'e2fsck -f /dev/prod_dg/volOracle' first.

[root@woogie /]# e2fsck -f /dev/prod_dg/volOracle
e2fsck 1.35 (28-Feb-2004)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/prod_dg/volOracle: 27925/524288 files (3.4% non-contiguous), 996131/1048576 blocks
[root@woogie /]# resize2fs /dev/prod_dg/volOracle 6G
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/prod_dg/volOracle to 1572864 (4k) blocks.
The filesystem on /dev/prod_dg/volOracle is now 1572864 blocks long.

[root@woogie /]# mount /u01

Wednesday, April 30, 2008

ACLs are enabled by default in Solaris 2.9

... and probably earlier. This says ACLs were "integrated" into 2.5 back in 1995, which might explain why they're finicky in 2.9. Anyway, I don't want to look this up again and won't believe myself next time it matters, so here I am using ACLs in / on 2.9, where I wouldn't have enabled them on purpose.
buzz> cd /
buzz> touch foo
buzz> setfacl -r -m u:karen:rwx foo
buzz> su karen
buzz> id
uid=1234(karen) gid=200(staff)
buzz> ls -l foo
-rw-r--r--+  1 root     other          0 Apr 30 11:35 foo
buzz> echo "bar" > foo
buzz> ls -l foo
-rw-r--r--+  1 root     other          4 Apr 30 11:36 foo
Here's an entry from a similar blog describing getfacl/setfacl usage on Solaris. Red Hat usage is similar, except: # There's no -r flag, because recalculation is implicit # Partial default ACLs are allowed. (You can set a default user, for example, without having to set defaults for group, other and mask.)

Thursday, April 24, 2008

Creating a local CA and certs

http://www.technocage.com/~caskey/openssl/

http://blogs.techrepublic.com.com/opensource/?p=200

http://www.octaldream.com/~scottm/talks/ssl/opensslca.html

pvscan and lvcreate

Working with disks on RedHat LVM...
  1. Create a new ext3 FS where room already exists on a physical volume. (RH4)
    [root@here /]# pvscan
      PV /dev/sdb1   VG prod_dg   lvm2 [273.22 GB / 139.44 GB free]
      PV /dev/sda2   VG rootdg    lvm2 [134.66 GB / 106.06 GB free]
      Total: 2 [407.88 GB] / in use: 2 [407.88 GB] / in no VG: 0 [0   ]
    [root@here /]# lvcreate --size 5G -n homeVol -t rootdg             # Minus t for "test"
      Test mode: Metadata will NOT be updated.
      Failed to activate new LV.
    [root@here /]# lvcreate --size 5G -n homeVol rootdg
      Logical volume "homeVol" created
    [root@here /]# mkfs.ext3 -b 1024 -T ext3 /dev/rootdg/homeVol
    mke2fs 1.35 (28-Feb-2004)
    Filesystem label=
    OS type: Linux
    ...
    [root@here /]# vi /etc/fstab
    # add new FS
    [root@here /]# mount /home
    [root@wcidb1 etc]# df -T
    ...
    /dev/mapper/rootdg-homeVol
                  ext3     5159385     11824   4885417   1% /home
    
  2. Free space from the root filesystem (from notes taken while watching someone else -- incomplete and not tested!) - Boot from a rescue CD - ? fdisk -l -- look for "Linux LVM" and note the device path - ? Find out what VG is on that device: pvscan - Find out what LV the root filesystem is on: lvscan - Make the filesystem smaller than the new LV size: resize2fs /dev/whatever newsize, with K/G/M trailer - Activate the LV: lvm lvchange -a y /dev/whatever - Shrink the LV: lvm lvreduce --size -1G --resizefs /dev/whatever

Wednesday, April 9, 2008

Cyrus IMAP permissions

Full access to a Cyrus mailbox is "lrswipcda", as in setacl user/jqpublic jsixpack lrswipcda. This allows Joe Sixpack to map John Q Public's folder and change it any way he sees fit, including granting access to yet more users.

Occasionally, Human Resources or a successor needs access to a former employee's mailbox. A better set of permissions for this case is simply "lr", allowing list and read access while preventing changes.

To revoke permissions, issue a setacl command with empty quotes in place of the privilege flags: setacl user/jqpublic jsixpack "" . Mail clients that present an Other Users folder should remove that folder after this change, but the client might need a restart.

The privilege flags are:
* (l) Lookup (mailbox visible to # LIST/LSUB/UNSEEN)
* (r) Read (SELECT, CHECK, FETCH, PARTIAL, SEARCH, COPY source)
* (s) Seen (STORE \SEEN)
* (w) Write flags other than \SEEN and \DELETED
* (i) Insert (APPEND, COPY destination)*
* (p) Post (send mail to mailbox)
* (c) Create and Delete mailbox (CREATE new sub-mailboxes, RENAME or DELETE mailbox)
* (d) Delete (STORE \DELETED, EXPUNGE)
* (a) Administer (SETACL)

Privilege flags section cribbed adapted from Wil Cooley's presentation at http://nakedape.cc/info/Cyrus-IMAP-Intro/ .