Thursday, October 19, 2017

Using rsync / cwrsync for copying data locally

I am using rsync alot to sync data between remote and local folders. Under Windows 7 64bit I am using cwrsync. Occasionally, I need to sync large (updated) data files from my local computer to another local device (usually a usb drive). The option to use to avoid copying the whole file is --no-whole-file. So with my specific cwrsync installation this looks like this:
c:\cwRsync\rsync.exe -rtv --progress --no-whole-file src/ dest/

Plain and simple ... who could have thought?! I never tested this on a Linux machine but I assume it works the same way there.

cheers

Sunday, June 15, 2014

Reset IDE configuration of Visual Studio 2010

I just encountered a strange behaviour in my Visual Studio 2010 installation. Out of the blue I was no longer able to open more than one file in one tab at the same time. This is obviously very annoying if you work on a project wich includes several source-files (which is the general case I guess). After some googling I found a solution that helped me without reinstalling everything:

just type at a VS 2010 command prompt (open it from the start menu)

devenv /ResetSettings

This will open the VS 2010 IDE and resets all settings that you may have made. After that everything worked like a charm again.

I stumbeld upon the answer here and here.

cheers

Saturday, May 21, 2011

Image backup of Windows XP with diskdump - dd

Today I set up a Thinkpad T60 with a clean install of Windows XP SP3. Because there ar no real nice built-in features for backing up the whole disk as an image file in XP, I used the famous dd for that. I took an gparted live cd, but any live linux should do the trick.
First mount the media where the image should be copied to
me@linux:~>mount /dev/sdb1 /mnt
and create a folder where you want to store the image file
me@linux:~>mkdir /mnt/Backup
and now copy the whole disk with dd
me@linux:~>dd if=/dev/sda1 bs=1M | gzip -c > /mnt/Backup/sda1.gz
To save a lot of disk space I piped the dd output through gzip. This stored the image of an 60GB hard disk with 14GB of used space into a 10GB image file. Without zipping one would store the whole 60GB. To restore the backup to the disk you could use
me@linux:~>cat /mnt/Backup/sda1.gz | gzip -d | dd of=/dev/sda bs=1M
Finally just out of precaution I also saved the MBR of the hard disk to a file
me@linux:~>dd if=/dev/sda of=/mnt/Backup/mbr.img bs=512 count=1
In case of emergency I would copy it back with
me@linux:~>dd if=/mnt/Backup/mbr.img of=/dev/sda bs=512 count=1

As always, be very careful if you don't know what you're doing and RTFM. Messing with dd and hard disks can easily kill your weekend.

cheers

Thursday, May 19, 2011

Open / Close firewall on Windows 7 via Batch script

Because I am a paranoid SOB I normally lock down my Windows 7 firewall for any kind of incoming and outgoing traffic. Only for programs that really need to connect to the big bad web I define custom firewall rules.
But sometimes I need to allow outgoing traffic for getting program updates or using a service that requires an internet connection. To click throuth the GUI in Windows to finally get to the firewall settings is kind of annoying. So I wrote two little batch scripts (each is a one-liner ;-) ) and put links to them into my start menue. And voilá...I can easily allow / block outgoing connections.
For opening the firewall for outgoing traffic you can simply put
netsh advfirewall set allprofiles firewallpolicy blockinbound,allowoutbound
into a file wich you can name FWallowOUT.cmd for instance. Save this somewhere on you machine and create a link to the file in your start menue. Don't forget to give administrative privileges to it. The same thing you can do for blocking the outgoing traffic again
netsh advfirewall set allprofiles firewallpolicy blockinbound,blockoutbound
Easy and simple. For detailed information about netsh and advfirewall read the man-pages or check Microsofts Technet.

cheers

TAR and GZIP or the command I always forget

As simple as it may seem I always forget the command line options for tar to unpack a tgz-file. And to avoid 'googling' I will put them here once and for all...

