Blog

All my blogging here :D

Make a text file and in it put:

NET USE X: \\servername\%username%

REG DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##servername#%username% /v _LabelFromReg /f

REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##servername#%username% /v _LabelFromReg /t REG_SZ /d WHATEVERYOUWANTTOCALLYOURDRIVE

Save the file, change its ending to .bat and run it as a logon script

If it works as planned, each user should then see a drive "X:" with whatever you want to call it.

Note that the samba share must be the same name as the username

This came from a friend V0lZy on Freenode IRC.

Romster - 30th September 2009

This is a howto remove Linux such as Ubuntu from a dual boot Windows setup.
There is a free utility to replace the boot loader back to what Vista uses, called Easy BCD from NeoSmart Technologies. Which can be downloaded here.

Here is a screen shot of how simple it is to restore the master boot record.

Now it's a simple matter of going into "disk management" in Windows and removing the Linux partition and resizing the Windows one.

Romster - 6th January 2009

This short script will remove old *.desktop files that point to missing WINEPREFIXs

#!/bin/sh
# Created by Danny Rawlins, <Romster> on freenode.
#
# This cleans out menu *.desktop files for missing WINEPREFIX

# find and delete wine menu files for missing WINEPREFIX
find "${HOME}/.local/share/applications/wine/" -type f -print | while IFS="$(printf "\n\b")" read FILE; do
if [ ! -e "$(grep '^Exec=' "${FILE}" | sed -ne 's|.*WINEPREFIX="\([^\"]*\)".*|\1|p')" ]; then
rm "${FILE}"
fi
done

# remove empty directorys
find "${HOME}/.local/share/applications/wine/" -depth -empty -exec rm -rf '{}' \;

# End of file

Romster - 5th January 2009

List the partiton table on the file then. we calculate the offset for mount in this example.

Device      Boot  Start  End        Blocks    Id   System
lists.img1  *       63      208844  104391  83  Linux

The equation is: "start sector * block size = offset"
63 * 512 = 32256

So in this example the command to mount this is.

mount -o offset=32256 <ImageFile> <MountPoint>

Note that there is a easier way using the command 'kpartx' found in 'multipath-tools'.

Romster - 31th December 2008

Have sda1 as a LVM2 volume and would like to convert it to LVM on RAID1?

Create the degraded RAID1

# mdadm --create /dev/<md0> --level=1 --raid-devices=2 /dev/<sdb1> missing

Do the LVM stuff.

# pvcreate /dev/<md0>
# vgextend <VolumeGroupName> <PhysicalDevicePath>
# pvmove <SourcePhysicalVolume> <DestinationPhysicalVolume>
# vgreduce <VolumeGroupName> <PhysicalVolumePath>

You may want/need to clear the partition table and boot loader on the empty disk

# dd if=/dev/zero of=/dev/<sda> bs=512 count=1

Add the now empty disk to <md0>

# mdadm /dev/<md0> --add /dev/<sda1>

Rebuild the RAID array

# mdadm /dev/md0 --rebuild
Romster - 14th December 2008

I decided to play with some ANSI colour and position codes and I have always liked this old DOS activity bar so I decided to recreate it.

printf "\033[?25l"
for a in {1..10}; do
   for i in \| / - \\; do
      printf -- "\033[1m\033[94m%s\033[u" "$i"
      perl -e 'select(undef,undef,undef,.25)'
   done
done
printf "\033[?25h\033[0m\n"
Romster - 07th November 2008

First off I will assume you have a working setup.

We should already have the loopback and first lan interface like this example.

/sbin/ip addr add 127.0.0.1/8 dev lo broadcast + scope host
/sbin/ip link set lo up
/sbin/ip addr add 192.168.0.1/24 dev eth1 broadcast +
/sbin/ip link set eth1 up

Now we add in the second one like so.

/sbin/ip addr add 192.168.0.2/24 dev eth2 broadcast +
/sbin/ip link set eth2 up

Giving it a new IP number.

Now we add a forward rule to allow out bound connections if the default policy is set to DROP (recomended).

iptables -A FORWARD -i eth2 -o ppp0 -m state --state NEW -j ACCEPT

And add inbound rules as required.

Romster - 25th September 2008

Inbound shaping for a number of clients on a slow network.

First off we setup IMQ and set some defaults

modprobe imq numdevs=1
ip link set imq0 up
ip link set txqueuelen 16 imq0
ip link set mtu 1500 imq0

Add root class.

tc qdisc add dev imq0 root handle 1:0 hfsc default 20

Add leaf class to root class

tc class add dev imq0 parent 1:0 classid 1:1 hfsc sc rate 400kbit ul rate 400kbit
tc class add dev imq0 parent 1:1 classid 1:100 hfsc ls rate 300kbit ul rate 400kbit
tc class add dev imq0 parent 1:1 classid 1:110 hfsc ls rate 100kbit ul rate 400kbit

Add leaf class to class 100

tc class add dev imq0 parent 1:100 classid 1:201 hfsc ls rate 60kbit ul rate 400kbit
tc class add dev imq0 parent 1:100 classid 1:202 hfsc ls rate 60kbit ul rate 400kbit
tc class add dev imq0 parent 1:100 classid 1:203 hfsc ls rate 60kbit ul rate 400kbit
tc class add dev imq0 parent 1:100 classid 1:204 hfsc ls rate 60kbit ul rate 400kbit
tc class add dev imq0 parent 1:100 classid 1:205 hfsc ls rate 60kbit ul rate 400kbit

Attach qdisc to leaf classes

tc qdisc add dev imq0 parent 1:100 sfq perturb 10 quantum 1500
tc qdisc add dev imq0 parent 1:110 sfq perturb 10 quantum 1500
tc qdisc add dev imq0 parent 1:201 sfq perturb 10 quantum 1500
tc qdisc add dev imq0 parent 1:202 sfq perturb 10 quantum 1500
tc qdisc add dev imq0 parent 1:203 sfq perturb 10 quantum 1500
tc qdisc add dev imq0 parent 1:204 sfq perturb 10 quantum 1500
tc qdisc add dev imq0 parent 1:205 sfq perturb 10 quantum 1500

iptables ‐t mangle ‐I PREROUTING ‐i ppp0 ‐d 192.168.1.1 ‐j CLASSIFY ‐‐set‐class 201:1
iptables ‐t mangle ‐I PREROUTING ‐i ppp0 ‐d 192.168.1.2 ‐j CLASSIFY ‐‐set‐class 202:1
iptables ‐t mangle ‐I PREROUTING ‐i ppp0 ‐d 192.168.1.3 ‐j CLASSIFY ‐‐set‐class 203:1
iptables ‐t mangle ‐I PREROUTING ‐i ppp0 ‐d 192.168.1.4 ‐j CLASSIFY ‐‐set‐class 204:1
iptables ‐t mangle ‐I PREROUTING ‐i ppp0 ‐d 192.168.1.5 ‐j CLASSIFY ‐‐set‐class 205:1

Instruct these packets to go through the imq0 device.

iptables -t mangle -I PREROUTING -i ppp0 -j IMQ
Romster - 14th September 2008

I decided to try running starcraft in a new Xorg server and here is how I did it.

First switch to a new empty console

CTRL+ALT+F2

Now log in and then type.

$ xinit /usr/bin/xterm -- :1 -extension Composite -depth 16

Now to lower the screen resolution to 640x480

$ xrandr -s 640x480

Change directory to the game and start it.

$ cd ~/.wine/drive_c/Program\ Files/Starcraft/
$ wine StarCraft.exe

Now you can jump between your game and your normal desktop with.

CTRL+ALT+F7

and

CTRL+ALT+F8

When you're done you can exit the game then type

$ exit

to get back to tty2, then if you wish to logout

$ exit

And switch back to your existing desktop

CTRL+ALT+F7