Solved

How to clone solaris 10 machine

Posted on 2016-10-21
33
71 Views
Last Modified: 2016-11-04
I am pretty novice to solaris and I need to clone solaris 10 machine to a shared network path, and then take the image to duplicate to another machine.

I tried using dd but got stuck at the start,

dd if=/dev/rdsk/device-name of=/dev/rdsk/device-name bs=block-size

Here, how to identify which is the source device-name.
Because under dev/rdsk I found number of entires as below,

c0t0d0p0   c0t0d0s15  c1t0d0p3   c1t0d0s4   c2t0d0s1   c2t0d0s7   c3t0d0s12
c0t0d0p1   c0t0d0s2   c1t0d0p4   c1t0d0s5   c2t0d0s10  c2t0d0s8   c3t0d0s13
c0t0d0p2   c0t0d0s3   c1t0d0s0   c1t0d0s6   c2t0d0s11  c2t0d0s9   c3t0d0s14
c0t0d0p3   c0t0d0s4   c1t0d0s1   c1t0d0s7   c2t0d0s12  c3t0d0p0   c3t0d0s15
c0t0d0p4   c0t0d0s5   c1t0d0s10  c1t0d0s8   c2t0d0s13  c3t0d0p1   c3t0d0s2
c0t0d0s0   c0t0d0s6   c1t0d0s11  c1t0d0s9   c2t0d0s14  c3t0d0p2   c3t0d0s3
c0t0d0s1   c0t0d0s7   c1t0d0s12  c2t0d0p0   c2t0d0s15  c3t0d0p3   c3t0d0s4
c0t0d0s10  c0t0d0s8   c1t0d0s13  c2t0d0p1   c2t0d0s2   c3t0d0p4   c3t0d0s5
c0t0d0s11  c0t0d0s9   c1t0d0s14  c2t0d0p2   c2t0d0s3   c3t0d0s0   c3t0d0s6
c0t0d0s12  c1t0d0p0   c1t0d0s15  c2t0d0p3   c2t0d0s4   c3t0d0s1   c3t0d0s7
c0t0d0s13  c1t0d0p1   c1t0d0s2   c2t0d0p4   c2t0d0s5   c3t0d0s10  c3t0d0s8
c0t0d0s14  c1t0d0p2   c1t0d0s3   c2t0d0s0   c2t0d0s6   c3t0d0s11  c3t0d0s9

Please help me how to use dd for cloning.
May be I m not sure whether dd suits for my requirement stated above.

Thanks in advance.
0
Comment
Question by:Puneeth MH
  • 17
  • 16
33 Comments
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41853399
Do you really want to use dd for cloning?
There are much better ways to do this (like ufsdump, zfs send, etc.)

But if you insist ;-)

Which is your (root) disk?

Look which disk is used for which file systems
# df -hl
Now look for the devices that the filesystems /, /usr, /var, /opt, /export etc. are using

The osurce device should be someting like /dev/rdsk/c0t0d0s0
0
 

Author Comment

by:Puneeth MH
ID: 41853547
I really have no restrictions to use any particular option. I am open to anything.

df -hl  shows following

Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c0t0d0s0      7.6G   7.5G     0K   100%    /
/devices                 0K     0K     0K     0%    /devices
ctfs                     0K     0K     0K     0%    /system/contract
proc                     0K     0K     0K     0%    /proc
mnttab                   0K     0K     0K     0%    /etc/mnttab
swap                   3.9G   980K   3.9G     1%    /etc/svc/volatile
objfs                    0K     0K     0K     0%    /system/object
sharefs                  0K     0K     0K     0%    /etc/dfs/sharetab
/usr/lib/libc/libc_hwcap1.so.1
                       7.6G   7.5G     0K   100%    /lib/libc.so.1
fd                       0K     0K     0K     0%    /dev/fd
swap                   3.9G    32K   3.9G     1%    /tmp
swap                   3.9G    32K   3.9G     1%    /var/run
/dev/dsk/c0t0d0s7      285G   256M   282G     1%    /export/home

