How to copy a Solaris boot drive to a disk with a different partition layout

If you’ve ever gone to mirror a system drive with Solstice Disk suite, you know how frustrating it can be when you either don’t have any more slices to use for your meta database partitions, or all the space on the disk has already been allocated to existing partitions. While Disk Suite only requires one partition be reserved for its meta database information on boot drives, two are really suggested for redundancy purposes, and in the example below, I found myself needing to mirror a system disk that had only one remaining partition, and no space left that could be used for the meta database.

While I could have taken a small amount of space from the swap partition and re-allocated it to a new meta database partition on slice 7, this solution would not have been elegant, and I would have still only had one meta database partition. As it stood, the system had the following filesystems on the following disk slices:

c1t0d0

Part Tag
0 root
1 swap
2 backup
3 usr
4 usr/local
5 opt
6 var
7 unused

In order to bring the system into line with my standards and prepare it for proper mirroring, I would have to carve up another disk, and migrate the data to it.

Here is what the partition table on the new disk looked like:

c1t2d0
Current partition table (original):
Total disk cylinders available: 24620 + 2 (reserved cylinders)

Part Tag Flag Cylinders Size Blocks
0 root wm 0 - 1088 1.50GB (1089/0/0) 3146121
1 swap wu 1089 - 6896 8.00GB (5808/0/0) 16779312
2 backup wu 0 - 24619 33.92GB (24620/0/0) 71127180
3 - wm 6897 - 6967 100.16MB (71/0/0) 205119
4 - wm 6968 - 7038 100.16MB (71/0/0) 205119
5 opt wm 7039 - 8853 2.50GB (1815/0/0) 5243535
6 usr wm 8854 - 12483 5.00GB (3630/0/0) 10487070
7 var wm 12484 - 24619 16.72GB (12136/0/0) 35060904

Now that everything is all laid out, we can start moving all the data from c1t0d0 to c1t2d0, keeping in mind that we will be merging /usr/local onto /usr on the new system disk… Here we go

Make a new filesystem for /:

# newfs /dev/rdsk/c1t2d0s0
newfs: /dev/rdsk/c1t2d0s0 last mounted as /
newfs: construct a new file system /dev/rdsk/c1t2d0s0: (y/n)? Y

Mount the new / filesystem as /mnt:
# mount -F ufs -o rw /dev/dsk/c1t2d0s0 /mnt
Move the data from c1t0d0s0 to c1t2d0s0:
# ufsdump 0f - / | ( cd /mnt ;ufsrestore xvf - )
Add links
Set directory mode, owner, and times.
set owner/mode for ‘.’? [yn] y
Directories already exist, set modes anyway? [yn] y
DUMP: 405886 blocks (198.19MB) on 1 volume at 406 KB/sec
DUMP: DUMP IS DONE

Unmount /mnt
# umount /mnt

That’s the general idea… Now we just have to do the same thing for the other partitions, leaving out swap, backup, and our two meta database partitions of course. These partitions (1,2,3 and 4) should be left alone for the time being, as they are never mounted as filesystems.

# newfs /dev/rdsk/c1t2d0s5
# mount -F ufs -o rw /dev/dsk/c1t2d0s5 /mnt
# ufsdump 0f - /opt | ( cd /mnt ;ufsrestore xvf - )
# umount /mnt
# newfs /dev/rdsk/c1t2d0s6
# mount -F ufs -o rw /dev/dsk/c1t2d0s5 /mnt
# ufsdump 0f - /usr | ( cd /mnt ;ufsrestore xvf - )
# umount /mnt
# newfs /dev/rdsk/c1t2d0s7
# mount -F ufs -o rw /dev/dsk/c1t2d0s5 /mnt
# ufsdump 0f - /var | ( cd /mnt ;ufsrestore xvf - )
# umount /mnt
Finally, the /usr/local partition
# mount -F ufs -o rw /dev/dsk/c1t2d0s5 /mnt
# ufsdump 0f - /usr/local | ( cd /mnt/local ;ufsrestore xvf - )
# umount /mnt

