How to go about restoring a vm image:
Open a putty session to aaphst02:
Then login and do sudo su – to get root access:
Now mount one of the usbdrives:
mount /dev/sdb1 /mnt/usbdrive1
or
mount /dev/sdc1 /mnt/usbdrive2
then navigate to that directory:
[root@aaphst02 /]# cd /mnt/usbdrive2
*note: dmesg command after plugging in will show the sdxx of the drive; if it ever asks, the files system type is ext3.
List the contents:
[root@aaphst02 usbdrive2]# ls -lah
total 92K
drwxr-xr-x 11 root root 4.0K Oct 30 04:12 .
drwxr-xr-x 7 root root 4.0K Nov 3 04:26 ..
drwxr-xr-x 3 root root 4.0K Oct 30 04:03 aaphst01
drwxr-xr-x 3 root root 4.0K Oct 30 04:12 aaphst02
drwxr-xr-x 3 root root 4.0K Sep 18 04:50 apvwap01
drwxr-xr-x 3 root root 4.0K Sep 30 15:58 databases
drwx------ 2 root root 16K Aug 14 17:38 lost+found
drwxr-xr-x 2 root root 4.0K Sep 21 20:50 lytec_backups
drwxr-xr-x 3 root root 4.0K Sep 3 16:49 sc1420
drwxr-xr-x 3 root root 4.0K Aug 31 14:11 server1
drwxr-xr-x 2 root root 4.0K Oct 16 13:25 vmware_backups
[root@aaphst02 usbdrive2]#
Now, copy the image you want out of the aaphst02 directory into an appropriate folder in /images
if you need to make a directory to put it in, use this (be in the directory where you want the new one):
[root@aaphst02 images]# mkdir vmserver1bak
This is the copy command:
[root@aaphst02 backups]# cp vmserver1.sat.tar.gz /images/vmserver1bak
*above backups is /mnt/usbdrivex/aaphst0x/backups
see http://www.cyberciti.biz/faq/copy-command/ for more info on cp
extract the tarball:
Please use tar/gz or zip (you can use Winzip) to
create a single file to submit for your homework.
·
Creating a file
"example.tar.gz":
·
"cd < your directory >"
·
"tar cvf example.tar *"
·
"gzip example.tar"
·
Submit the file
"example.tar.gz"
·
If you do not want
to include all the files in your homework directory (which is what "tar cvf example.tar *" means),
instead list the specific files you want to include (e.g., "tar cvf example.tar prog1.c prog1.h
README output.ppm").
·
Extracting files
from the file "example.tar.gz":
·
"gunzip example.tar.gz"
·
"tar xvf example.tar"
[root@aaphst02 vmserver1bak]# tar -xvf vmserver1.sat.tar.gz
Now, add the VM to inventory:
Don't start the new instance without stopping the old.
[root@aaphst02 ~]# vmrun -h https://10.0.1.21:8333/sdk -u mwhalen -p secret start "[standard] apvwap01/apvwap01.vmx"
The “start” above can be stop, list (don't name the vm if you want the list), suspend or a few others. Lookup vmrun on google.
When you're done, unmount the drives:
umount /mnt/usbdrive1
extra:
find . -name '*mon.tar*' -print0 | xargs -0 rm
recursively deletes everything with mon.tar in its name
df -h shows current disk usage
fdisk -l shows partition info +
ifconfig is ipconfig
Command I used to copy the contents of sc1420/backups to aaphst02:
[root@aaphst02 backups]# rsync -avz /mnt/usbdrive1/sc1420/edrive/backups /mnt/vmserver1/backups
building file list ... done
backups/
backups/ahvs.bak
backups/ahvs_llc.bak
backups/angarola.bak
backups/aperian.bak
backups/aperian_laboratory_solutions_llc.bak
backups/diagnostic_lab_practice.bak
backups/dlp.bak
backups/drugscan_inc.bak
backups/forensic_laboratories.bak
backups/forensic_laboratories_summit.bak
backups/forensic_laboratories_summit_before_rebuild.bak
backups/forensic_laboratories_universal.bak
backups/forensic_laboratories_universal_after_import.bak
backups/forensic_laboratories_universal_after_import_details.bak
backups/forensic_laboratories_universal_after_import_headers.bak
backups/forensic_summit.bak
backups/forensic_summit_before_rebuild.bak
backups/forensic_summit_log.bak
backups/forensic_summit_manual.bak
backups/forensic_universal.bak
backups/genelex.bak
backups/genelex_corp.bak
backups/hardman.bak
backups/hardman_path_and_dermpath.bak
backups/liberty.bak
backups/liberty_testing_laboratories_inc.bak
backups/lytec_tutorial.bak
backups/michaels_test_practice.bak
backups/michaels_test_practice_after_import.bak
backups/mosaic.bak
backups/mosaic_gi_pathology_svrs_pllc.bak
backups/odl.bak
backups/onco_diagnostic_laboratory.bak
backups/soft_landing_labs_ltd.bak
backups/udtl.bak
backups/united_drug_testing_laboratories.bak
sent 6854970846 bytes received 818 bytes 1868094.20 bytes/sec
total size is 37273356288 speedup is 5.44
[root@aaphst02 backups]#
RESTART WEB INTERFACE: /etc/init.d/vmware-mgmt restart
adding a new drive:
Whit out any theory:
1. Check what is the new hard disk device name with "fdisk
-l", it shoul be something like /dev/sdb
2. Create a partition on it, supose the disk is /dev/sdb: "echo -ne "n\np\n1\n\n\nw\n" | fdisk /dev/sdb1"
3. Make a filesystem on the partition: mkfs.ext3
/dev/sdb1
4. Create a directory where to mount the partition: mkdir
/newdirectory
5. Edit fstab an add at the end of the file:
/dev/sdb1 /newdirectory ext3
defaults 0 0
6. now mount: mount -a
that is.
Mounting CIFS windows locations:
mount -t cifs //10.0.1.5/commonfiles -o user=backupdude,password=secret /mnt/server1/edrive
/sbin/shutdown -h now (-h halt !wait for the halt mssg or risk data crrp!)
/sbin/shutdown -r now
(-r = restart)
find
/ -name foo
This will search the whole
system for any files named foo and
display their pathnames. Here we are using the criterion -name with the argument foo to tell find to perform a
name search for the filename foo.
The output might look like this:
/home/wpollock/foo
/home/ua02/foo
/tmp/foo
If find doesn't locate any matching files, it produces no output.
*(****
USE “” around search strings that contain wildcards
Vi
search: / string (forward) ? String (back)
drive info:
fdisk -l
usbinsert:
dmesg | tail
Run rsync manually:
rsync -ra /mnt/usbdrive1/ /mnt/usbdrive2/
LVM:
vgscan shows vol groups
lvcreate creates logical volumes
see (http://www.centos.org/docs/5/html/5.2/Cluster_Logical_Volume_Manager/LV_rename.html)
also (http://tldp.org/HOWTO/LVM-HOWTO/)
also (http://www.walkernews.net/2007/07/11/create-new-linux-ext3-file-system-in-lvm/)
Formatting
a new DISK:
How
to Format a Hard Drive in Linux
mattlax Member
By
MattLax, eHow Member
Article
Rating: (311 Ratings)
* Facebook
*
Twitter
* StumbleUpon
*
Email
*
Print
*
Share
* Facebook
*
Twitter
* Add to Favorites
*
Email
*
Print
*
Share
*
Email
* Facebook
*
Twitter
* Add to Favorites
* Print
*
Share
This
article explains how to format a hard drive in Linux using the standard
commands fdisk, mkfs and fsck. The procedure described can be used either to format
a secondary hard drive or to format a drive prior to system installation.
Difficulty:
Moderately Easy
Instructions
Preparation
1.
Step 1
When you format a computer hard drive,
you will lose everything that is on the drive. Therefore, it is very important
to back up anything you might later want.
2.
Step 2
To format a secondary drive, you will
need root access. All commands used in this tutorial are run from a command
line (terminal) as root. You may also want to make note of the size (total
capacity in MB) of the drive.
3.
Step 3
Linux refers to hard drives as either "hdx" or "sdx,"
where x is a letter, starting with a, which represents the order in which the
drive was added to or detected by the computer. The "hd"
prefix is used for IDE and PATA (formerly just ATA), and the "sd" prefix is used for SCSI, SATA and USB drives.
Usually, a number is also put at the end of "hdx"
or "sdx" to denote different partitions on
the same physical drive, but for the purpose of formatting, you only need to
know which letter the drive you want to format is.
4.
Step 4
The examples given in this how-to are for
a computer with two IDE hard drives attached as a master and slave. In this,
the drives are "hda" and "hdb." You will need to determine the letter of the
drive you want to format for your own setup. We will be formatting the drive hdb. For all examples, replace "hdb"
with whatever your drive designation is.
5.
Step 5
You can see all the drives attached to
your system by typing the command "ls /dev/hd*" or "ls /dev/sd*", depending on which type (IDE, SATA and so forth)
the drives are. On the example system, the result of this command looks like
"/dev/hda /dev/hda1 /dev/hda2 /dev/hdb /dev/hdb1". The operating system is installed on hda, which has two partitions (hda1 and hda2), and there is
one partition on hdb and hdb1.
Using fdisk
6.
Step 1
First, you will use the fdisk command to erase any old partitions on the drive and
create a new one. Any changes you make using fdisk
are only made permanent if you then issue the "w" command before
quitting, so feel free to play around a little if you like. If at any time you
find yourself stuck, you can quit the program without saving changes by holding
the "Ctrl" key and pressing "c."
7.
Step 2
At the command prompt, type "fdisk /dev/hdb", replacing
the "hdb" with the letters for your drive.
Upon opening, fdisk may give you a couple of
warnings, all of which can be ignored. It then gives you a prompt that looks
like this: Command (m for help):
8.
Step 3
Enter "p" to see the partition
table of the drive. The first line of output from the "p" command
will also tell you the size of the drive. This is a good way to double-check
that you are working with the correct drive.
9.
Step 4
If there are any partitions already on
the drive, they will be listed as the last lines of the "p" command.
On our example, this looks like "/dev/hdb1", followed by some
information about the partition's size and filesystem.
10.
Step 5
To delete any existing partitions, press
"d" and then "Enter." It will ask you which partition
number you wish to delete. The number of the partition is the number that
follows hdb, so on our example system, we enter 1. If
there are multiple partitions, repeat the "d" command for each one.
You can always view the partition table again with the "p" command.
11.
Step 6
Once you have deleted all existing
partitions on the drive, you are ready to make a new one. Type "n"
and hit "Enter." Then press "p" to create a primary
partition. It asks you for a partition number; enter "1." Now you are
asked which cylinder the partition should start at. The beginning of the drive
is the default, so just hit "Enter." Then, you are asked for the last
cylinder. The end of the drive is the default, so you can just press
"Enter" again.
12.
Step 7
Now you are back at fdisk's
command prompt. Use the "p" command to check the partition table. You
should now see your new partition at the bottom of the output. In the example,
it lists as "/dev/hdb1."
13.
Step 8
You now need to set the filesystem type for your new partition with the
"t" command. You are asked for the Hex code of the filesystem you wish to use. We will use the standard Linux
ext2 filesystem, which is "83." If you are
doing something special and know of a particular filesystem
that you need to use, you can press "L" to see all the codes, which
are one or two characters made up of the numbers 0 to 9 and the letters a to f.
14.
Step 9
Now just issue the "w" command
to write your new partition table and exit fdisk.
Creating the New Filesystem
With mkfs
15.
Step 1
Now you need to create the filesystem on the drive. This is done with the "mkfs" command.
16.
Step 2
At the command prompt, enter "mkfs -t ext2 /dev/hdb1", while remembering to change
the hdb1 to whatever the letters are for the partition you just created.
17.
Step 3
If
you are using a different filesystem than ext2, you
will have to specify that where "ext2" is in the above command.
Finalizing the Format With fsck
18.
Step 1
All that is left is to run a check on the
drive and enter it into your fstab so that the drive
mounts each time you start your computer. This can be done with a single fsck command.
19.
Step 2
At the command prompt, type "fsck -f -y /dev/hdb1", again replacing hdb1 with the
letters and number for your partition.
20.
Step 3
After fsck
runs, your new drive is formatted. Restart your system before using it.
21.
Step 4
If you reformatted your system drive, you
will now need to boot off an installation disk to install an operating system.