Saturday Nov 03, 2007

Here you will find my chronicles of several hours of failed attempts to add disk space to a Solaris VM disk image.  It turns out that some "newthink" was required.  If you want the correct solution, just skip to the end.

I'm running my Solaris images under VMware Fusion on a MacBook Pro.  The question has come up on how to expand the virtual disk size. 

  • Download the VMware Virtual Disk manager for MacOS X. This is a GUI to command line tools provided with Fusion.  If you really like command lines, you can find it at: /Library/Application\ Support/VMware\ Fusion/vmware-vdiskmanager. Figure it out yourself.  I know you're man enough!
  • Duplicate your virtual machine.  Only work on the copy! Select it in the Finder and choose Edit > Duplicate. (Apple-D). The VM must NOT be running or even in use and suspended when you make the copy. Fusion complains about this.
  • Start Fusion
  • File Open... your new VM Copy
  • Fusion notices that the name has changed and asks you if you have copied it. 
  • Suspend the VM
  • You must discard any snapshots before expanding this disk. Virtual Machine > Discard Snapshot.
  • Start the Vdiskmanager GUI
  • Click Expand and locate the vmdk file in your VM.  Select your desired size.
  • Click Go (the GUI echoes the command line it uses at the bottom of the windows for cheaters)
  • The GUI does NOT show the progress of this activity.
  • The Results Tab will open when complete with the status.

Now the real fun begins.  Format, however, shows my disk at its original 10 GB size rather than the new 18 GB size.  This is where fdisk comes into play.

fdisk /dev/rdsk/c8t0d0p0 shows that my disk has one partition that is 56% of the entire disk.  This proves that the operation worked. Now we will attempt to delete the partition and recreate it with a larger size while the OS is running (holding breath). Unfortunately, this attempt failed, if you don't care about learning from my failures, skip to the next section.

  • fdisk /dev/rdsk/c8t0d0p0
  • Select 3 to delete the partition, select partition 1 and confirm
  • Select 1 to create a partition. Specify 100% of the Disk.
  • Select 5 to exit and pray!
  • Run Format and crash (Oh crap!  Glad it was only a copy!)
  • System reboots and Grub has no menu. All attempts to boot the kernel fail.Oops. try again.

Ok, so Solaris doesn't like me removing and recreating it's fdisk partition while it's running.  How about creating a separate partition and mounting it?  Throw away this VM and make another copy of the original.  Repeat the steps to enlarge the disk, then... This attempt also failed, if you don't care about learning from my failures, skip to the next section.

  • reboot is required for fdisk to recognize the new larger size
  • fdisk /dev/rdsk/c8t0d0p0
  • 1 to create new partition, enter size, do NOT make active

Now I'm stuck again.  I can't find a way to get format to recognize the disk in order to build slices.  newfs refuses to write a new file system with no partition table.

In SunSolve, I found this bug 6307998 which has been closed with these comments.

I have verified that fundamentally Solaris has a limitation in that 
it does not allow more than one physical Solaris partition on the same disk.

This lack of functionality goes beyond the installer, it's something lacking in
Solaris in general. Having 2 Solaris partitions on the same disk is not
supported in Solaris because the disk driver assumes there's only one
Solaris partition per disk. For example, if we reference /dev/dsk/c0d0s0, how do
we determine which Solaris partition we're intending to access on c0d0.

 ZFS to the rescue

Who needs that nasty old format and mkfs stuff when you have ZFS! 

  • reboot is required for fdisk to recognize the new larger size
  • fdisk /dev/rdsk/c8t0d0p0
  • 1 to create new partition, enter size, do NOT make active
  • zpool create mypool /dev/dsk/c8t0d0p1
  • zfs create mypool/jim

I've successfully increased by virtual storage!

 Alternative method:  Add a second disk to the image

In order to add second hard disk with Fusion.

  • solaris must be halted.
  • VM must be shut down.
  • Click the + sign, add disk and enter a size.
  • devfsadm  (almost typed reboot -- -r but that would be "old think" so that format sees the new device.)

format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c1t0d0 <DEFAULT cyl 1302 alt 2 hd 255 sec 63>
          /pci@0,0/pci1000,30@10/sd@0,0
       1. c1t1d0 <DEFAULT cyl 2557 alt 2 hd 128 sec 32>
          /pci@0,0/pci1000,30@10/sd@1,0

# zpool create mypool /dev/dsk/c1t1d0
# zfs create mypool/jim

# zpool status
  pool: mypool
 state: ONLINE
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        mypool      ONLINE       0     0     0
          c1t1d0    ONLINE       0     0     0