Now that we have all the data moved, we still don’t have a disk that is bootable. Since the whole idea here is for us to end up with a new bootable system disk, we have to install bootblocks onto the new system disk. This is done with the installboot command:

# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t2d0s0

Now that we have the bootblocks needed to boot the solaris kernel, the last thing we have to do is make sure our new vfstab file points to all the right partitions.

Mount the new / partition:
# mount -F ufs -o rw /dev/dsk/c1t2d0s0 /mnt
Edit the new vfstab file:
# vi /mnt/etc/vfstab
For the information given in this example, this file will contain the following entries:

#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c1t2d0s1 - - swap - no -
/dev/dsk/c1t2d0s0 /dev/rdsk/c1t2d0s0 / ufs 1 no -
/dev/dsk/c1t2d0s5 /dev/rdsk/c1t2d0s5 /usr ufs 1 no -
/dev/dsk/c1t2d0s6 /dev/rdsk/c1t2d0s6 /var ufs 1 no -
/dev/dsk/c1t2d0s7 /dev/rdsk/c1t2d0s7 /opt ufs 2 yes -
swap - /tmp tmpfs - yes -

Notice that the target number will remain 2, not move to 0 when we swap the disks and boot from the new one. To resolve this, it is strongly suggested that you rebuild the solaris device tree and change the vfstab file to reflect the new disk position.

That is everything! We now shutdown the system, swap the positions of c1t0d0 and c1t2d0 and reboot off our new system disk. We are now ready to move onto the mirroring process.

Discuss This Article