With this can you help me what dd or ufsdump stepwise, if you don't mind.
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41853589
OK, you have one file system with your Solaris OS
c0t0d0s0
and another with everything under /export/home (user's home directories)
c0t0d0s7

Therefore, the source device would read: /dev/rdsk/c0t0d0s0
And if you want to copy home data, too: /dev/rdsk/c0t0d0s7
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41853601
Which FS type do you use for your filesystems?
mount | grep c0t0d0s

Open in new window

Depending on the FS type you can use diffenrent backup (and recover) methods like dumping a filesystem, creating a FLAR and so on ...
0
 

Author Comment

by:Puneeth MH
ID: 41853612
#mount | grep c0t0d0s

/ on /dev/dsk/c0t0d0s0 read/write/setuid/devices/rstchown/intr/largefiles/loggin                                             g/xattr/onerror=panic/dev=840000 on Fri Oct 21 12:21:11 2016

/export/home on /dev/dsk/c0t0d0s7 read/write/setuid/devices/rstchown/intr/largef                                             iles/logging/xattr/onerror=panic/dev=840007 on Fri Oct 21 12:21:17 2016

#fstyp /dev/rdsk/c0t0d0s0
ufs
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41853657
Have you ever used ufsdump?

I'd suggest to use ufsdump to backup you disk. You can even do it when running OS by using snapshop:
You can safely run ufsdump with snapshot on a live system and transfer the resulting dump (a file) onto another system

Create ufsdump from root filesystem with snapshot:
 # ufsdump 0f /var/tmp/root.dump `fssnap -F ufs -o raw,unlink,fs=/var/tmp/BS  /`

Open in new window

You will have to make sure that /var/tmp is NOT in the filesystem you want to back up (e.g. your root filesystem). Otherwise, use another directory, like /export/home/BS. BS stands for "backing store".

Transfer (copy) the dump file onto the other system and mount the new root filesystem under /mnt
Now, extract the (whole) dump into it:
 # cd /mnt ; ufsrestore xf /tmp/root.dump

Open in new window

and install the boot block (change c0t0d0s0 to your root device):
 # installboot /usr/platform/`uname -m`/lib/fs/ufs/bootblk /dev/rdsk/c0t0d0s0

Open in new window


If you are short with disk space, create a comressed dump instead:
 # ufsdump 0f - `fssnap -F ufs -o raw,unlink,fs=/var/tmp/BS  /` | gzip -9 > /var/tmp/root.dump.gz

Open in new window

and extract (on the other system) with
 # cd /mnt ; gzcat /tmp/root.dump.gz | ufsrestore xf -

Open in new window

0
 

Author Comment

by:Puneeth MH
ID: 41856609
Thanks for your detailed answer Hanno.

I have not used usfdump anytime before.

Is backup/clone used interchangeably, because I wanted to clone the machine.

My Source file system has /var/tmp so I will have to use /export/home/BS. In this case is the following command correct?

# ufsdump 0f /var/tmp/root.dump `fssnap -F ufs -o raw,unlink,fs=/export/home/BS  /`

But nothing is happening with this command.

Or should I need to use ufsdump 0f /var/tmp/root.dump `fssnap -F ufs -o raw,unlink,fs=/export/home/BS  /dev/rdsk/c0t0d0s0???

Next you have asked me to transfer to the destination system so here my queries are,
1) What should be the configuration of the destination system, like does it have Solaris 10 running on it?
2) Where to copy file I mean which location in the destination machine?

If my directory is /export/home/BS how the rest of the command would change.

Please do the needful.
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41856795
1. Make sure you use backticks and not single quotes. Maybe, you want to copy-and-paste the command.
2. My typo: it should read bs (for backing store) not fs.
ufsdump 0f /var/tmp/root.dump `fssnap -F ufs -o raw,unlink,bs=/export/home/BS  /`

Open in new window

Do not use
ufsdump ... /dev/rdsk/c0t0d0s0`

Open in new window

as you will be using the snapshot and not the disk device to read from.
The command
fssnap -F ufs -o raw,unlink,bs=/export/home/BS  /

Open in new window

creates a snapshot /device) from which will be read.

To understand better, yo may do it this way:
a) Create the snapshot:
       fssnap -F ufs -o raw,unlink,bs=/export/home/BS  /
b) Dump (backup) from the device that just got displayed (substitute 'x' with the correct number):
       ufsdump 0f /var/tmp/root.dump /dev/fssnap/x
c) Dsiplay existing snapshot debvices:
      fssnap -i
d) Delete the snapshot device:
     fssnap -d /
    or
     fssnap /dev/fssnap/x


Man pages for fssnap and fssnap_ufs.
1
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41856799
Note:
ufsdump 0f /var/tmp/root.dump ... 

Open in new window

will write the dump into file /var/tmp/root.dump.
Make sure it's not on your filesystem to be backed up, like
ufsdump 0f /export/home/root.dump ... 

Open in new window

1
 

Author Comment

by:Puneeth MH
ID: 41856819
fssnap throwing errors as device busy.

I ran this command in export/home folder, that time it showed me something like this

dev/fssnap/0

next time I ran this under root but it showing me the following error.
#fssnap -F ufs -o raw,unlink,bs=/export/home/BS  /
fssnap: ioctl: error 16: Device busy

Is the snapshot done? if so how to check?
0
 

Author Comment

by:Puneeth MH
ID: 41856825
I tried running the ufsdumo command but I got the following, should I say yes, because under root I have /var/tmp