# zpool list
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
mypool                 4.97G    116K   4.97G     0%  ONLINE     -
 

Why should you care

I found myself guilty here if something that my customers also do frequently.  That is, deal with Solaris 10 as if it were Solaris 2.2.  The new capabilities of the open sourced ZFS are not only easier to use, they support a wider variety of options for the user.


 

Comments:

I'm unsure if this works under vmware, but I don't see why it wouldn't. The way we grow zfs luns on our SAN (our array supports growing of luns, unfortunately zfs does not).

Say we have a 50gig lun that is under zfs control and you want to grow it to 100gig. What we have to do (so we don't require a reboot to our servers) is you allocate the 100gig lun to the server, and mirror the 50gig lun to it via zfs. Once the mirror is complete, remove the 50gig lun from the mirror. ZFS then happily starts using the 100gig instead of being limited to the 50gig cause of the mirror partner.

It would be wonderful if zfs could dynamically grow a lun without having to jump thru hoops like this, but this is the only way I've found to do it so far.

Posted by Simon Coggins on November 08, 2007 at 05:45 PM EST #

My internal sources point me to infodoc 88135 and these bugs:

http://bt2ws.central.sun.com/CrPrint?id=6475340
when lun expands, zfs should expand too

http://bt2ws.central.sun.com/CrPrint?id=6606879
should be able to grow pool without a reboot or export/import

Be sure to add your name to the bug if you want it prioritized.

Posted by Jim Laurent on November 09, 2007 at 12:59 PM EST #

You don't want to use fdisk on OSX, you must use diskutil so EFI stays in sync. I have zfs on my MacBook Pro under Leopard as the 4th partition. Leopard also makes the hybrid partitioning of MBRFormat + GPTFormat unnecessary as it was needed in Tiger. You may simply run:

`diskutil resizeVolume disk0s2 MS-DOS Windows 62G zfs %noformat% 24.4G` and it'll still be able to have Windows installed on the third partition. Personally I use Winclone 1.6 beta and have my Boot Camp partition backed up, so activation and product id's are retained for Windows. You can use dd to clone your Solaris partition and use it under VMware with a little effort also, in the instance you're smart enough to follow Paul Michell's instructions to install OpenSolaris bare metal. Also remember to use SysKonnect's drivers for the ethernet.

Fusion does not provide the ability to use non-Windows partitions, Parallels does by editing the configuration file for a Boot Camp partition. It's due to the fact Fusion will look for Boot Camp partitions on the fly, and has really lacking configuration options, especially in the GUI. Personally I have better experience with VMware and Solaris, but that's how it is, and it's still not fixed in the latest Fusion beta.

It's perfectly fine to use fdisk on an MBP type external disk, just don't do it on the internal, you'll break OSX' ability to update EFI firmware.

Once partitioned:

sudo su
mkdir /zmount
zpool create fishtank /dev/disk0s4
zfs unmount -f fisktank
zfs set mountpoint=none fishtank
zfs create -o compression=on -o mountpoint=/zmount/vm -o quota=20G -o reservation=10G fishtank/vm

In Fusion, create a new VM, and use command + shift + g then type /zmount/vm and select allocate all space now, and it'll create 10x faster than on HFS+ with only 1kb usage. Also check split into 2GB files if you might need to move the VM using a vfat formatted external disk.

Posted by James Cornell on November 14, 2007 at 06:02 AM EST #

чччччччч

Posted by Ангелок on January 20, 2008 at 03:24 AM EST #

Nice post.

Allocated a single 20Gb Virtual Disk for SXDE 9/07 on a new PC but at SXDE install time I only wanted to partition up to 15Gb of that 20Gb - I was thinking "I may need to use the remaining 5Gb in another way at a later date". Wanted to do it this way so that the entire 20Gb VMware virtual disk was not fragmented, and that the virtual machine used one single filesystem space on the host machine.

Added second Solaris2 partition using fdisk but "/reconfigure" or format won't let me see it. Google, and find myself here, now I know why. Thank you.

Nice time to learn ZFS me thinks.

Posted by Eric Taylor on February 22, 2008 at 01:09 PM EST #

LOL - just read your "If you are interested in making yourself and your business more productive with Sun products and services, I hope you will get benefits from my blog."

OK.....but as an Engineer do I HAVE to get tech advice from a guy who is a freaking Arts graduate? It seems so...the horror!!!

Posted by Eric Taylor on February 22, 2008 at 01:19 PM EST #

I'm glad I could help!

Posted by Jim Laurent on February 22, 2008 at 01:22 PM EST #

Im using VMware Workstation 6.0 and installed Solaris 10 x86 on my laptop (Vista) on a 10GB parition.

Current Size shows 4.36 GB
Maxium Size = 10Gb

When im in solaris it shows the disk being full?
Can any one shed some light in this?

Posted by Avi on March 17, 2008 at 12:31 PM EDT #

Sorry for the late response. I was on vacation last week.

Most common reason for a root file system to be full can be crash dumps in /var/crash.

This particularly true in the case of VMware rather than real hardware because sometimes VMware doesn't perfectly virtualize the HW and causes Solaris to panic resulting in a crash dump.

Remove these very large crash dump files.

Posted by Jim Laurent on March 24, 2008 at 10:58 AM EDT #

Hello Jim,

Thanks for the reply... but I dont think that is the case... I have a Guest operating system setup on VM 6 Workstation 6 with a 15 GB (Pre-allocated) and the only thing I have installed is just the OS and downloaded Oracle DB enterprise which is about 700MB and the disk is showing 94% full at 4.4 GB... let me know if you need more information.

Thanks in advance

Posted by Avi on March 24, 2008 at 09:21 PM EDT #

I guess I don't know what you mean by the "disk." If you are talking about the root file system as shown by df -h, that's entirely possible if you made / a small size and swap and /export/home a large size.

Meanwhile I can't psychically determine what is taking up lots of space on your disk partitions.

You can email directly jim dot laurent at sun dot com.

Send out put for df -h

Posted by Jim Laurent on March 24, 2008 at 09:49 PM EDT #

Hi Jim,

So that "bug" does exist (read: not implemented yet)

http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6475340

Interestingly though you *can* make it work with a rather ugly work around!

1. Present 50G LUN to S10
2. Zpool it
3. Expand the LUN to 100GB (I just created a LUSE on the array side)
4. Deport the Zpool
5. Reconfigure the disk type with format (it was a little confused and thought it only had half the sectors it should have)
6. Manually mangle the partition table so s0 goes from sector 34 - <last sector - the 8mb reserved EFI space>
7. Label the disk
8. Import the zpool and magically ZFS decides to use all 100GB

I wouldn't *ever* recommend doing this on a production system. But it does work! To do this on a root file system you would need some sort of bootable media (USB/DVD).

Posted by Dale Clutterbuck on August 06, 2008 at 07:33 PM EDT #

Hi,

I have one VMWARE Lab machine and I have Solaris10 installed on it.

I want to create Virtual Disks on it but after adding additional hard disk,when I run format it doesnot show me additional disk.

Please suggest me the correct and complete steps.

Thanks in advance.......
Prabal Tripathi

Posted by prabal Tripathi on October 08, 2008 at 08:58 AM EDT #

Did you remember the "devfsadm" step?

This is required for Solaris to see the new device on the device tree.

In order to add second hard disk with Fusion.

* solaris must be halted.
* VM must be shut down.
* Click the + sign, add disk and enter a size.
* devfsadm (almost typed reboot -- -r but that would be "old think" so that format sees the new device.)

format

Posted by Jim Laurent on October 09, 2008 at 03:39 PM EDT #

kjjbjbjbjbj

Posted by 68.97.244.182 on October 21, 2008 at 11:08 PM EDT #

Thanks for joining in on the comment page.

Documentation for Solaris 10 live upgrade is at:

http://docs.sun.com/app/docs/doc/817-5505

You do not need a separate disk but will need a separate disk slice. Once you have created a separate disk slice you create an alternate boot environment. This will copy your existing S8 root slice over to the ABE.

Then you upgrade from S8 to S10 on the ABE while the system is still running the primary BE. After the upgrade is complete and recommended patches applied, reboot to the ABE.

There is a very nice "how to" guide at:

http://www.sun.com/software/solaris/howtoguides/liveupgradehowto.jsp

I can't give you all the instructions here but the documentation should provide you with full set of instructions.

Posted by Jim Laurent on February 03, 2009 at 06:38 AM EST #

[Trackback] Sun&apos;s Jim Laurent reports that the Department of Defense is writing its own secured office suite, using OpenOffice.org code as a starting point. &nbsp;Microsoft&apos;s &quot;Shared Source&quot; program, apparently, does not give them enough freedo...
http://www.globalsale.me/Aion-gold-083.aspx
http://www.cheap-gamegold.org
http://www.gamegoldvip.org
http://www.watchrolexshop.com
http://www.gamegoldme.com

Posted by replica rolex on June 24, 2009 at 05:28 AM EDT #

Post a Comment:
  • HTML Syntax: NOT allowed