13 Responses to “How to copy a Solaris boot drive to a disk with a different partition layout”

  1. spiralbound.net » Rebuilding the Solaris Device Tree on December 21st, 2005 2:57 pm #

    [...] If you ever shift around any bootable drives within a Sun Solaris box, you may find that either the device names (cxtxd0sx) do not follow the disk position within the server, or, the system just fails to boot because it can’t mount the other disk slices. [...]

  2. Jokerbone » Solaris partitioning on February 1st, 2006 9:49 pm #

    [...] I had great fun following this process today. I made it to the last bit, but after rebooting the system wants to mount / as a read-only file system, freaks out about not being able to create /tmp, execute cron jobs and do a handful of other really important things and then presents a login prompt. [...]

  3. cliff on February 2nd, 2006 9:12 am #

    This sounds like it may be caused by mixed up device links. Did you rebilid them?

  4. Life After Coffee » Determining credibility of web resources on July 25th, 2006 4:35 pm #

    [...] What is the reputation of the site in question from other, possibly more reputable sites? For instance, Cliff wrote some instructions on Solaris partitioning which were linked by Sun support shortly after that. A link like that gives a high level of confidence in the content presented. [...]

  5. spiralbound.net » Taking Disk Cylinders From Swap on Solaris 8 on November 21st, 2006 5:31 pm #

    [...] You can also use my instructions for copying a Solaris boot drive to a disk with a different partition layout as a safer alternative. [...]

  6. Maelstrom on March 9th, 2007 6:28 pm #

    Should these be set to slice 6 and 7 respectively?

    EG # mount -F ufs -o rw /dev/dsk/c1t2d0s6/mnt
    and
    # mount -F ufs -o rw /dev/dsk/c1t2d0s7 /mnt
    instead of just using s5

    # newfs /dev/rdsk/c1t2d0s6
    # mount -F ufs -o rw /dev/dsk/c1t2d0s5 /mnt
    # ufsdump 0f - /usr | ( cd /mnt ;ufsrestore xvf - )
    # umount /mnt
    # newfs /dev/rdsk/c1t2d0s7
    # mount -F ufs -o rw /dev/dsk/c1t2d0s5 /mnt
    # ufsdump 0f - /var | ( cd /mnt ;ufsrestore xvf - )
    # umount /mnt
    Finally, the /usr/local partition
    # mount -F ufs -o rw /dev/dsk/c1t2d0s5 /mnt
    # ufsdump 0f - /usr/local | ( cd /mnt/local ;ufsrestore xvf - )
    # umount /mnt

  7. kjs on June 27th, 2007 10:46 am #

    I have used the above procedure to copy the contents of an entire disk over to a different disk. It worked very nicely, and now I have a system with a mirrored disk set (using DiskSuite).
    Thanks, great article
    js

  8. cliff on June 27th, 2007 9:40 pm #

    Hey JS,

    I’m glad the article was helpful to you :)

  9. BaffyOfDaffy on July 23rd, 2007 6:01 pm #

    You may also want to boot to an alternative source (cd/dvd/net) in order to ensure that you are not trying to deal with changing content

  10. spiralbound.net » Moving Large Directories on Solaris on August 13th, 2007 1:37 pm #

    [...] some of the files in those directories are larger than 8 Gigabytes. One solution is to use a “ufsdump pipe to ufsrestore” command, but I have even had problems with this from time to time. My perfered method these [...]

  11. Prasen on August 20th, 2007 11:51 am #

    Good document.

    With this document I did on SUNfire 440 with Solaris 10. But problem is that its took long time to take backup & restore with 3 GB data using #ufsdump 0f - /usr | ( cd /mnt ;ufsrestore xvf - )

    Near about 3 hours it tooks take backup & restore with 3 gb data.

    Is there any solution to minimise the time.

    One more thing I am not able to rebuild /etc/path_to_inst file with following command in Solaris 10 release 10/6

    # devfsadm -r /mnt -p /mnt/etc/path_to_inst

    Thanks …
    Prasen

  12. How to copy a Solaris boot drive to a disk with a different partition layout | IDGLabs.COM - tips, tools and resource on April 16th, 2008 4:14 am #

    [...] Link:http://spiralbound.net/2005/05/10/how-to-copy-a-solaris-boot-drive-to-a-disk-with-a-different-partit… BookmarkBookmark and Share This Page | « CloseSave to Browser FavoritesAskbackflipblinklistBloglinesBlogMarksBlogsvineBUMPzee!CiteULikeco.mmentsConnoteadel.icio.usDotNetKicksDiggdiigodropjack.comdzoneFacebookFarkFavesFeed Me LinksFriendsitefolkd.comFurlGoogleHuggJeqqKaboodlelinkaGoGoLinksMarkerMa.gnoliaMister WongMixxMySpaceMyWebNetvouzNewsvinePlugIMpopcurrentPropellerRedditRojoSegnaloShoutwireSimpysk*rtSlashdotSphereSphinnSpurl.netSquidooStumbleUponTailrankTechnoratiThisNextWebrideWindows LiveYahoo!Email This to a FriendHTML: If you like this then please subscribe to the RSS feed or Email feed.Powered by Bookmarkify™ More » Tags: boot, computer, disk, disk cylinder, disk label, disk suite, disksuite, howto, metadb, mirroring, mirroring scripts, partition, partition layout, process, risky, server, Solaris, Solaris, solaris 8, Storage, sun microsystems, swap [...]

  13. DaveK on June 17th, 2008 5:28 pm #

    Thanks for this article, I’ve just used it to move to a bigger drive in my E4500.


Got something to say?






