Marius van Witzenburg We fight for our survival, we fight!

1Jul/110

How to fix ACL errors in diskutility

Posted by mariusvw

If you try to repair permissions and get a bunch of acls found but not expected.

To fix this some chmod commands need to be executed in the terminal.

Essentially open up a terminal and do the following:

cd /
ls -le

Look at the Applications and Library folders in the listing and you should see they have specific ACLs. On one of my machines the Applications folder had 2 and the Library had one. On the other both had just one.

To remove these ACLs do the following:

sudo chmod -a# 0 "/Applications"
sudo chmod -a# 0 "/Library"
# etc...

If you had more than one on either directory you can execute the same command until they are gone.

9Jun/110

How to DoD 5220.22-M secure wipe a disk

Posted by mariusvw

If you need to trash a disk its always smart to first erase all your data in a way others cannot recover it easily.

This script is a nice way to wipe it on a DoD 5220.22-M compatible way.

!/bin/sh
 
if [ -z "$1" ]
then
    echo "Usage: $0 ad1"
    exit    
fi
 
doExit() {
    exit $? 
}
trap doExit SIGINT
 
confirmed=0
for n in 1 2 3 4 5 6 7 
do
    if [ -c "/dev/$1" ]
    then    
        if [ "$confirmed" -eq 0 ] 
        then    
            echo "Erase /dev/$1 ?"
            read -e confirm 
        fi      
        if [ "$confirm" = "yes" ] 
        then    
            confirmed=1
            /bin/dd if=/dev/urandom of=/dev/$1 bs=8b
        else    
            echo "Be careful!"
            exit    
        fi      
    else    
        echo "Device not found!"
        exit    
    fi
done
4Jul/100

How to determine the partition sizes of your disk for FreeBSD usage

Posted by mariusvw

Partition sizes

First of all, what I mostly do. I press A for the default partitions and then raise them. Below are some default sizes who are advised.

partition mountpoint size SoftUpdates my size
a / 1GB N 1GB
b SWAP 2-3x RAM size - 2x RAM size
d /var 512MB to 4096MB Y 5GB
e /tmp 1GB Y 1GB
f /usr Rest of disk (at least 8GB) Y Rest

For the root partition it might be smart to keep track of how large the kernel is.

This size was a default of 512MB but this is too small to install 2 kernels (kernel and kernel.old).

Another thing is the /tmp partition, this defaults to 512MB, raise it to 1GB (for tar / gzip etc)

11Mar/108

How to backup from a Western Digital Sharespace to another Sharespace

Posted by mariusvw

There is a newer version of this script available here.

You might need this: How to enable SSH on a Western Digital ShareSpace

For a script running from a FreeBSD server check this script.
~~~
Lately I've been busy with making a backup script to automate the backup of a WD Sharespace drive.

This script has been made to backup between two Sharespace drives.

The script works quite simple. In a endless loop it keeps on running when you start it to the background with: ./backup.sh &

It scans for the shares on your master drive and it will Rsync it to your slave drive on the share backup.

Put this script on your slave drive in /root/backup.sh

If you decide to modify this script please leave my name in the script.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
time=5
src_ip="192.168.3.3"
log="/root/backup.log"
 
# Written by Marius van Witzenburg
# http://kitara.nl
 
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
PID=$$
cleanup() {
    rm -f ${log}
    return $?
}
s_hup() {
    echo -e "n*** SIGHUP! Ignoring ***n"
    cleanup
    #exit $?
}
s_int() {
    echo -en "n*** SIGINT! Exiting ***n"
    kill ${JOB}
    exit $?
}
s_term() {
    echo -en "n*** SIGTERM! Exiting ***n"
    kill ${JOB}
    exit $?
}
 
trap s_hup SIGHUP
trap s_int SIGINT
trap s_term SIGTERM
 
echo "Having a rest for the first run..." > ${log}
sleep 30 &
JOB=$!
wait ${JOB}
 
echo "Running backup..." >> ${log}
while [ "true" ]
do
    for x in `ssh ${src_ip} ls -l /shares/| grep "^d" | awk '{ print $9 }'`
    do
        if [ ! -z ${x} ]
        then
            output=''
            if [ ! -z "`expr ${x} : '(usb[0-9]-[0-9]share[0-9])'`" ]
            then
                if [ -d "/shares/${x}" ]
                then
                    echo -e "USB Syncing '/shares/${x}' to '/shares/${x}'n" >> $log
                    rsync -qau --no-t --checksum --delete ${src_ip}:/shares/${x}/ /shares/${x}/ & 2>> ${log} 1> /dev/null
                    JOB=$!
                    wait ${JOB}
                    echo -e "n${JOB} -- finished.nn" >> ${log}
                else
                    echo -e "Skipping USB for '/shares/${x}'n" >> ${log}
                fi
            else
                echo -e "Syncing '/shares/${x}' to '/shares/backup/${x}'n" >> $log
                rsync -qau --no-t --checksum --delete ${src_ip}:/shares/${x}/ /shares/backup/${x}/ & 2>> ${log} 1> /dev/null
                JOB=$!
                wait ${JOB}
                echo -e "n${JOB} -- finished.nn" >> ${log}
            fi
        fi
    done
    message=`cat ${log}`
    echo -e "From: noreply@kitara.nlnTo: info@kitara.nlnSubject: ShareSpace backup output.nn${message}" | /usr/sbin/msmtp info@kitara.nl
    echo -e "Waiting for cycle (${time} minutes)...n" >> ${log}
    sleep `expr ${time} * 60` &
    JOB=$!
    wait ${JOB}
    echo "Running cycle..." > ${log}
done
# EOF

Comments and donations are more than welcome :-)