OpenSolaris Disk Goodness
OpenSolaris Disk Goodness
OpenSolaris Disk Partitioning and the Free Hog
Background...
Let’s face it pigs want space and pigs are fairly hard to move around when they don’t want to. So as a result they tend to just sit there until something motivates them to move. OpenSolaris on Intel changed the “rules” we all knew and loved about partitioning hard disks on Solaris. ZFS had an even greater impact, so much so, that normal partitions are of little consequence anymore. However, if one wants to optimize or tweak the partition tables in a stock OpenSolaris installation, this will tell you how it’s done. The impatient can go to the summary at the end of this page.
This technique can also be employed if upgrading to larger hard disks on your machine. For instance, you started with 20GB disks and decided that 500GB disks were more your liking.
If you have an enterprise class server and a SAN, then these techniques probably aren’t what you are looking for, however, if you are looking to maximize your storage bang-for-the-buck and increase its flexibility either at home or a small to medium sized business, then this is for you.
This will assume two things:
‣You have more than one disk on your system and intend to mirror your boot drive.
‣ OpenSolaris 2008.11, though this may work on previous versions. If you don’t have it, you can get it here.
Click here to view the full dialog box.
One key item of note here is that I’m using a bridged network interface in the virtual host, along with DNS and DHCP, I can ensure that NWAM will get the network configuration.
A “Free Hog” partition used to be the partition on the disk which contained all the remaining unallocated disk space when using the Solaris format utility. As partitions were created or resized, it would take up all remaining disk space in this “free hog” partition. More background may be found on Sun’s web site in the “Basic System Administration Guide: Dividing a Disk Into Slices.”
First a bit of information about partitioning...
On Intel machines, there are two layers of “partitioning” done for the OpenSolaris installation. One happens at the BIOS level on the disk using a utility such as “fdisk”, and the other is within one of these four BIOS partitions. This creates the traditional VTOC partitioning scheme of slices people familiar with previous versions of Solaris know. I won’t go into too much detail here on this because there is a great blog entry on how Solaris disk device names work. OpenSolaris can only use one of these fdisk partitions to store it’s partitioning table or VTOC.
Why does all this matter? When OpenSolaris installs, it gives you a choice to use all of the disk or to create fdisk partitions on the disk so you could use the disk for a dual-boot configuration. Or, if you have a disk already partitioned with fdisk, it will allow you to select which partition you wish to use for the Solaris installation. OpenSolaris the places a default VTOC on that fdisk partition which is somewhat less than optimal.
The entire fdisk partition selected is used, but the OpenSolaris partitions are set up with two partitions. One for the ZFS rpool, and a second partition for swap. The default on these is to use a swap size equal to your physical memory and a slice for the ZFS partition made up of everything else. NOTE - 13 May 2009: I did an install on my PHYSICAL server today and discovered that the OpenSolaris 2008.11 instal does not create a swap partition, but creates a ZFS zvol. This is good news since previously I was going to use SVM to mirror the swap partition. Previous versions of the ZFS best practices warned against using a ZFS Volume for a swap device, but I guess it’s better now though I still cannot see to find too much information on the subject. I did go back and check the VirtualBox installation again and it does create a separate swap partition on the vdisks, not sure why there is an inconsistency here.