Post Tags (user submitted): t (781) - solaris installboot (781) - ufsdump ufsrestore (604) - tag/storage (493) - solaris ufsdump (307) - installboot solaris (262) - Solaris 10 installboot (197) - Solaris Disk copy (171) - solaris ufsdump ufsrestore (164) - installboot solaris 10 (142) - ufsdump to disk (136) - ufsdump solaris (100) - solaris 10 ufsdump (100) - ufsdump ufsrestore solaris (95) - No Entries in the Drive Database (90) - ufsdump examples (85) - solaris copy partition (82) - ufsrestore solaris (79) - ufsdump howto (77) - ufsdump (73) - solaris ufsrestore (73) - solaris copy disk (71) - solaris copy partition table (70) - ufsdump copy (59) - f (59) - ufsdump solaris 10 (58) - all (56) - copy disk solaris (56) - Solaris boot -b (52) - ufsdump example (51) - disk copy solaris (48) - ufsrestore example (43) - "ufsrestore examples" (43) - solaris copy filesystem (42) - solaris 10 disk mirror (38) - ufsdump copy disk (37) - mirroring Solaris boot drives. (35) - solaris disk to disk copy (34) - ufsdump disk to disk (33) - solaris boot net (32) - copy partition table solaris (32) - solaris 10 mirror disk (32) - netbackup No Entries in the Drive Database (31) - solaris make disk bootable (31) - ufsrestore howto (30) - solaris 10 mirror boot disk (30) - Solaris 10 disk copy (30) - copy solaris disk (30) - solaris boot disk (29) - solaris bootable (29) - solaris copy (29) - ufsdump pipe ufsrestore (28) - solaris mount disk (27) - ufsdump disk copy (27) - solaris ufsdump example (27) - ufsdump ufsrestore copy (26) - solaris copy boot disk (26) - solaris diskcopy (26) - ufsdump and ufsrestore (26) - solaris ufsdump examples (25) - solaris ufsrestore example (25) - ufsrestore ufsdump (25) - solaris (24) - ufsrestore Solaris 10 (24) - ufsdump copy filesystem (23) - Solaris 10 disk mirroring (23) - installboot in solaris (23) - disk to disk copy in solaris (23) - copy filesystem solaris (22) - solaris copy "disk to disk" (22) - ufsdump in solaris (22) - solaris copy drive (22) - copy solaris (21) - copy partition solaris (21) - solaris boot (21) - ufsrestore in solaris (21) - "boot -b" solaris (21) - ufsdump installboot (20) - solaris boot mirror (20) - mount disk solaris (19) - solaris ufsdump to disk (19) - solaris copy root disk (19) - solaris 10 ufsrestore (19) - copy boot disk solaris (18) - solaris copy root partition (17) - ufsdump disk | (17) - disk to disk copy solaris (16) - ufsdump copy partition (16) - ufsdump/ufsrestore (16) - solaris ufsdump root (16) - copy solaris boot disk (16) - ufsdump to copy filesystem (16) - ufsdump root (16) - ufsdump ufsrestore copy disk (15) - solaris copy boot block (15) - solaris copy partitions (15) - solaris partition copy (15) - solaris ufsdump disk (15) - solaris 10 mirror boot drive (15) - tag/Solaris (14) - solaris 10 boot disk (14) - copy solaris partition (14) - solaris 10 "boot net" (14) - ufsdump mirror (14) - "no entries in the drive database" netbackup (14) - copy root disk solaris (14) - solaris 10 ufsdump ufsrestore (14) - mss (14) - solaris filesystem copy (14) - solaris move boot disk (13) - ufsrestore installboot (13) - ufsrestore slow (13) - ufsdump slow (13) - solaris unmount swap (13) - disk copy ufsdump (13) - copy filesystem ufsdump (13) - mirror disk solaris 10 (13) - solaris ufsdump howto (13) - ufsdump ufsrestore copy filesystem (12) - "ufsrestore" (12) - solaris disk dump (12) - solaris: installboot command (12) - solaris ufsdump disk to disk (12) - disk copy solaris 10 (12) - newfs /dev/ (12) - copy disk + ufsdump (12) - Diskcopy Solaris 9 (12) - Solaris 8 + ufsrestore (12) - solaris 10 x86 installboot (12) - ufsdump 0f (11) - solaris disk copy ufsdump (11) - ufsdump 0f - / | ( cd /mnt ;ufsrestore xvf - ) (11) - ufsdump + "boot disk" (11) - solaris copy disks (11) - mirror boot disk solaris 10 (11) - ufsdump boot (11) - solaris boot disk copy (11) - +ufsdump +ufsrestore +example (11) - ufsdump in solaris 10 (11) - copying a disk in solaris (11) - ufsdump on solaris 10 (11) - ufsdump / on solaris (11) - sun solaris disk copy (11) - copy disk ufsdump ufsrestore (11) - sun disk copy (11) - copy boot block solaris (11) - bootable solaris (11) - installboot command in solaris (11) - umount swap solaris (10) - solaris 10 mirror (10) -