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, November 12, 2011
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/
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.
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
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
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
Subscribe to:
Comments (Atom)