I used to have an encrypted volume on my file server, for storing sensitive things, but after an upgrade to the newest version of Debian, that stopped working. So after some mucking around and getting the old module for cryptoloop put back into my current kernel, I figured i might as well migrate over to the newer version, which uses cryptsetup, losetup, and luks.

Ive shamelessly stolen these commands (although ive changed some of them)from elsewhere..

Create the file system and restricted access.

dd of=/path/to/secretfs bs=1G count=0 seek=8
chmod 600 /path/to/secretfs

Create a loopback device for the file
losetup /dev/loop0 /path/to/secretfs
Creates the volume, asks you for the key, and then creatss the DM mapping
cryptsetup -y luksFormat /dev/loop0
cryptsetup luksOpen /dev/loop0 secretfs

Pad the file so it generates its random data
dd if=/dev/zero of=/dev/mapper/secretfs

Create the filesystem
mkfs.ext3 dev/mapper/secretfs

# Mount the new filesystem in a convenient location
mkdir /mnt/cryptofs/secretfs
mount /dev/mapper/secretfs /mnt/cryptofs/secretfs

And an encrypted volume is setup.

Now how to unmount:

umount /mnt/cryptofs/secretfs
cryptsetup luksClose secretfs
losetup -d /dev/loop0

Remount:

losetup /dev/loop0 /path/to/secretfs
cryptsetup luksOpen /dev/loop0 secretfs
(enter password when prompted)
mount /dev/mapper/secretfs /mnt/cryptofs/secretfs

Now stuff that i can never remember how to do is grow the volume.

Make sure the volume is closed, unmounted etc.
umount /mnt/cryptofs/secretfs
cryptsetup luksClose secretfs
losetup -d /dev/loop0

Add 20gig to the file
dd if=/dev/zero bs=1G count=20 >> /dev/mapper/secretfs

Remount and reopen part of it

losetup /dev/loop0 /path/to/secretfs
cryptsetup lucksOpen /dev/loop5 EncryptedFS

check the FS first
e2fsck -f /dev/mapper/EncryptedFS

once thats done grow it
resize2fs /dev/mapper/EncryptedFS
and your done. You can now open the volume for use

Backed up and restored a database the other day, but of course the network users arent setup properly cause there actually stored in the master database..

So i recreate the user on the instance which is fine , and then try and regrant it permissions on the database but it fails because its already there…

To fix…

User DATABASE
EXEC sp_change_users_login 'update_one', 'usernamehere', 'usernamehere''

http://msdn.microsoft.com/en-us/library/ms174378.aspx

I wanted to pull my iphone backups apart because i accidentally deleted some stuff but didn’t want to restore it all and play with it that way.

So heres the tools and what i needed to do it:
Backups are stored at: ~/Library/Application Support/MobileSync/Backup) or on a PC (c:\Documents and Settings\Application Data\Apple Computer\MobileSync\Backup).

Iphone backup extractor for OSX
how-to-save-and-read-your-iphone-text-messages-on-your-computer
how-to-recover-your-iphone-files-photos-contacts-notes-sms-call-history-etc

Couldnt work out how to pull up previous backups though.. only the latest one.. which is a pain..

Shorter emails are better.. apparently

Rounds Timefieldhere to the nearest 5 minutes..

trunc(timefieldhere,'dd') + round(to_char(timefieldhere,'sssss') / 300) / 288)

Trying to use sed in some stuff and i never want to have to write this kinda crap again so..

grep '^D' Filename  | sed -e 's/\(^.\{43\}\)0\(.*\)/\1M\2/g'

That looks for any line in “Filename” that starts with D… then if the 44th character is 0, replace it with an M.
kgo.

grep "^D" Filename | sed -e 's/.*/&XX/'

That looks for anything in Filename and adds “XX” to the end of the line..
Another Useful link

For work i had to come up with a way to remap printers since our current print server is on the way out.. I was pondering at home about the best way to do this with minimal work for the service desk or for me, and this is what i came up with.. Easy way to map any old printers to new ones.. Just have to update the findnewPrinter function with the old vs new printers..

'Script to map and remove printers from old print server to new one
'Needs an entry in findNewPrinter function for each mapping
'nfrankish;2010-03-21

Set objNetwork = CreateObject("Wscript.Network")
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Function findNewPrinter(Printername)
                select case PrinterName
                case "\\OldPrintServer\OldPrinterQueue"
                                findNewPrinter = "\\newprintserver\newprintqueue"
                case else
                                wscript.echo  "Printer: " & Printername & " not found"
                                findNewPrinter = ""
                end select
