Datenschutz
Home/IT/Solaris/Interactive Installation/Housekeeping  

Solaris on VMware: Interactive Installation  

← Zurück  
(De-)Fragmentation

One problem of all unsupported VMware guest operating systems is the fragmentation of the virtual hard disks. These disk images are large regular files from the host's point of view. In my case I have two hard disks made of four files each (8 GB capacity each disk). The size of these files is starting at almost zero and is growing once the virtual hard disks are going to be formated and filled with data. Unfortunately, deleting data in the guest won't shrink the hard disk files. To free space, the disk images must decrease using the so called VMware tools which are not available for Solaris 2.6

There are several strategies to limit the size of the hard disk images. One of them is the renewal of the virtual hard disks and will be explained here. On a real PC this would mean to replace the hard disks by new ones.

Creating New Hard Disks

With the following procedure the physical size of the virtual hard disks can be reduced and the hard disk layout or the total disk size may be changed if that ever should become necessary. First of all the data on the disks should be reduced to the minimum. Delete all needless files and power down the machine.

The first step is to create two new virtual hard disks using the Virtual Machine Control Panel. The new disks may get exactly the same size as the old ones, which makes it easier to transfer the disklabel, but they may differ to make changes in the layout as well. However, in this example the new disks will be identically to the old ones. The new hard disks are created in a new directory and are called new/solaris-system.vmdk and new/solaris-home.vmdk.

Note that it might be necessary to remove the CD-Rom drive temporary to free one IDE channel.

Preparing the Hard Disks

The next step is the transfer of the disk's content: IDE 0:0 (in Solaris language: c0d0) will copied to IDE 1:0 (c0d1), IDE 0:1 (c1d0) to IDE 1:1 (c1d1). Power on the virtual machine and boot with the reconfigure option. Start typing the command within five seconds and mention the US keyboard layout.

Initializing system
Please wait...


                     <<< Current Boot Parameters >>>
Boot path: /isa/ata@1,1f0/cmdk@0,0:a
Boot args:

Type    b [file-name] [boot-flags]  ENTER       to boot with options
or      i  ENTER                                to enter boot interpreter
or      ENTER                                   to boot with defaults

                  <<< timeout in 5 seconds >>>

Select (b)oot or (i)nterpreter: b -r

The new hard disks must get a partition table which the PC's BIOS can understand. Four primary partitions will be created, one of them (the fourth) will declared as Solaris type. The other three are left empty. This is done using the program fdisk.

# fdisk -B /dev/rdsk/c1d0p0
# fdisk -B /dev/rdsk/c1d1p0

Now the new Solaris partitions will get a abel, which specifies the borders of the slices within the partition. First I store the old disklabels in text files.

# echo "save /tmp/format_c0d0.dat" | format c0d0 >/dev/null 2>&1
# echo "save /tmp/format_c0d1.dat" | format c0d1 >/dev/null 2>&1

And then the label may be transfered to the new disks. That means that the slices will have exactly the same sizes as before. Note that bash's internal echo command is used which understands the -e option.

# echo -e "partition\nselect\n0\nlabel\ny\nquit\nquit" | format -x /tmp/format_c0d0.dat c1d0 >/dev/null 2>&1
# echo -e "partition\nselect\n0\nlabel\ny\nquit\nquit" | format -x /tmp/format_c0d1.dat c1d1 >/dev/null 2>&1

Okay, now the new slices must be formated. Please make no typo, as it could ruin all work already done...

# echo "y" | newfs /dev/rdsk/c1d0s0
# echo "y" | newfs /dev/rdsk/c1d0s1
# echo "y" | newfs /dev/rdsk/c1d0s5
# echo "y" | newfs /dev/rdsk/c1d0s6
# echo "y" | newfs /dev/rdsk/c1d0s7
# echo "y" | newfs /dev/rdsk/c1d1s7

In order to make the new system disk bootable, a Master Boot Record must be installed on it.

# cd /usr/platform/i86pc/lib/fs/ufs/
# PATH=/usr/bin:/usr/sbin
# installboot pboot bootblk /dev/rdsk/c1d0s2

Transferring Data

Now the data can be copied from the old disks to the new ones, one partition after each other. Every slice is mounted to /mnt and filled with the appropriate data.

# mount /dev/dsk/c1d1s7 /mnt
# ufsdump 0f - /export/home | ( cd /mnt ; ufsrestore rf -)
# umount /mnt

# mount /dev/dsk/c1d0s7 /mnt
# ufsdump 0f - /usr/local   | ( cd /mnt ; ufsrestore rf -)
# umount /mnt

# mount /dev/dsk/c1d0s6 /mnt
# ufsdump 0f - /usr         | ( cd /mnt ; ufsrestore rf -)
# umount /mnt

# mount /dev/dsk/c1d0s5 /mnt
# ufsdump 0f - /opt         | ( cd /mnt ; ufsrestore rf -)
# umount /mnt

# mount /dev/dsk/c1d0s1 /mnt
# ufsdump 0f - /var         | ( cd /mnt ; ufsrestore rf -)
# umount /mnt

# mount /dev/dsk/c1d0s0 /mnt
# ufsdump 0f - /            | ( cd /mnt ; ufsrestore rf -)
# umount /mnt
# init 5

Switching the hard disks

Now the old disks may be removed from the computer. The new disks will be moved onto the final place and their original entries are removed from the machine's configuration file (using the Virtual Machine Control Panel). The CD-ROM drive can be reinstalled.

$ mkdir old/
$ mv solaris-system* old/
$ mv solaris-home* old/
$ mv new/solaris-system* .
$ mv new/solaris-home* .

At the end of the procedure everything should be in the same state as it was before, except that the disks need much less space on the host. If everything went well, the old disks may be removed.

$ rm -r old/