ufsdump 0f /var/tmp/root.dump /dev/fssnap/0
  DUMP: Date of this level 0 dump: 24 October 2016 04:40:00 PM IST
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rfssnap/0 to /var/tmp/root.dump.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 32 Kilobyte records
  DUMP: Estimated 16200358 blocks (7910.33MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: End-of-file detected
  DUMP: 0.00% done, finished in 0:00
  DUMP: Change Volumes: Mount volume `#2' on `unknown:/var/tmp/root.dump'
  DUMP: NEEDS ATTENTION: Is the new volume (#2) mounted on `unknown:/var/tmp/root.dump' and ready to go?: ("yes" or "no") yes
  DUMP: Volume 2 begins with blocks from inode 2
  DUMP: Dumping (Pass III) [directories]
  DUMP: End-of-file detected
  DUMP: 0.00% done, finished in 0:00
  DUMP: Change Volumes: Mount volume `#3' on `unknown:/var/tmp/root.dump'
  DUMP: NEEDS ATTENTION: Is the new volume (#3) mounted on `unknown:/var/tmp/root.dump' and ready to go?: ("yes" or "no")
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41856840
No. This looks like you are saving the dump file onto the same filesystem you are reading from.
You need thre pieces:
1. the file system to back up          /
2. the backing store (must not reside on 1.)
3. the dump file (must not reside on 1.)
1
 

Author Comment

by:Puneeth MH
ID: 41856861
I did not understand file system to back up,  is this means source or destination machine path?, if so where to mention in the below command?

fssnap -F ufs -o raw,unlink,bs=/export/home/BS  /


Could you please give explain with example of my case?
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41856874
use /export/home to put backup file AND backing store onto.
Delete all existing snap shots:
1) Check which snapshots exist
     fssnap -i
2) Delete all snapshots (one by one)
     fssnap -d /dev/fssnap/x      (x = no. from above)

Backup up using ufsdump with snapshot:
a) Create snapshot for /
     fssnap  -F ufs  -o raw,bs=/export/home/BS    /
b) Check snapshots (just to be sure)
     fssnap -i
c) dump to file root.dump, where x = no. from b) above
     ufsdump  0f /export/home/root.dump  /dev/fssnap/x
1
 

Author Comment

by:Puneeth MH
ID: 41856908
See I have a single machine which has Solaris 10 running on it, in the same machine I have /var/tmp and /export/home so keeping this in mind, shall I go ahead executing your steps without worrying source and destination for snapshot alone?
0
 

Author Comment

by:Puneeth MH
ID: 41858079
I believe and take forward your steps executing in the same machine.

Next you have asked me to transfer to the destination system so here my queries are,
 1) What should be the configuration of the destination system, like does it have Solaris 10 running on it?
 2) Where to copy file I mean which location in the destination machine?

How to mount the new root filesystem under /mnt?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41858382
You said you wanted to 'clone' -- which means you will put stuff on an new (usually blank) disk.
The answer is in my post from 2016-10-21 at 14:08:46 already.
1
 

Author Comment

by:Puneeth MH
ID: 41859763
Thanks a ton, snapshot and dump got created under /export/home, I am worrying about the statement of yours on the same post,

Stmt:Transfer (copy) the dump file onto the other system and mount the new root filesystem under /mnt.

Ok fine I have a new disk or a new system which is usually blank.
Should I install Solaris 10 in that disk/new system and copy the dump only to follow your steps?
If so where to copy I literally mean which location in the new disk/new machine? Is it on the root or root/tmp where?

Second concern is how to mount the root filesystem? Is that Ok If I follow below steps to mount? Please answer all my resentments.

# newfs /dev/rdsk/c0t1d0s0
# fsck /dev/rdsk/c0t1d0s0
# mkdir /legacy
# mount /dev/dsk/c0t1d0s0 /legacy
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41859849
Transfer (copy) the dump file onto the other system and mount the new root filesystem under /mnt
Now, extract the (whole) dump into it:
What you wrote is fine, but fsck is not required.
As I wrote earlier (I will add a few more details here) you go into the (blank) root filesystem to restore your dump:
# newfs /dev/rdsk/c0t1d0s0
# mount /dev/dsk/c0t1d0s0  /mnt
# cd /mnt
# ufsrestore xf /export/home/root.dump

Open in new window


Don't forget to install the boot block:
# installboot /usr/platform/`uname -m`/lib/fs/ufs/bootblk  /dev/rdsk/c0t1d0s0

Open in new window


Now you have a fresh copy of your root file system on c0t1d0s0 which is bootable.
1
 

Author Comment

by:Puneeth MH
ID: 41859894
This infers I should install Solaris 10 in the new system isn't it?
But if I install the new system with Solaris 10 it will be having some file system right, how should go about it?
Should I place dump file under root / or export/home in the new machine?

These  above are my main points to ponder.
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41859905
If you put the dump onto your second disk (as descibed in my prior post) you can put this disk in another system as first disk to boot from -> a clone (or copy) of your original system.
And that is what you wanted to acomplish, right?
1
 

