Saturday, November 12, 2011

freebsd partition

Moving FreeBSD to a New Hard Drive
Wednesday, 04 June 2008
This tutorial explain how to move a FreeBSD operating system and data to a new hard drive. This is useful if your hard drive is old/slow or too small. Also this can be used if you experience problems with your hard drive and you want to make sure the hard drive will not crash.

Warning! before doing this saves your data! We are not responsable if you use wrong commands and lose your data!

In this tutorial ad0 is old hard drive and ad1 is the new hard drive. Depending on your configurations your drives might have other names, for example da for SCSI, or ad4 and ad5 for SATA drives (depending on how bios is configured, for SATA you might have ad0 too), so replace ad0 and ad1 with your drives. Make sure you know exactly what are your drives name otherwise you might run command on the wrong hard drives and loose data.

Use "dmesg" command to find your hard drives names, that will also tell you the drive size and manufacturer.


Step 1. Add your second hard drive
-------------------------------------------------
Add your new hard drive to the system as a second hard drive.
If you use an IDE drive make sure your new added drive is on secondary IDE, still setup as master.


Step 2. Boot to single mode
--------------------------------------
Boot to single mode, by pressing SPACE at boot time, when loader starts and then type:

boot -s

This will boot the system in single mode. You could also choose "single mode" from menu that appears when FreeBSD starts.


Step 3. Check all partitions for errors
---------------------------------------------------

fsck -p


Step 4. Mount all partitions and activate swap
--------------------------------------------------------------
First, we will mount root partition with read/write support:

mount -u /

Then mount all partitions:

mount -a

Activate swap:

swapon -a

If the computer is set to local time we will also need to run:

adjkerntz -i


Step 5. Create directories where we will mount the new hard drive
--------------------------------------------------------------------------------------------
Next we must create directories where we will then mount partitions from the new hard drive that, of course must be created too.

mkdir /mnt/backup/ /mnt/backup/root /mnt/backup/usr /mnt/backup/var


Step 6. Create slice and partitions for the new hard drive
------------------------------------------------------------------------------
To create slice and then partitions for the new drive you have two options: to do that from sysinstall or from command line. Either will work. To create partitions from sysinstall tool is trivial so we will show how to create partitions from command line.

Clear boot and disklabel (sector0):

dd if=/dev/zero of=/dev/ad1 bs=1k count=1

Initialize sector 0 of the disk. Existing slice entries will be cleared. Then reinitialize the boot code contained in sector 0 of the disk.

fdisk -BI ad1

Label the disk. Bootstrap code will be read from the file /boot/boot and written to the disk. Also a standard label will be written (-w option).

disklabel -B -w ad1s1 auto

Edit disklabel and add new partitions:

disklabel -e ad1s1

Last command will enter an text editor where you can add partitions. For a default/generic/usual FreeBSD system we will have
ad1s1a - / (root partition)
ad1s1b - swap
ad1s1d - /tmp
ad1s1e - /var
ad1s1f - /usr

Letter at the end of ad1s1 are partition identifiers and can have values from a to h. By convention, 'c' is reserved for describing entire disk.

The partition table list partitions on multiple rows, with every partition on a single row. We can have up to 8 entries (values) for a
partition - partition identifier, size, offset, fstype, fsize, bsize, bps/cpg.
Example:
# /dev/ad1s1:
8 partitions:
# size offset fstype [fsize bsize bps/cpg]
a: 2097152 0 4.2BSD 2048 16384 28552
b: 1024000 2097152 swap
c: 156296322 0 unused 0 0 # "raw" part, don't edit
d: 10485760 3121152 4.2BSD 2048 16384 28552
e: 2097152 13606912 4.2BSD 2048 16384 28552
f: 140592258 15704064 4.2BSD 2048 16384 28552

size - is the size of partition and can be in sectors (of 512 bytes in size), K bytes, M bytes or G bytes.

offset - is the offset of the start of partition from begining of drive in sectors. Also you can add instead * to let disklabel calculate the offset for you.

fstype - partition type: for UFS is 4.2BSD, for vinum drives is vinum. Other types could be swap or unused.

fsize - the fragment size

bsize - block size

bps/cpg - number of cylinders in a cylinder group.

For more info: man disklabel and man newfs.

After you've created all partitions you need save and exit with :wq (vi commands).


Step 7. Create filesystem for all newly created partitions
------------------------------------------------------------------------------
We will create file systems for partition we've setup with disklabel:

newfs /dev/ad1s1a
newfs /dev/ad1s1e
newfs /dev/ad1s1f


Step 8. Mount newly created partitions
------------------------------------------------------
We will create directories in /mnt on current system, where we will mount the newly created partitions from second hard drive:

mkdir /backup/root
mkdir /backup/var
mkdir /backup/usr

Now we will mount the newly created partitions from second hard drive:

