initramfs script's to backup system's (also raid1) and restore from a usb stick 
These are scripts to backup system's and build an image for an usb stick or kvm for testing:

rescue.tar.gz

The only thing to configure is the backup-script:

All your partition's must have an UUID.

With "uuidgen | xargs mkswap /dev/sda1 -U" and "uuidgen | xargs tune2fs /dev/sda1 -U" you can generate one.


This is an example of a backup of a system with two partitions:
#!/bin/sh

cat >root_exclude <<EOF
/lost+found/*
/tmp/*
EOF

cat >var_exclude <<EOF
./tmp/*
./run/*
./lock/*
./log/messages*
./lost+found/*
EOF

sudo tar -cSp --one-file-system --numeric-owner --atime-preserve \
--exclude-from=root_exclude -f $(hostname).root.tar /

sudo tar -cjSp --one-file-system --numeric-owner --atime-preserve \
--exclude-from=var_exclude -f $(hostname).var.tar.bz2 --directory /var .

uuid() { sudo blkid -o value -s UUID /dev/$1; }
fstype() { sudo blkid -o value -s TYPE /dev/$1; }
inodesize() { sudo tune2fs -l /dev/$1 | grep "Inode size" | sed -e 's/[^0-9]//g'; }
raiduuid() { sudo sed -n "s/^.*$1.*UUID=\(.*\)/\1/p" /etc/mdadm/mdadm.conf; }
partitioninfo() { echo "$(echo $1|sed -e 's/[^0-9]//g') $(uuid $1) $(fstype $1)"; }

cat >$(hostname).cfg <<EOF
DISK_PARTITIONS=",1024,S;,10000,L,*;,,L"
ARCHIVES="$(partitioninfo sda2) $(hostname).root.tar.bz2
$(partitioninfo sda3) $(hostname).var.tar.bz2"
SWAP="1 $(uuid sda1)"
GRUB=1
GRUB1_PARTITION=1
GRUB1_INODESIZE=$(inodesize sda2)
EOF
* for each tar an exlude-file can be defined
* files are named HOSTNAME.root.tar.bz2, HOSTNAME.var.tar.bz2 and HOSTNAME.cfg
* this backup needs a small config-file (HOSTNAME.cfg)

DISK_PARTITIONS is used by sfdisk and has to be definded in its INPUT FORMAT
ARCHIVES takes a config line for each partition with an optional tar archive at the end
SWAP starts with the number of the partition and the uuid of it
GRUB needs the version of grub
GRUB1_PARTITION is only needed for grub 1 and is the boot partition (counting starts with 0)
GRUB1_INODESIZE is needed because older grub1 can not boot with a filesystem of different inode size

For a raid1 system with only one filesystem the config looks like
DISK_PARTITIONS=",8000,S;,,L,* ,8000,S;,,L,*"
RAID_UUIDS="$(raiduuid md0) $(raiduuid md1)"
ARCHIVES="$(partitioninfo md1) $(hostname).root.tar.bz2"
SWAP="0 $(uuid md0)"
GRUB=1
GRUB1_PARTITION=1
GRUB1_INODESIZE=$(inodesize md1)
After running the backup script HOSTNAME.root.tar.bz2, HOSTNAME.var.tar.bz2 and HOSTNAME.cfg are build.
Now you can run ./rescue-build.sh or copy these files to your backup server (where you put the files from other systems) and run there ./rescue-build.sh. Now you got a directory called image with all your archives, your running kernel and a configured initrd (initramfs).
With ./rescue-create-stick.sh /dev/STICKDEVICE your stick to restore is prepared (Warning all data on the stick is erased!).

With kvm you can test the restore process:

Therefore run sudo ./rescue-create-kmv-image.sh.
The build image can be mounted with sudo ./rescue-kvm-mount.sh to ./mnt and unmounted with sudo ./rescue-kvm-umount.sh.
Test the image with rescue-kvm-restore.sh and test the restored image with ./rescue-kvm-test.sh.



[ view entry ] ( 1476 views )   |  print article
php script for sispmctl (power supply switching) 
#> apt-get install sispmctl

Switch Socket on with sispmctl -o 1, off with sispmctl -f 1 and get status with sispmctl -m all

To have premission for a webserver to execute the command:

/etc/udev/rules.d/90-local.rules:
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", \
ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="fd13", \
GROUP="www-data", MODE="0660"
Because sometimes a wrong status came back i read it twice and compare it
<?php

function sispm_status() {
$pins1=array(0=>'0'); $pins2=array(0=>'1');
while ($pins1 !== $pins2) {
unset($pins1);
unset($pins2);
exec("/usr/bin/sispmctl -qnm all", $pins1);
exec("/usr/bin/sispmctl -qnm all", $pins2);
}
return $pins1;
}
$pins = sispm_status();

if (isset($_POST['update']))
for ($i = 0; $i <= 3; $i++)
if (isset($_POST["pin$i"])) {
if (!$pins[$i]) exec("/usr/bin/sispmctl -qno ".($i+1)); }
else if ($pins[$i]) exec("/usr/bin/sispmctl -qnf ".($i+1));

$pins = sispm_status();

?>
<html>
<body>
<form method="post">
<input type="checkbox" name="pin0" value="1" <?= ($pins[0]?'checked':'') ?>> Socket 1<br>
<input type="checkbox" name="pin1" value="1" <?= ($pins[1]?'checked':'') ?>> Socket 2<br>
<input type="checkbox" name="pin2" value="1" <?= ($pins[2]?'checked':'') ?>> Socket 3<br>
<input type="checkbox" name="pin3" value="1" <?= ($pins[3]?'checked':'') ?>> Socket 4<br>
<input type="submit" name="update">
</form>
</body>
</html>

perl:
#!/usr/bin/perl

use strict;
use warnings;
use CGI;

my $cgi = CGI->new();

my @ports=("PC","Printer","-","-");

print "Content-type: text/html\n";

print "\n";

print "<HTML><HEAD><TITLE>USB Steckdosenleiste</TITLE><META http-equiv=\"refresh\" content=\"60;steckdose.cgi\"></HEAD>\n\n";

print "<BODY>\n";

for my $port ($cgi->param()) {
if ($cgi->param($port) eq "on") { system "/usr/bin/sispmctl -q -o $port"; }
elsif ($cgi->param($port) eq "off") { system "/usr/bin/sispmctl -q -f $port"; }
}

print "<H1>USB Steckdosenleiste</H1><UL>\n";
my @states = `/usr/bin/sispmctl -q -g all`;
my $cnt = 1;
for my $state (@states) {
if ($ports[$cnt-1] ne "-") {
if ($state eq "off\n") { print "<LI>".$ports[$cnt-1]." ist ausgeschaltet [<A href=\"steckdose.cgi?$cnt=on\">einschalten</A>]\n"; }
else { print "<LI>".$ports[$cnt-1]." ist eingeschaltet [<A href=\"steckdose.cgi?$cnt=off\">ausschalten</A>]\n"; }
}
$cnt++;
}
print "</UL>\n";

print "</BODY></HTML>"


[ view entry ] ( 1523 views )   |  print article
Automount and autounmount of usb sticks / discs 
Each partition of plugged in usb stick's should be accessible with automount.

My mountpoints will be /media/usb/part0, /media/usb/part1, ...

Example:

The fist plugged stick has two partitions. The second only one.

/media/usb/part0 ... first stick partition one
/media/usb/part1 ... first stick partition two
/media/usb/part2 ... second stick partition one

If the second stick is plugged in first:

/media/usb/part0 ... first stick partition one
/media/usb/part1 ... second stick partition one
/media/usb/part2 ... second stick partition two

/etc/udev/rules.d/90-local.rules
ACTION=="add", BUS=="usb", SUBSYSTEM=="block", KERNEL=="sd?[0-9]*", \
NAME="%k", PROGRAM="get_usbdisc_symlink", SYMLINK+="%c", OPTIONS+="nowatch"
OPTIONS+="nowatch" avoids removal by udev of the symlink after unmounting

/lib/udev/get_usbdisc_symlink
#!/bin/sh -e

. /lib/udev/rule_generator.functions

[ -h /dev/usbpart0 ] && \
echo usbpart$(raw_find_next_available $(ls /dev/usbpart[0-9]*)) || \
echo "usbpart0"

exit 0
#> apt-get install autofs5

/etc/auto.master
#+auto.master
/media/usb /etc/auto.usb --timeout=5 --ghost

My usb sticks will be unmounted after 5 seconds not being in use.
With "--ghost" /media/usb/partX will automatically created.

/etc/auto.usb
part0 -fstype=auto,noexec,nodev,nodiratime,noatime,nosuid :/dev/usbpart0
part1 -fstype=auto,noexec,nodev,nodiratime,noatime,nosuid :/dev/usbpart1
part2 -fstype=auto,noexec,nodev,nodiratime,noatime,nosuid :/dev/usbpart2
part3 -fstype=auto,noexec,nodev,nodiratime,noatime,nosuid :/dev/usbpart3
part4 -fstype=auto,noexec,nodev,nodiratime,noatime,nosuid :/dev/usbpart4
part5 -fstype=auto,noexec,nodev,nodiratime,noatime,nosuid :/dev/usbpart5
part6 -fstype=auto,noexec,nodev,nodiratime,noatime,nosuid :/dev/usbpart6
part7 -fstype=auto,noexec,nodev,nodiratime,noatime,nosuid :/dev/usbpart7
To have readwrite access for users add ",uid=$UID,gid=$GID"

For more partitions extend the lines.



[ view entry ] ( 2123 views )   |  print article
ssd optimizations 
* do partition alignment

Check if aligned at http://www.techpowerup.com/articles/other/157

Theodore Ts'o's blog post is somewhat misleading, as even that manufacturer's MLC SSDs have an erase block size of 512KiB (PDF), like OCZ's drives - not 128KiB. You're better off running fdisk -H 32 -S 32 /dev/sda, which will align partitions to 512KiB, and mke2fs -b 4096 -E stride=128,stripe-width=128 -t ext4 (128 * 4096B = 512KiB).

for partitioning see http://www.ocztechnologyforum.com/forum ... sing-fdisk

But without ATA TRIM your drive writes will decrease (depending on write usage)

The only solution seams to secure erase the whole drive and do a reinstall

* add "elevator=noop" to /boot/grub/menu.lst


Some tips i found but think this came from a myth:

* use a tempdir for logs

/etc/fstab
tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0

/etc/rc.local
for dir in apparmor apt ConsoleKit cups dist-upgrade fsck installer news samba unattended-upgrades; do
mkdir -p /var/log/$dir
done

* Set Firefox Cache to RAM
in about:config set browser.cache.disk.enable to false

* change the file system mount options on SSDs to "noatime"

[ view entry ] ( 2171 views )   |  print article
ubuntu 8.10 (intrepid ibex) troubles with an old Acer Travelmate 630 
I could not run the ubuntu live installcd and also the alternate hang sometimes. After a successful install X freezes. I tried to boot with various boot options. Only with acpi=off my system seams to working but with fan running and no battery info. An older knoppix was running, so i decided to install older ubuntu kernels and saw my system running with a gutsy kernel (2.6.22) but not with a hardy kernel (2.6.24).

What changed inside the kernel?

After searching a lot i found pci=nommconf.

It seams that something in the way pci is configured has changed.

[ view entry ] ( 879 views )   |  print article

<<First <Back | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Next> Last>>