This is alright, except I might not want all of a 500GB disk used for rpool, especially because later, the rpool virtual device (vdev) cannot be extended. The base operating system really only needs about 8GB for an install. I can create a smaller base footprint on the disk for the rpool and then create a second zpool on the disk for other things like zones, virtual hosts, database storage, or really anything else I’d like to be maintained separately from the operating system.
Additionally, sizing swap equal to physical memory by default just doesn’t cut it sometimes. Some software vendors also, not that it’s proper, check the swap size with their installers to make sure you have two times memory for swap. These products will sometimes fail to install is they fail the “swap check.” (Oracle comes to mind, but isn’t supported on OpenSolaris 2008.11 - yet...)
So, on to the Install...
Click here to view the full dialog box.
In the configuration panel, I will select to partition the disk. Then only create a single partition of 8GB for the OpenSolaris base install. The remaining partitions will be unused. We’ll re-partition this disk later on in the process using the format and fdisk command line utilities in OpenSolaris.
The installation will takes about an hour and a half in the VirtualBox for me. This time includes installing the guest additions and rebooting. Installing the guest additions are probably unnecessary for this purpose, but I do so only for completeness.
One note about my interaction with the machine. In the following text, my commands will be in blue and the computer responses will be in green. For example, I will be doing all this as root so in OpenSolaris, I will shell into the machine and use pfexec su - to get root privileges. Here is what that would look like:
[mps@lithium-wire ~]$ ssh panacea
Password:
Last login: Sun May 10 16:42:45 2009 from lithium-wire.ka
Sun Microsystems Inc. SunOS 5.11 snv_101b November 2008
mps@panacea:~$ pfexec su -
Sun Microsystems Inc. SunOS 5.11 snv_101b November 2008
root@panacea:~#
WARNING! - Important Safety Tips
‣All the following commands I will use are done using the root user.
‣If you are not comfortable using root directly, then DO NOT TRY THIS.
‣If you are not 100% comfortable with what you are doing, DO NOT TRY THIS!
‣Use common sense, HAVE A BACKUP/RECOVERY PLAN BEFORE ATTEMPTING THIS!
‣Unless you really know what you are doing and are comfortable with everything here, DO NOT ATTEMPT THIS ON PRODUCTION SYSTEMS.
‣LAST, I CLAIM NO RESPONSIBILITY FOR YOUR ACTIONS. IF YOU SCREW UP, YOU ARE ON YOUR OWN, SORRY.
Initial System Configuration
After setting up the system, the partitions and zpool look like this:
root@panacea:~# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
rpool 7.44G 2.63G 4.81G 35% ONLINE -
root@panacea:~# zpool status
pool: rpool
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
c4t0d0s0 ONLINE 0 0 0
errors: No known data errors
Since I used the SATA controller and SATA virtual disks in the VirtualBox, we are using controller number 4. The boot disk is now /dev/rdsk/c0t0d0p0 for the entire physical disk. Partition number 1 is used by Open Solaris to create the disk slices.
Using fdisk, we can also see in the listing from fdisk that we are only using a small portion of the physical disk:
root@panacea:~# fdisk -W - /dev/rdsk/c4t0d0p0
* /dev/rdsk/c4t0d0p0 default fdisk table
* Dimensions:
* 512 bytes/sector
* 63 sectors/track
* 255 tracks/cylinder
* 13054 cylinders
*
* systid:
* 1: DOSOS12
* 2: PCIXOS
*
* ==> NOTE: Many partition types removed here. The list is long.
*
* 190: X86BOOT
* 191: SUNIXOS2
* 238: EFI_PMBR
* 239: EFI_FS
*
* Id Act Bhead Bsect Bcyl Ehead Esect Ecyl Rsect Numsect
191 128 0 1 1 254 63 1023 16065 16762880
So now we can see that the actual partition is 1023 cylinders when there are really 13054 cylinders available on the disk.
OpenSolaris has “sliced” this disk into several partitions:
root@panacea:~# prtvtoc /dev/dsk/c4t0d0s2
* /dev/dsk/c4t0d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 63 sectors/track
* 255 tracks/cylinder
* 16065 sectors/cylinder
* 1043 cylinders
* 1041 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* Unallocated space:
* First Sector Last
* Sector Count Sector
* 0 1060290 1060289
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 2 00 1060290 15663375 16723664
1 3 01 16065 1044225 1060289
2 5 01 0 16723665 16723664
8 1 01 0 16065 16064
Of particular note here is slice(partition) 8 which is the MBR for Solaris. Partitions with number greater than 7 are not usable by the OS. Notice here, also, that our swap partition, slice 1 is 512MB (1044225 * 512 = 534643200). These settings are all the defaults set up by the OpenSolaris install.
Typically, it would be at this point in your installation you would want to attach your second disk as a mirror, but since we have done a minimal install using only a small portion of the disk, we want to do a few extra steps.
Resizing/Creating the Partitions and Moving Solaris.
So, now we turn our attention to the second disk. We’re going to partition this disk to the sizes we would like. In this case I would like to have 2GB swap, a Solaris OS partition for the rpool of 20GB and the remaining disk (about 78GB) to be available for another zpool (there it is the “free hog”). So, the layout I’d like to have will be:
‣s0 20GB rpool/OS Slice
‣s1 2GB swap
‣s2 Entire disk
‣s3 78GB naspool/”Free hog”
Ok, so now, how do we do it? Back to the command line. We’ll use the format utility, which also gives us access to fdisk as well. The second disk has no partition table on it yet because it’s never been used or accessed. If you purchase a disk at a retail outlet, you may have a factory installed partition table on it. This can be easily cleared out and a new one put in place. We’ll do that in a bit once we finish up with the second disk, or /dev/dsk/c4t1d0p0 .
root@panacea:~# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c4t0d0 <DEFAULT cyl 1041 alt 2 hd 255 sec 63>
/pci@0,0/pci8086,2829@d/disk@0,0
1. c4t1d0 <DEFAULT cyl 13052 alt 2 hd 255 sec 63>
/pci@0,0/pci8086,2829@d/disk@1,0
Specify disk (enter its number): 1
selecting c4t1d0
[disk formatted]
No fdisk solaris partition found.
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
fdisk - run the fdisk program
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd> - execute <cmd>, then return
quit
format> fd
No fdisk table exists. The default partition for the disk is:
a 100% "SOLARIS System" partition
Type "y" to accept the default partition, otherwise type "n" to edit the
partition table.
y
format> pa
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
!<cmd> - execute <cmd>, then return
quit
partition> pr
Current partition table (original):
Total disk cylinders available: 13051 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 0 (0/0/0) 0
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0 - 13050 99.98GB (13051/0/0) 209664315
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
8 boot wu 0 - 0 7.84MB (1/0/0) 16065
9 unassigned wm 0 0 (0/0/0) 0
partition>
So that’s all there is to it if we wanted to use this disk for a plain ZFS pool. We’d simply add the whole disk c4t1d0 to a new zpool. However, I need to make partitions so we’ll stay in the format utility for now. Also, in format, you can abbreviate commands using the first few letters which make that command unique, like fd for fdisk, pa for partition and pr for print.
Here we will use the modify command to modify a predefined partition table. This will give us the option to select “All Free Hog.” Pretty much go with the defaults for all the questions except for the size of partition s0 and s1. There’s no need to calculate starting and number of cylinders because format takes care of this for us. Pretty simple?
partition> mod
Select partitioning base:
0. Current partition table (original)
1. All Free Hog
Choose base (enter number) [0]? 1
Part Tag Flag Cylinders Size Blocks
0 root wm 0 0 (0/0/0) 0
1 swap wu 0 0 (0/0/0) 0
2 backup wu 0 - 13050 99.98GB (13051/0/0) 209664315
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 usr wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
8 boot wu 0 - 0 7.84MB (1/0/0) 16065
9 alternates wm 0 0 (0/0/0) 0
Do you wish to continue creating a new partition
table based on above table[yes]?
Free Hog partition[6]?
Enter size of partition '0' [0b, 0c, 0.00mb, 0.00gb]: 20gb
Enter size of partition '1' [0b, 0c, 0.00mb, 0.00gb]: 2gb
Enter size of partition '3' [0b, 0c, 0.00mb, 0.00gb]:
Enter size of partition '4' [0b, 0c, 0.00mb, 0.00gb]:
Enter size of partition '5' [0b, 0c, 0.00mb, 0.00gb]:
Enter size of partition '7' [0b, 0c, 0.00mb, 0.00gb]:
Part Tag Flag Cylinders Size Blocks
0 root wm 1 - 2611 20.00GB (2611/0/0) 41945715
1 swap wu 2612 - 2873 2.01GB (262/0/0) 4209030
2 backup wu 0 - 13050 99.98GB (13051/0/0) 209664315
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 usr wm 2874 - 13050 77.96GB (10177/0/0) 163493505
7 unassigned wm 0 0 (0/0/0) 0
8 boot wu 0 - 0 7.84MB (1/0/0) 16065
9 alternates wm 0 0 (0/0/0) 0
Okay to make this the current partition table[yes]?
Enter table name (remember quotes): "My new rpool disk"
Ready to label disk, continue? yes
partition> q
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
fdisk - run the fdisk program
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd> - execute <cmd>, then return
quit
format> q
root@panacea:~# prtvtoc /dev/dsk/c4t1d0s2
* /dev/dsk/c4t1d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 63 sectors/track
* 255 tracks/cylinder
* 16065 sectors/cylinder
* 13053 cylinders
* 13051 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* Unallocated space:
* First Sector Last
* Sector Count Sector
* 0 16065 16064
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 0 00 16065 41945715 41961779
1 0 00 41961780 4209030 46170809
2 5 01 0 209664315 209664314
6 0 00 46170810 163493505 209664314
8 1 01 0 16065 16064
root@panacea:~#
The prtvtoc command just verified everything was in place correctly.
Now we’re ready to move the OS partition over to c4t1d0s0. To do this, we will use zpool replace to replace the smaller 6GB partition with the new 20GB partition
root@panacea:~# zpool replace -f rpool c4t0d0s0 c4t1d0s0
Please be sure to invoke installgrub(1M) to make 'c4t1d0s0' bootable.
ZFS accepts this disk as a replacement and begin moving the data over. It also reminds us to make this disk bootable, which we would have to do anyway to use it as an effective bootable mirror. We can also now check the status and we see the 20GB disk was added as a replacement and is being re-silvered.
root@panacea:~# zpool status
pool: rpool
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scrub: resilver in progress for 0h1m, 4.10% done, 0h25m to go
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
replacing ONLINE 0 0 0
c4t0d0s0 ONLINE 0 0 0
c4t1d0s0 ONLINE 0 0 0 108M resilvered
errors: No known data errors
The re-silver to the new device only took 4 minutes, and very impressive. The zpool command now reports the new zpool is 19.9GB in size. Here it is in the completed state:
root@panacea:~# zpool status
pool: rpool
state: ONLINE
scrub: resilver completed after 0h4m with 0 errors on Sun May 10 23:12:51 2009
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
c4t1d0s0 ONLINE 0 0 0 2.64G resilvered
errors: No known data errors
root@panacea:~# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
rpool 19.9G 2.64G 17.3G 13% ONLINE -
Perform the installgrub to make this disk bootable.
root@panacea:~# /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 \
/dev/rdsk/c4t1d0s0
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 267 sectors starting at 50 (abs 16115)
We now need to relocate our swap to the new swap device on /dev/dsk/c4t1d0s1 and remove the original swap device before we re-partition the original disk as a mirror.
root@panacea:~# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c4t0d0s1 50,1 8 1044216 1014416
root@panacea:~# swap -a /dev/dsk/c4t1d0s1
root@panacea:~# swap -d /dev/dsk/c4t0d0s1
root@panacea:~# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c4t1d0s1 50,65 8 4194288 4194288
Now the new swap is in place, but we need to add an entry to /etc/vfstab for it so it is used next time we boot. Take a look at your /etc/vfstab and add an entry for the new device after the entry for the original device. My new /etc/vfstab now looks like this:
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
/devices - /devices devfs - no -
/proc - /proc proc - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
sharefs - /etc/dfs/sharetab sharefs - no -
fd - /dev/fd fd - no -
swap - /tmp tmpfs - yes -
/dev/dsk/c4t0d0s1 - - swap - no -
/dev/dsk/c4t1d0s1 - - swap - no -
Next we need to create an identical set of fdisk partitions on the original disk and lay down the OpenSolaris VTOC. This is fairly simple to do using fdisk, prtvtoc, and fmthard.
root@panacea:~# fdisk -W - /dev/rdsk/c4t1d0p0 > /tmp/fdisk.par
root@panacea:~# fdisk -F /tmp/fdisk.par /dev/rdsk/c4t0d0p0
root@panacea:~# fdisk -W - /dev/rdsk/c4t1d0p0
* /dev/rdsk/c4t1d0p0 default fdisk table
* Dimensions:
* 512 bytes/sector
* 63 sectors/track
* 255 tracks/cylinder
* 13054 cylinders
*
* systid:
* 1: DOSOS12
* 2: PCIXOS
*
* ==> NOTE: Many partition types removed here. The list is long.
*
* 190: X86BOOT
* 191: SUNIXOS2
* 238: EFI_PMBR
* 239: EFI_FS
*
* Id Act Bhead Bsect Bcyl Ehead Esect Ecyl Rsect Numsect
191 128 0 1 1 254 63 1023 16065 209696445
So, we wrote out the fdisk partition information from the physical disk c4t1d0p0 and put it on the physical disk c4t1d0p0. Note these are the physical devices and not slices, therefore they use “p” in the device name.
Now do the VTOC, but we don’t have to write to a temporary file.
root@panacea:~# prtvtoc /dev/rdsk/c4t1d0s2 | fmthard -s - /dev/rdsk/c4t0d0s2
fmthard: New volume table of contents now in place.
root@panacea:~# prtvtoc /dev/dsk/c4t0d0s2
* /dev/dsk/c4t0d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 63 sectors/track
* 255 tracks/cylinder
* 16065 sectors/cylinder
* 13053 cylinders
* 13051 accessible cylinders
*
* Flags:
* 1: unmountable
* 10: read-only
*
* Unallocated space:
* First Sector Last
* Sector Count Sector
* 0 16065 16064
*
* First Sector Last
* Partition Tag Flags Sector Count Sector Mount Directory
0 0 00 16065 41945715 41961779
1 0 00 41961780 4209030 46170809
2 5 01 0 209664315 209664314
6 0 00 46170810 163493505 209664314
8 1 01 0 16065 16064
Setup the newly partitioned c4t0d0s0 as a mirror for rpool. This will also involve doing a new installgrub to make the disk bootable. and then lastly check the status of the zpool.
root@panacea:~# zpool attach -f rpool c4t1d0s0 c4t0d0s0
Please be sure to invoke installgrub(1M) to make 'c4t0d0s0' bootable.
root@panacea:~# /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 \
/dev/rdsk/c4t0d0s0
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 267 sectors starting at 50 (abs 16115)
root@panacea:~# zpool status
pool: rpool
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scrub: resilver in progress for 0h0m, 5.00% done, 0h13m to go
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
mirror ONLINE 0 0 0
c4t1d0s0 ONLINE 0 0 0 2.87M resilvered
c4t0d0s0 ONLINE 0 0 0 133M resilvered
errors: No known data errors
This is going to take a few minutes, so now would be a good time to create the new zpool for naspool which will be our NAS pool which we can extend with concatenated mirrors. We will create the zpool with c4t0d0s6 and attach c4t1d0s6 which were the “free hog” partitions we created earlier. Then create a mount point for this zpool called /export/nas.
root@panacea:~# zpool create -f naspool c4t0d0s6
root@panacea:~# zpool attach -f naspool c4t0d0s6 c4t1d0s6
root@panacea:~# zfs create naspool/export
root@panacea:~# zfs set mountpoint=/export/nas naspool/export
root@panacea:~# zpool status
pool: naspool
state: ONLINE
scrub: resilver completed after 0h0m with 0 errors on Mon May 11 00:38:14 2009
config:
NAME STATE READ WRITE CKSUM
naspool ONLINE 0 0 0
mirror ONLINE 0 0 0
c4t0d0s6 ONLINE 0 0 0 44K resilvered
c4t1d0s6 ONLINE 0 0 0 70.5K resilvered
errors: No known data errors
pool: rpool
state: ONLINE
scrub: resilver completed after 0h5m with 0 errors on Mon May 11 00:29:50 2009
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
mirror ONLINE 0 0 0
c4t1d0s0 ONLINE 0 0 0 24.1M resilvered
c4t0d0s0 ONLINE 0 0 0 2.64G resilvered
errors: No known data errors
root@panacea:~# zfs list
NAME USED AVAIL REFER MOUNTPOINT
naspool 116K 76.3G 18K /naspool
naspool/export 18K 76.3G 18K /export/nas
rpool 2.64G 17.0G 72K /rpool
rpool/ROOT 2.39G 17.0G 18K legacy
rpool/ROOT/opensolaris 2.39G 17.0G 2.26G /
rpool/dump 256M 17.0G 256M -
rpool/export 626K 17.0G 21K /export
rpool/export/home 604K 17.0G 19K /export/home
rpool/export/home/mps 586K 17.0G 586K /export/home/mps
All done. Next to reboot with two new virtual disks and add them as concatenated mirrors to the zpool naspool.
root@panacea:~# init 6
After the reboot, we will see both swap devices online and swap -l will confirm this:
root@panacea:~# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c4t0d0s1 50,1 8 4194288 4194288
/dev/dsk/c4t1d0s1 50,65 8 4194288 4194288
I’ve added two new 100GB disks which will be used to extend the zpool naspool. I did this inside VrtualBox by creating two new 100GB disks and connecting them to the SATA controller like I did with the original two disks. The disks do not have any fdisk information on them, so we will need to put it on there. Luckily fdisk on OpenSolaris has a “-B” option to fdisk the entire disk as a single Solaris2 partition. The final step is to attach the two new disks c4t2d0 and c4t3d0 to as mirrored concatenated stripes to the zpool naspool.
root@panacea:~# fdisk -B /dev/rdsk/c4t2d0p0
root@panacea:~# fdisk -B /dev/rdsk/c4t3d0p0
root@panacea:~# fdisk -W - /dev/rdsk/c4t2d0p0
root@panacea:~# fdisk -W - /dev/rdsk/c4t2d0p0
* /dev/rdsk/c4t2d0p0 default fdisk table
* Dimensions:
* 512 bytes/sector
* 63 sectors/track
* 255 tracks/cylinder
* 13054 cylinders
*
* systid:
* 1: DOSOS12
* 2: PCIXOS
*
* ==> NOTE: Many partition types removed here. The list is long.
*
* 190: X86BOOT
* 191: SUNIXOS2
* 238: EFI_PMBR
* 239: EFI_FS
*
* Id Act Bhead Bsect Bcyl Ehead Esect Ecyl Rsect Numsect
191 128 0 1 1 254 63 1023 16065 209696445
root@panacea:~# zpool add naspool mirror c4t2d0 c4t3d0
root@panacea:~# zfs list
NAME USED AVAIL REFER MOUNTPOINT
naspool 124K 174G 18K /naspool
naspool/export 18K 174G 18K /export/nas
rpool 2.64G 17.0G 72K /rpool
rpool/ROOT 2.39G 17.0G 18K legacy
rpool/ROOT/opensolaris 2.39G 17.0G 2.26G /
rpool/dump 256M 17.0G 256M -
rpool/export 630K 17.0G 21K /export
rpool/export/home 608K 17.0G 19K /export/home
rpool/export/home/mps 590K 17.0G 590K /export/home/mps
Notice that when we did the zpool add, we didn’t have to specify a slice. ZFS is smart enough to examine the device and partition it as required. Also notice we’ve added 100GB to the zpool naspool.
The new zpool status (after both pools scrubbed for good measure) looks like this:
root@panacea:~# zpool status
pool: naspool
state: ONLINE
scrub: scrub completed after 0h0m with 0 errors on Mon May 11 01:42:40 2009
config:
NAME STATE READ WRITE CKSUM
naspool ONLINE 0 0 0
mirror ONLINE 0 0 0
c4t0d0s6 ONLINE 0 0 0
c4t1d0s6 ONLINE 0 0 0
mirror ONLINE 0 0 0
c4t2d0 ONLINE 0 0 0
c4t3d0 ONLINE 0 0 0
errors: No known data errors
pool: rpool
state: ONLINE
scrub: scrub completed after 0h3m with 0 errors on Mon May 11 01:59:49 2009
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
mirror ONLINE 0 0 0
c4t1d0s0 ONLINE 0 0 0
c4t0d0s0 ONLINE 0 0 0
errors: No known data errors
All done, and now we can add pairs of additional disks of varying sizes to this mirrored stripe.
Summary
So here’s a high level overview of the step-by-step process we just went through.
‣Construct a “machine” in VirtualBox, it’s fun and it’s free.
•2x100GB SATA virtual hard disks (or possibly 4, will save a step or two later)
•512MB RAM
•Bridged ethernet adapter, though I use this only so I can ssh into the machine from a terminal session.
‣Get the latest OpenSolaris media and mount it to the virtual machine CD-ROM.
‣Install on a single disk using the minimum - 8GB partition (I will assume “target 0”).
‣Log into the machine and using a terminal window become root using: pfexec su -
‣You are now executing commands as root. BE VERY CAREFUL FROM THIS POINT ON.
‣At the command prompt type: format
•Using format select “target 1”
•Use fdisk within format to create a 100% Solaris2 partition.
•Partition the disk to your preference. I used:
•Modify a partition table using: mod
-Select the “All Free Hog” option.
-Select which partition is to be the “Free Hog.”
-Setup all other partitions by size. I used:
Partition ‘0’ - 20GB Base OS Install
Partition ‘1’ - 2GB Swap
-Name the partition table.
-Label the disk.
•Quit format utility.
‣“Replace” the initial install device with your resized device: zpool replace -f rpool c4t0d0s0 c4t1d0s0
‣Make the disk bootable: /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4t1d0s0
‣Add the new swap device: swap -a /dev/dsk/c4t1d0s1
‣Remove the old swap device: swap -d /dev/dsk/c4t0d0s1
‣Redo the partitioning tables on the original disk. (NOTE: When using fdisk the devices are not “slices,” the “p” in the device name is intentional)
•Create a partition file from the new disk: fdisk -W - /dev/rdsk/c4t1d0p0 > /tmp/fdisk.par
•Re-partition the original disk: fdisk -F /tmp/fdisk.par /dev/rdsk/c4t0d0p0
•OpenSolaris partition table (slices): prtvtoc /dev/rdsk/c4t1d0s2 | fmthard -s - /dev/rdsk/c4t0d0s2
‣Attach the new mirror device from the original disk: zpool attach -f rpool c4t1d0s0 c4t0d0s0
‣Make the new(original) disk bootable: /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4t1d0s0
‣Make sure there are entries in /etc/vfstab for both swap devices: /dev/dsk/c4t1d0s1 and /dev/dsk/c4t1d0s1
‣Create the new zpool for NAS storage: zpool create -f naspool c4t0d0s6
‣Mirror it: zpool attach -f naspool c4t0d0s6 c4t1d0s6
‣Create a ZFS export filesystem: zfs create naspool/export
‣Set the mount point for the export: zfs set mountpoint=/export/nas naspool/export
‣Add two new 100GB disks to the virtual host.
‣Reboot OpenSolaris: init 6
‣Use fdisk to setup the new disks as 100% Solaris2 partitions.
•fdisk -B /dev/rdsk/c4t2d0p0
•fdisk -B /dev/rdsk/c4t3d0p0
‣Add the two new disks as a concatenated mirror to zpool naspool: zpool add naspool mirror c4t2d0 c4t3d0
You’re done.
Sunday, 10 May 2009