Link to home
Start Free TrialLog in
Avatar of Puneeth MH
Puneeth MH

asked on

How to clone solaris 10 machine

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.
Avatar of Hanno P.S.
Hanno P.S.
Flag of Germany image

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
Avatar of Puneeth MH
Puneeth MH

ASKER

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.
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
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 ...
#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
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

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.
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.
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

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?
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")
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.)
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?
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
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?
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?
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.
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
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.
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.
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?
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?
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
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.
b) explains that you cannot overwrite a root filesystem when it's active!
    It must be quiescent (unused)
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"
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?
SOLUTION
Avatar of Hanno P.S.
Hanno P.S.
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
I just posted an answer to your new question.
Thanks for the great response