mount /dev/ad1s1a /backup/root
mount /dev/ad1s1e /backup/var
mount /dev/ad1s1f /backup/usr


Step 9. Dump data from old drive
----------------------------------------------
We will move everything from root, var and usr partitions to newly created partitions on new hard drive:

(dump -0f - /) | ( cd /backup/root; restore -rf - )
(dump -0f - /var) | ( cd /backup/var; restore -rf - )
(dump -0f - /usr) | ( cd /backup/usr; restore -rf - )


Step 10. Umount the new drive partitions
---------------------------------------------------------
umount /backup/root
umount /backup/var
umount /backup/usr


Step 11. Enable soft updates for partitions on new drive
-----------------------------------------------------------------------------

tunefs -n enable /dev/ad1s1a
tunefs -n enable /dev/ad1s1e
tunefs -n enable /dev/ad1s1f

Now you should have a new hard drive with all your old info. Replace the old hard drive and make sure it is connected on the same device. If it has different drive name, for example instead of ad0 it is on SATA and is named ad4, edit /etc/fstab and change partition names from ad0 to ad4, for example for root will be /dev/ad4s1a.



Last Updated ( Friday, 06 June 2008 )


< Prev Next >

Saturday, June 11, 2011

backup office 2007 mail setting

Creating a Microsoft Outlook backup of your emails and settings is something important as a lot can happen in the future and we have to be in a position that we can restore our emails and settings back from a data loss. In Microsoft Outlook 2007 all the data is stored in .pst file(s) and all the account settings in the registry.

In case an Exchange Server exists all your data are stored in the server and not localy in your machine. In your machine only the synchronized file is saved with .ost extension which is for offline use.

To backup our data files:


32Bit: Start -> Control Panel -> Mail -> Data Files
64bit: Start -> Control Panel -> View 32-Bit Control Panel Items -> Mail -> Data Files
Navigate to the path shown: C:\Users\USERNAME\AppData\Local\Microsoft\Outlook\ and copy the .pst file to a backup location.




To backup our account settings:


Start -> Run -> regedit
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook
Right click Outlook, click on export and save it with your .pst backup file(s)



To restore Data and Account Settings

Restoring Data and Account Settings is even easier than backup. Just copy the .pst file back to the location that you copy it from and run the registry exported file to import back your account settings.
http://www.itsolutionskb.com/category/microsoft-solutions/microsoft-outlook/

Tuesday, March 29, 2011

add remove button on windows

http://www.jsiinc.com/SUBM/tip6000/rh6032.htm

If the Add/Remove Programs applet does NOT open, or flashes briefly, you may have some missing registry entries.

To fix the problem:

1. Open a CMD.EXE prompt.

2. Type regsvr32 mshtml.dll and press Enter and OK.

3. Type regsvr32 shdocvw.dll -i and press Enter and OK.

4. Type regsvr32 shell32.dll -i and press Enter and OK.

Saturday, March 26, 2011

Crontab – Quick Reference

http://adminschoice.com/
Crontab – Quick Reference
Setting up cron jobs in Unix and Solaris

cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix , solaris. Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.

This document covers following aspects of Unix cron jobs
1. Crontab Restrictions
2. Crontab Commands
3. Crontab file – syntax
4. Crontab Example
5. Crontab Environment
6. Disable Email
7. Generate log file for crontab activity

1. Crontab Restrictions
You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow. If that file does not exist, you can use
crontab if your name does not appear in the file /usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user can use crontab. The allow/deny files consist of one user name per line.

2. Crontab Commands

export EDITOR=vi ;to specify a editor to open crontab file.

crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.)

3. Crontab file
Crontab syntax :
A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.

* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)


* in the value field above means all legal values as in braces for that column.
The value column can have a * or a list of elements separated by commas. An element is either a number in the ranges shown above or two numbers in the range separated by a hyphen (meaning an inclusive range).
Notes
A. ) Repeat pattern like /2 for every 2 minutes or /10 for every 10 minutes is not supported by all operating systems. If you try to use it and crontab complains it is probably not supported.

B.) The specification of days can be made in two fields: month day and weekday. If both are specified in an entry, they are cumulative meaning both of the entries will get executed .

4. Crontab Example
A line in crontab file like below removes the tmp files from /home/someuser/tmp each day at 6:30 PM.