end function

Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where Local = FALSE")

For Each objPrinter in colPrinters
                wscript.echo "Printer: " & objprinter.Name & " Default: " & objprinter.default
                strNewPrinter = findNewPrinter(objprinter.name)
                if not (strNewPrinter = "") then
                                objNetwork.AddWindowsPRinterConnection strNewPrinter
                                if (objPrinter.default) then
                                                objNetwork.SetDefaultPrinter strNewPrinter
                                end if
                                objNetwork.RemovePrinterConnection objprinter.name, true, true
               end if
Next

So I’ve been with Linode.com now for coming up on either 3 or 4 years, I’ve lost track now. I was looking for a remote server that i could play with and run a few services such as mail and maybe a web page or two. So a friend and I bought a linode. Back then the lowest linode you could get was a 32mb linode (32mb of ram), and i think it hat 4gig of HDD space. Not a lot but it was reasonable at 19.95$ a month.

Low and behold 3-4 years later, for the same price linode now offers the Linode 360, with 10Gig of storage off the bat. Every 6 months or so, so far, the team at Linode have managed to excite us all, by giving us free upgrades, the last one 20% ram increase for xmas. Ive been through countless free RAM upgrades, as well as storage, and transfer, and not once has there been a cost associated with it.

The only reason i can say that my uptime is not massively large, is that they keep giving out these upgrades that require us to reboot to take advantage of them. Otherwise i havnt had a much of a problem or downtime, that i havn’t caused myself, or was outside of Linode’s reachs (Datacentre issues).

Thats not to mention the friendliness and helpfulness of the 3 admins, Caker, Tasaro, and Mikegrb who are always available via the ticketing system, and atleast one is generally lurking in the irc channel (#linode on irc.oftc.net). On top of the help from the staff, there are always people arround in the chat channel that are more then willing to help out on just about any linux topic, linode related, or not. That and the forums are always bristling with activity, be it howto guides, customer feedback, announcements or community help requests with specific platform/software packages.

These days i have 3 linodes, 2x 360mb, and a 540mb one, ive never looked back…

With servers in 3 different data centres, full root access, friendly staff and a great community behind them, if your looking for a VPS, you can stop looking. Linode is the place to be.

www.linode.com Got root?

Well i got a few more drives today for my file server, and one of the things i couldnt remember was how to add to the LVM device that exists that stores all my loot.

First off there is
pvdisplay which shows you which physical drives are alocated to what volume group
lvdisplay which gives you details about the actually logical volume, such as its status etc.

Now the part that initially tripped me up was forgetting to create the partition to LVM type on the raid
pvcreate /path/to/device
It’ll show up something like this

pvcreate /dev/md3
Physical volume “/dev/md3″ successfully created

Next step is to add it to the existing group
vgextend /path/to/device

channel:/etc/lvm# vgextend vg00 /dev/md3
Volume group “vg00″ successfully extended

Now that its in the volume group and its extended that group to incorporate all the devices, you need to extend the logical volume.
lvextend -l +536551 /dev/vg00/lv_space
Where 536551 is the extents listed as free as shwon by pvdisplay

Now that that is done, its just a matter of extending the file system..

So after gearing up to do some changing to my security stuff, i was looking in on suexec. Suexec is great, it runs all processes launched from apache as the person that actually owns them and does a lot of checking to make sure things are what they are meant to be.

The only down side is, its default options are compiled in and cannot be changed. So on Debian this obviously presents a challenge. Never fear! We can rebuild it!!.
Starting off,

cd /usr/src
apt-get build-dep apache2.2-common
apt-get source apache2.2-common

Wait patiently for stuff to download and unzip and then head into the directory it just created. Should be something like this

cd apache2-2.2.3/

Now you want to edit the debian build rules so that it changes the suexec stuff

vi debian/rules

Just near the top there is
AP2_COMMON_CONFARGS

And you will notice that it has a lot of references to suexec.
Just change the options to what you want. In my case i want to change the docroot to be /home/hosting
so mine looks like
--with-suexec-docroot=/home/hosting \

Now to stop apache getting overwritten with the same version next time you update, we need to increment the build number.
dch -i
(Note: if you don’t have this command you need to install devscripts )
edit the build notes at the top to say what you changed, and then exit.

then simply build the package
dpkg-buildpackage
if you now goto the /usr/src directory you will have all the .deb files that you need to install
dpkg -i the ones you need such as apache2.2-common etc, and then run apt-get -f install to install any extra dependencies and your done.

Next Page »