Author Comment

by:Puneeth MH
ID: 41859996
This could also serve the requirement if there are two disks in the same machine.  But what if there are two machines and each only one disk? What you said was right but right now my machine has only one disk and I will have to dump the file onto another machine.
How to proceed in this scenario?
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41860074
a) The dump file can be written to any device you have (tape, disk, NFS-mounted diretory, SaMBa share, etc.)
b) If you have only a single drive target machine, you will have to boot that machine over network or from CD/DVD as you cannot create a new root filesystem on a "live" disk/filesystem
1
 

Author Comment

by:Puneeth MH
ID: 41860121
The following steps has to be executed on the target machine is it?
I believe the target machine should be running any OS on that we will have to perform the following steps isn't it?

newfs /dev/rdsk/c0t1d0s0
# mount /dev/dsk/c0t1d0s0  /mnt
# cd /mnt
# ufsrestore xf /export/home/root.dump
# installboot /usr/platform/`uname -m`/lib/fs/ufs/bootblk  /dev/rdsk/c0t1d0s0

But I am perplexed with the point b).

 Can I scp the dump file onto the target machine and then perform the above steps?

I humbly request you to answer my three questions here.
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41860247
b) explains that you cannot overwrite a root filesystem when it's active!
    It must be quiescent (unused)
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41860268
1.) The steps (newfs, ufsrestore) have to be performed on the target machine
2.) You have to run (boot) an OS that has ufsrestore (any Solaris you may have)
3.) ufsrestore will recover all files from your full backup (ufsdump with level 0) to a (new and empty) filesystem
     You can either copy (scp) the dump file or mount via NFS.
     If you have an existing server you want to replace the root filesystem, you can
     a) transfer (copy) the dumpfile to any place outside the root filesystem
     b) Boot the system from another disk, network or CD/DVD
     c) newfs the root filesystem and mount under /mnt
         cd into /mnt and extract your dump using ufsrestore.

A side note:
You can easily examine the dump using
   ufsrestore if /export/home/root.dump
Now, you can user commands like ls, pwd and cd to move around and look at backup contents. quit will leave. More can been learnt with "man ufsrestore"
1
 

Author Comment

by:Puneeth MH
ID: 41861648
This is under export/home
# ls -lh
total 16219376
-rw-------   1 root     root        7.7G Oct 26 18:30 BS
drwx------   2 root     root        8.0K Oct 19 15:39 lost+found
-rw-------   1 root     root        7.7G Oct 25 16:17 root.dump

If I SCP the dump file (root.dump) onto target machine why should I do b), because target machine is already running with Solaris 10. What does the disk, cd?DVD contains here?
What do u mean to say boot from CD/DVD when I have OS already installed in the target machine?
I will transfer the dump file to the target machine and start mounting it, will it not work?
0
 
LVL 16

Assisted Solution

by:Hanno Schröder
Hanno Schröder earned 500 total points
ID: 41861887
1. The dump file is a backup archive (not a disk image that can be mounted)
2. As said several times alreadyy: You cannot extract a dump onto a "live" filesystem
   Therefore you have to boot NOT from the filesystem you want to restore.
3. You say you already have Solaris 10 up and running on target machine. Why do a new install with all this?
0
 

Author Comment

by:Puneeth MH
ID: 41863442
Yes exactly How do I go with target machine configuration?
Before booting Should I need an empty machine without any OS?

If there is nothing in the machine How to transfer the dump file?
What I understand is
a) Get an empty machine (Target machine)with no OS
b) Boot an OS from CD/DVD
c) transfer the dump file
d) then perform ufsrestore and install boot

Is that correct?
0
 
LVL 16

Accepted Solution

by:
Hanno Schröder earned 500 total points
ID: 41863634
I tink this is now way beyond the scope of your original question!
But to give you some idea:

The easiest would be to put a second disk to your source machine.
Otherwiese:
- Boot target machine from CD/DVD (Solaris CD/DVD)
- Create desired filesystems (at least for / and /export/home)
- Mount fs and put dump file onto filesystem you created for /export/home (or mount via NFS)
- cd into mount point for new root and extraxt dump file
- boot with "reconfigure"
0
 

Author Comment

by:Puneeth MH
ID: 41869712
I totally agree having another new drive instead of new target machine.
I bought a new hard drive.
I did connect this new drive, using format, fdisk and partition.
Now How to transfer the dump file onto this new drive (any command like cpio if so how)?
Literally how to switch between two drives?
Remember I have not mounted and created any files system because as per your steps I need to transfer (copy) the dump file onto another system and then mount the new fs, restore and the install boot.
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41869721
I just posted an answer to your new question.
0
 

Author Closing Comment

by:Puneeth MH
ID: 41873754
Thanks for the great response
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now