To save the current Linux MBR type
dd if=/dev/hdaX of=/bootsect.lnx bs=512 count=1
where hdaX is the device in which you installed the MBR and /bootsect.lnx is the file in which you whant to dump it.
Then, to use it from Windows Boot Manager, edit c:\boot.ini adding
c:\bootsect.lnx="Linux"
Friday, October 3, 2008
Monday, September 29, 2008
Windows Backup made easy with SystemRescueCD
Quick solution to add an 'open source' automatic recovery option from the windows boot manager.
Steps:
1- Download SystemRescueCD iso from http://www.sysresccd.org/Download
2 - Extract sysrcd.dat, rescuecd, initram.igz and place them on C:
3 - Download Grub4Dos from https://gna.org/projects/grub4dos/ (tested with version
4 - Modify C:\boot.ini adding in the section [operating systems] the statement:
5 - Add the following file to C:\
6 - Resize you C partition and create another one which will contain the backup.
Steps:
1- Download SystemRescueCD iso from http://www.sysresccd.org/Download
2 - Extract sysrcd.dat, rescuecd, initram.igz and place them on C:
3 - Download Grub4Dos from https://gna.org/projects/grub4dos/ (tested with version
grub4dos-0.4.3-2007-08-27.zip)
extract the file grldr to C:\4 - Modify C:\boot.ini adding in the section [operating systems] the statement:
C:\grldr="SystemRescueCd"
#======================menu.lst=======================
default 2
timeout 30
# This is a sample menu.lst file for SystemRescueCd
title Create Backup
root (hd0,0)
kernel /rescuecd ar_nowait autoruns=0 setkmap=it docache
initrd /initram.igz
# This is a sample menu.lst file for SystemRescueCd
title Restore Backup
root (hd0,0)
kernel /rescuecd ar_nowait autoruns=1 setkmap=it docache
initrd /initram.igz
# This is a sample menu.lst file for SystemRescueCd
title SystemRescueCd from the NTFS disk
root (hd0,0)
kernel /rescuecd ar_disable setkmap=it docache
initrd /initram.igz
#================================================
#===========================autorun0=============
#!/bin/sh
#Create Backup Script
ntfs-3g /dev/sda2 /mnt/windows
partimage --compress=2 --overwrite --nodesc --batch save /dev/sda1 /mnt/windows/win_backup.bz2
umount /mnt/windows
reboot
#================================================
#===========================autorun1=============
#!/bin/sh
#Restore Backup Script
ntfs-3g /dev/sda2 /mnt/windows
partimage --batch restore /dev/sda1 /mnt/windows/win_backup.bz2
umount /mnt/windows
reboot
#================================================
6 - Resize you C partition and create another one which will contain the backup.
Thursday, August 21, 2008
Automatic login in Windows XP
Taken from:
http://support.microsoft.com/kb/315231
Quick command:
Start->Execute-> control userpasswords2
http://support.microsoft.com/kb/315231
Quick command:
Start->Execute-> control userpasswords2
Thursday, July 10, 2008
Character encoding in Apache
One of the last problem that i faced is related on how to setup character encoding on apache httpd for content served directly by the web server. What i was willing to do was to serve all the content with UTF-8 character encoding. Let see how to procede.
First we must edit the httpd.conf. Search for AddDefaultCharset and set it to utf-8:
AddDefaultCharset utf-8
Then we must be sure that the content that we are going to serve is stored on the file system in utf-8 as well. If this is not the case we will have wired behavior, with characters not displayed correctly. Unfortunately in linux is not possible to discover which is the encoding of a file, so the quickest way will be to verify directly the output on the browser. Linux in any case provide a quick way to convert from an encoding to another:
iconv -f ISO-8859-1 -t UTF-8 index.html > index.html.utf8
then we can simply:
mv -f index.html.utf8 index.html
Pay attention that iconv do NOT check the source file encoding. This means that if you apply this command to a file that is already stored with utf-8 encoding it will simply produce a wired file as output.
Last but not least, i would suggest you to avoid to put inside the page:
<meta equiv="Content-Type" content="text/html; charset=utf-8">
because in any case the parameters passed by apache through the http header will override it.
PS I've created a small script to modify a bunch of file in a row. It accept a search like parameter :
#!/usr/bin/ksh
USAGE="usage: "
if (( $# < 1 )) then
print $USAGE;
exit;
elif (( $# > 1 )) then
print $USAGE;
exit;
fi
for file in *$1*
do
if [[ $file = *html* ]]
then
iconv -f ISO-8859-1 -t UTF-8 $file > $file.utf8;
mv -f $file.utf8 $file;
echo $file;
fi
done
First we must edit the httpd.conf. Search for AddDefaultCharset and set it to utf-8:
AddDefaultCharset utf-8
Then we must be sure that the content that we are going to serve is stored on the file system in utf-8 as well. If this is not the case we will have wired behavior, with characters not displayed correctly. Unfortunately in linux is not possible to discover which is the encoding of a file, so the quickest way will be to verify directly the output on the browser. Linux in any case provide a quick way to convert from an encoding to another:
iconv -f ISO-8859-1 -t UTF-8 index.html > index.html.utf8
then we can simply:
mv -f index.html.utf8 index.html
Pay attention that iconv do NOT check the source file encoding. This means that if you apply this command to a file that is already stored with utf-8 encoding it will simply produce a wired file as output.
Last but not least, i would suggest you to avoid to put inside the page:
<meta equiv="Content-Type" content="text/html; charset=utf-8">
because in any case the parameters passed by apache through the http header will override it.
PS I've created a small script to modify a bunch of file in a row. It accept a search like parameter :
#!/usr/bin/ksh
USAGE="usage:
if (( $# < 1 )) then
print $USAGE;
exit;
elif (( $# > 1 )) then
print $USAGE;
exit;
fi
for file in *$1*
do
if [[ $file = *html* ]]
then
iconv -f ISO-8859-1 -t UTF-8 $file > $file.utf8;
mv -f $file.utf8 $file;
echo $file;
fi
done
Wednesday, July 9, 2008
Compress / Decompress initrd files
To Decompress:
zcat initrd.gz > initrd
mount -t ext2 -o loop,rw initrd /tmp/
After the modification of the folder structure, to compress again:
gzip -c initrd > initrd.gz
zcat initrd.gz > initrd
mount -t ext2 -o loop,rw initrd /tmp/
After the modification of the folder structure, to compress again:
gzip -c initrd > initrd.gz
Monday, May 12, 2008
Remove tabulation from an Excel file
Just a simple routine to remove "Tab characters" from an excel file:
Sub RemoveTab()
Dim MyCell As Range
For Each MyCell In Selection
Dim a As String
a = MyCell.Text
a = Replace(a, Chr(9), "")
MyCell.Value = a
Next MyCell
End Sub
Sub RemoveTab()
Dim MyCell As Range
For Each MyCell In Selection
Dim a As String
a = MyCell.Text
a = Replace(a, Chr(9), "")
MyCell.Value = a
Next MyCell
End Sub
Saturday, April 5, 2008
Create a manager accout
It is very usefull to create a manager account in your tomcat. In fact it will be used to access all the administration sections that you can see if you point to the root of your tomcat from a browser (e.g. http://localhost:8080/). But it is also usefull if you want to start, stop, redeploy... from the url with the tomcat manager (http://{host}:{port}/manager/{command}?{parameters}) or with ant. We have to open tomcat-users.xml (..apache-tomcat-5.5.26\conf\tomcat-users.xml). We will add the following lines:
<role rolename="manager">
...
<user username="user" password="pass" roles="manager">
So in the end we will have something like this:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager"/>
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="user" password="pass" roles="manager"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>
<role rolename="manager">
...
<user username="user" password="pass" roles="manager">
So in the end we will have something like this:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager"/>
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="user" password="pass" roles="manager"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>
Subscribe to:
Posts (Atom)