For creating one can use:
tar cfvz [file].tgz [path] [file]
and for extracting:
tar xfvz [file].tgz
cheers

Saturday, February 5, 2011

Cloning a VirtualBox vdi-file

OK,
this will be a short one. I did this with VirtualBox 4.0 on a Windows 7 64bit machine.
I had and still have a vdi-file which is simply a virtual disk that contains a virtual operating system. For me this is a virtual Windows XP SP3. I have to point out that my virtual machine did not contain any snapshots. So I don't know what happens if you try this with a virtual machine that contains one or more snapshots.
To try different software in a kind of safe environment I use virtual machines a lot. But one can not simply copy a virtual disk to another folder and use it as another virtual system because VirtualBox internaly registers the vdi-files with its UUID which is unique for every vdi-file. So you can not use two virtual systems with the same UUID with VirtualBox. The solution is to change the UUID of the copied vdi-file the following way.
First I copied the original "winxp.vdi" to "winxp-clone.vdi". Then I opened a command prompt and changed to the location "D:\Virtualdisks" where my virtual disks are stored. There I issued the command:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands sethduuid "d:\Virtualdisks\winxp-clone.vdi"
I gave the full path to be sure that everything behaves as expected. And after generating a new virtual system in VirtualBox with the same settings as the original one, I could assign the cloned vdi-file to it.

cheers

Wednesday, September 1, 2010

Mounting an external harddisk with NTFS file system as normal user under Linux using ntfs-3g

On my computer at work running an openSUSE 11.2 64bit installation, I'm using an external harddrive to copy data between my Linux and Windows machines. For several reasons it's formatted with NTFS so that I have to use ntfs-3g under linux for having read and write access. And because it's annoying to always become root for mounting the drive I did the steps described below. It's maybe not the most perfect way but it's working and this is what matters to me.

Let's say I have an external harddisk on /dev/sdb1 and the label of this disk is "EXTERNAL". Then I will find it with ls like this:
me@linux:~> ls -hal /dev/disk/by-label/
insgesamt 0
drwxr-xr-x 2 root root  80  1. Sep 14:38 .
drwxr-xr-x 6 root root 120  1. Sep 16:21 ..
lrwxrwxrwx 1 root root  10  1. Sep 14:38 EXTERNAL -> ../../sdb1
me@linux:~>
Because this label is unique on my machine I can use the label for mounting the harddisk with the fstab file. If I want to mount it to /home/me/usb (assuming my username is me) I put following code as root into /etc/fstab
/dev/disk/by-label/EXTERNAL       /home/me/usb  ntfs-3g noauto,uid=1000,gid=users,umask=022,locale=de_DE.UTF-8   0       0  
which means
  • /dev/disk/by-label/EXTERNAL is the device to be mounted
  • /home/me/usb is the mount point where it should be accessible
  • ntfs-3g is the file system driver to be used
  • the mount options are: noauto (no automatic mount on boot time), uid=1000 (my user id), gid=users (the group which should be used, one can also write his gid like gid=100 which is normally the users gid), umask=022 (gives permissions like 755 or u=rwx,g=rx,o=rx) and the local charset to be used (I'm german so I use the german one obviously)
  • 0 (default settings - don't ask me)
  • 0 (default settings - don't ask me).
Each of this six items has to be tab separated. Then I add myself as root to the group disk in the /etc/group file so that the entry looks like:
disk:x:6:me
I do so because the /dev/sdb1 belongs to the group disk. Otherwise I couldn't get it to work. Maybe someone knows a better trick. Just let me know.

Finallly I set the suid flag on ntfs-3g and ntfs-3g.probe with
me@linux:~> sudo chmod 4755 $(which ntfs-3g)
me@linux:~> sudo chmod 4755 $(which ntfs-3g.probe)
so that I can mount the external harddisk also as normal user and don't have to become root everytime.

I recommend reading the man pages of mount and ntfs-3g before you start messing around. You should definitly know what you're doing especially if you're editing the /etc/fstab file. So be careful.

cheers