Posts Tagged by Windows

Backup multiple MySQL databases into separate files – Windows

Years ago I wrote a post on how to Backup multiple MySQL databases into separate files (Linux). I get a lot of questions about how to do the same on Windows; here’s a script submitted by one of my readers:

:: MySQl DB user
set dbuser=xxxx

:: MySQl DB users password
set dbpass=xxxx

:: Switch to the MySQL data directory and collect the folder names
pushd "C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.5\data"

:: Loop through the folders and use the fnames for the sql filenames, collects all databases automatically this way

echo "hello"

echo "Pass each name to mysqldump.exe and output an individual .sql file for each"

FOR /D %%F IN (*) DO (
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe" --user=%dbuser% --password=%dbpass% --databases %%F > "C:\SQLBackup\%%F.%backupdate%.sql"
)

Windows autologon

The only time I use Windows is as a virtual machine “appliance” ie it’s running some application that I have to run, that only runs on Windows. Often I want the VM to just logon automagically; here’s a registry file to do so. Save it as foo.reg and double click on it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon]
"DefaultUserName"="sonia"
"DefaultPassword"="secret"
"AutoAdminLogon"="1"

No rocket science, I’m just blogging it so I don’t have to look it up again…

Windows recovery tools

Here are some useful tools for troubleshooting/recovering windows systems:

Linux tools (and religion…):

  • Knoppix is a CD bootable Linux distribution, that is The Swiss Army Chainsaw of distros – it does everything. Insert Linux and Damn Small Linux are also useful, as they fit on business card CDs
  • PNordahl has a tool for resetting forgotten Administrator passwords
  • DBAN completely solves all Windows problems, by wiping the hard disk :-) You can then install a decent Operating System like Ubuntu Linux
  • see also my article on DD Rescue

sharing application data on a dual boot laptop

I dual boot my laptop between Linux and Windows – mostly Linux, but occasionally Windows. Here’s how to make applications like Firefox, Thunderbird, etc share their configuration – especially useful for bookmarks and saved passwords for Firefox. This how-to presumes that your Linux username is sonia and your user id is 1000 (check by running the id function). It also presumes that you can see system folders in Windows – setup in Windows Explorer under Tools, Options, View, Show hidden files and Folders, Click Apply to All Folders.

Create a Shared Partition

First you need a filesystem that will be shared between both Linux and Windows – it has to be FAT, as this is the only filesystem that both operating systems (easily) read. This may involve shrinking an existing filesystem and partition. (You could of course lose data doing this, so check your backups first).

The key idea here is that each partition (eg /dev/hda6) has a filesystem (eg Reiserfs or Ext3) located inside. To shrink a partition, the filesystem needs to be shrunk first; the easiest way to do this is to shrink the filesystem too small, delete the partition and recreate it smaller, then expand the filesystem to fit the newly shrunk partition:

  • boot off Knoppix
  • shrink the filesystem before the partition. For example if using ReiserFS and hda6:
 resize_reiserfs -s 10G /dev/hda6
  • using fdisk/cfdisk, resize the partition by deleting the existing partition and recreating it with a smaller size. Ensure the new partition is larger than the resized filesystem.
  • expand the previous filesystem so it fills the shrunk partition:
 resize_reiserfs /dev/hda6
  • check and mount the shrunk partition before creating the new partition and filesystem, in case you’ve made a mistake

 reiserfsck /dev/hda6
 mount /dev/hda6
  • in fdisk/cfdisk, also create the new partition (/dev/hda7 in this case), set the type to 0C (Windows FAT LBA)
  • create the new shared filesystem:
 mkfs.vfat /dev/hda7

Mount the Shared Partition in Linux

  • create a mount directory
 cd /
 sudo mkdir /configs
 sudo chown 1000. /configs
  • add an entry to /etc/fstab to mount at boot:
 /dev/hda7       /configs        vfat    defaults,uid=1000,gid=1000        0       0
  • reboot to linux and check the partition mounts OK by trying to create a test file in /configs using your normal user account, not root

Get Firefox to Locate Configuration in Linux

  • close Firefox and move your profile – it’ll be a directory named something like 123456.default:

 mkdir -p /configs/.mozilla/firefox
 mv ~/.mozilla/123456.default /configs/.mozilla/firefox
  • config Firefox to use the new location; change these settings in ~/.mozilla/firefox/profiles.ini:
 IsRelative=0
 Path=/configs/.mozilla/firefox/123456.default
  • check Firefox runs OK – if the Profiles screen pops up, you’ve got some sort of error

Mount the Shared Partition in Windows

  • boot into Windows. The partition should be located automatically, you may want to change the drive letter (to say Z:) using Computer Management

Get Firefox to Locate Configuration in Windows

  • edit the file profiles.ini, located in the directory C:Documents and SettingssoniaApplication DataMozillaFirefox
  • change the following settings
 IsRelative=0
 Path=Z:.mozillafirefox123456.default

Thunderbird

The process is similar for Thunderbird. Under Linux the file is ~/mozilla-thunderbird/profiles.ini, under Windows C:Documents and SettingssoniaApplication DataThunderbirdprofiles.ini.

Notes

Notes taken from Linux Journal article, June 2006