OpenSolaris

You are not signed in. Sign in or register.

Manual Setup to boot ZFS on x86 (a script version is here).

Note: If your system is running on a zfs root based on the old mountroot setup, you may manually transition to the new bits by following this.
  1. ZFS Boot bits is available in snv_62.

  1. Prepare the disk for a ZFS rootpool. A rootpool can be a single disk device, or a device slice, or in a mirrored configuration. If you use a whole disk for a rootpool, you must use a slice notation (e.g. c0d0s0) so that it is labeled with an SMI label.

  1. Create a ZFS rootpool, a root filesystem, mount the root filesystem on /zfsroot, and update /etc/vfstab to mount /zfsroot upon reboot. Through out the Instruction examples, we use 'rootpool' for the pool name created on 'c0d0s3', and 'rootpool/rootfs' as the ZFS default boot filesystem name.

    # zpool create rootpool c0d0s3
    # zfs create rootpool/rootfs
    # zfs set mountpoint=legacy rootpool/rootfs
    # mkdir /zfsroot
    # mount -F zfs rootpool/rootfs /zfsroot
    

    add this entry in /etc/vfstab:

    rootpool/rootfs - /zfsroot zfs – yes -

  1. Populate the UFS root content to the ZFS root filesystem:

    • Copy all of the files in the UFS root filesystem to the newly created ZFS root filesystem. The following command does this without crossing mountpoints. This command will take on the order of 30 minutes, give or take. Note, this will not cross mountpoints, if /usr, /var, or other filesystems are on other mountpoints, they will need to be copied over following this command.

      # cd /
      # find . -xdev -depth -print | cpio -pvdm /zfsroot
      
    • The directory structure for several auto generated filesystems need to be created. Run this script to create them.

    • Populate the /devices filesystem. /devices is a devfs pseudo filesystems which sits on top of a ufs backing store. When a system is booted, /devices is mounted on top of this backing store and hides the underlying ufs backing store. Same to the /dev filesystem. To get at the underlying files, do the following:

      # mount -F lofs -o nosub / /mnt
      # (cd /mnt; tar cvf - devices dev ) | (cd /zfsroot; tar xvf -)
      # umount /mnt
      
  1. Complete the ZFS root filesystem setup:

    • If you would like to have your UFS root filesystem mounted while booted of ZFS, make a directory named "ufsroot" on your ZFS filesystem. This will be used to mount your UFS root filesystem when booted off of ZFS.

      # mkdir /zfsroot/ufsroot
      
    • Edit /zfsroot/etc/vfstab to modify mount entries for your new ZFS root and UFS root. Make sure your UFS root is not mounted on “/”. You should already have a swap slice set aside. The added entries should look similar to the following:

      rootpool/rootfs - / zfs - no -
      /dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 /ufsroot ufs - yes -
      
    • Set this filesystem to be the default ZFS boot filesystem:

      # zpool set bootfs=rootpool/rootfs rootpool
      
    • Edit /zfsroot/boot/solaris/filelist.ramdisk to include “etc/zfs/zpool.cache”, then update the boot archive for the ZFS root:

      (add "etc/zfs/zpool.cache" into filelist.ramdisk)
      # /usr/sbin/bootadm update-archive -R /zfsroot
      
  1. Setup GRUB to boot off of the ZFS root filesystem:

    • Copy /zfsroot/boot/grub/menu.lst to your top level filesystem since that is where GRUB will read the menu.lst from:

      # mkdir -p /rootpool/boot/grub (assuming rootpool is mounted on /rootpool)
      # cp /zfsroot/boot/grub/menu.lst /rootpool/boot/grub
      
    • Edit /rootpool/boot/grub/menu.lst to include an entry for this ZFS boot filesystem by appending '-B $ZFS-BOOTFS' after the unix program. Your entry should look something like this:

      title Solaris ZFS
      kernel$ /platform/i86pc/kernel/unix -B $ZFS-BOOTFS,console=ttya
      module$ /platform/i86pc/boot_archive
      

      This entry boots from the default ZFS boot filesystem 'rootpool/rootfs' defined in the 'bootfs' pool property of the 'rootpool' assuming rootpool is the default boot device.

      If rootpool is not the default boot device, you can use 'root' command to redirect the boot device to the ZFS rootpool. Your entry could look something like this, assuming the UFS root is on slice 0 (default boot device) and ZFS root is on slice 3 of c0d0:

      title Solaris ZFS
      root (hd0,0,d)
      kernel$ /platform/i86pc/kernel/unix -B $ZFS-BOOTFS,console=ttya
      module$ /platform/i86pc/boot_archive
      

      This entry boots from the default ZFS boot filesystem 'rootpool/rootfs' defined in the 'bootfs' pool property of the 'rootpool' on c0d0s3.

      The root entry has the following format (hdx,x,x) where the first entry in the tuple is the disk identifier, the second entry is the partition number (0-3), and the third entry is the slice number (a-h), where a is slice 0 and h is slice 7. The root command is not needed if your boot environment is on the disk slice given to the installgrub command. See step #7 for more information.

      There can be multiple bootable filesystems in a single pool. You can override the default boot filesystem name by using a GRUB command 'bootfs <pool/fs>'. Put it before the kernel command. Example:

      title Solaris ZFS
      bootfs rootpool/rootfs2
      kernel$ /platform/i86pc/kernel/unix -B $ZFS-BOOTFS,console=ttya
      module$ /platform/i86pc/boot_archive
      

      For the failsafe mode, use the following entry in menu.lst:

      kernel /boot/platform/i86pc/kernel/unix -B console=ttya
      module /boot/x86.miniroot
      
  1. Install the new bootloader. The grub bootloader is installed via a utility called installgrub(1M). It takes, as its parameters, a pointer to stage1 and stage2 (available in your newly bfu'd filesystem at /zfsroot/boot/grub/) and the raw device containing a boot environment. Installgrub will install stage1 and stage2 on the boot area of a disk partition. The raw device indicates where the root is. The examples below show how to installgrub on a system which has the ZFS rootpool.

    • ZFS rootpool (c0d0s3) and UFS root (c0d0s0) are on the same disk:

      # installgrub /zfsroot/boot/grub/stage1 /zfsroot/boot/grub/stage2 /dev/rdsk/c0d0s3
      

      Then, the following entry will boot off the default boot filesystem from the rootpool on c0d0s3:

      title Solaris Default-ZFS
      kernel$ /platform/i86pc/kernel/$ISADIR/unix -B $ZFS-BOOTFS,console=ttya
      module$ /platform/i86pc/boot_archive
      
    • ZFS rootpool (c1d0s0) and UFS root (c0d0s0) are on a different disk:

      # installgrub /zfsroot/boot/grub/stage1 /zfsroot/boot/grub/stage2 /dev/rdsk/c1d0s0
      

      Change the boot device in BIOS to be c1d0, then the same Default-ZFS menu.lst entry will boot off the default bootfs from the rootpool on c1d0s0:

  1. Reboot. Remember to select your ZFS Boot environment from the GRUB menu or change the boot device in the BIOS.
    (Note: Do Not export the rootpool before rebooting.)