30 18 * * * rm /home/someuser/tmp/*

Changing the parameter values as below will cause this command to run at different time schedule below :

min hour day/month month day/week Execution time
30 0 1 1,6,12 * – 00:30 Hrs on 1st of Jan, June & Dec.

0 20 * 10 1-5 –8.00 PM every weekday (Mon-Fri) only in Oct.

0 0 1,10,15 * * – midnight on 1st ,10th & 15th of month

5,10 0 10 * 1 – At 12.05,12.10 every Monday & on 10th of every month
:

Note : If you inadvertently enter the crontab command with no argument(s), do not attempt to get out with Control-d. This removes all entries in your crontab file. Instead, exit with Control-c.

5. Crontab Environment
cron invokes the command from the user’s HOME directory with the shell, (/usr/bin/sh).
cron supplies a default environment for every shell, defining:
HOME=user’s-home-directory
LOGNAME=user’s-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh

Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry.

6. Disable Email
By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line .

>/dev/null 2>&1

7. Generate log file
To collect the cron execution execution log in a file :

30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log

How to backup MySQL Database in command line with compression

For those who looking for way to backup mysql database,
you can use mysqldump to backup mysql database.

Below is the script example to backup mysql database in command line:-

$ mysqldump -h localhost -u username -p database_name > backup_db.sql
If your mysql database is very big, you might want to compress your sql file.
Just use the mysql backup command below and pipe the output to gzip,
then you will get the output as gzip file.


$ mysqldump -u username -h localhost -p database_name | gzip -9 > backup_db.sql.gz
If you want to extract the .gz file, use the command below:-

$ gunzip backup_db.sql.gz

Saturday, October 23, 2010

useful dos command

ipconfig - Windows IP configuration
Useful for troubleshooting your internet connection. Displays the current IP address of your computer and the DNS server address. If you call your ISP for reporting a bad internet connection, he will probably ask you to run ipconfig.

fc - Free BeyondCompare in XP
FC is an advanced DOS Command that compares two files and displays the differences between them. Though the file comparison results are not as interactive as BeyondCompare or Altova DiffDog, fc is still very useful. You can even set fc to resynchronize the files after finding a mismatch.

type - open text files sans Notepad
Similar to Unix cat command, Type is my favorite DOS command for displaying the contents of a text files without modifying them. When used in combination with more switch, type splits the contents of lengthy text files into multiple pages. Avoid using the type command with binary files or you'll hear alien PC beeps and see some greek characters on your PC.

ping - Say hello to another computer
Ping network command followed by the web-address or IP address tells you about the health of the connection and whether the other party is responding to your handshake request. Ping tool can also be used to convert the web address to a physical IP address.

tree - visual directory structure
You often need to take prints of your physical directory structure but XP has no simple "visual" commands for printing directory contents. Here, try the Tree DOS command and redirect the output to a text file.

tree > mydirectory.txt
print mydirectory.txt

attrib - make hidden files visible
Attrib lets you change attributes of System files and even hidden files. This is great for troubleshooting Windows XP. Say your XP doesn't boot ever since you edited that startup boot.ini file (Hidden), use attrib to remove the Hidden attibute and edit the file using EDIT dos command.

assoc - which program will open that .xyz file
The assoc DOS command can be used to either isplay or even modify the file name extension associations. The command assoc .htm will quickly tell you the name of your default web browser (see picture)

move - more flexible than copy-paste
Say you got a lot of XLS and DOC files in you MyDocuments folder and want to move only those XLS files that have their name ending with 2006. In XP Explorer, you have to manually select each file and then cut-paste to another folder. However, the DOS move command make things much simpler. Just type the following at the command prompt:
move *2006.xls c:\2006Reports\

find - advanced file search with filter
Find is the most powerful DOS command and even more useful than the Windows Desktop Search tool or the Windows Find Wizard. The find command searches for a specific string of text in a file or files. After searching the specified file or files, find displays any lines of text that contain the specified string.

To search your hard disk to find and display the file names on drive C: that contain the string "Google" use the pipe (|) to direct the results of a dir command to find as follows:
dir c:\ /s /b | find "Google"

Quick tip - Drag to avoid typing: When your command acts on a file or folder, you must type the path to that folder after the command. You can save typing time by dragging the file or folder from Windows Explorer into the command window.

Sunday, January 17, 2010

office 2007

Save as .doc instead of .docx in Word 2007
By Walter, January 13, 2007 11:03 pm
While the new .docx format in Word 2007 promises great things, for now most of the people you’ll be working with are still using Word 2003 or (gasp) an even earlier version. The .doc format remained virtually unchanged in Word 97-2003 and is still supported in Word 2007. But Word 2007 by default saves files as .docx documents, meaning that when you need to share with someone using a previous version you have to open the .docx file you created and save it as a .doc file.

If you work with folks that use previous versions of Word, you can change the default format Word 2007 uses to save a file. To do this, use the following steps:

In Word 2007, click the Office button (the big round button at the top left of the Window) and then click Word Options.
In the Word Options dialog box, choose the Save category from the list on the left.
Use the Save files in this format drop-down menu to choose the format you want Word 2007 to use by default. I use Word 97-2003 Document (*.doc).
Click OK.


When you save a new file, if you really want to save it as a .docx file, you can always choose that format from the list in the Save As dialog box.

Microsoft also has an Office Compatibility Pack available for users of Office XP and Office 2003 for opening documents created in Office 2007 (Word, Excel, and PowerPoint)