Installing FreeBSD on a GPT disk


Synopsis:

These notes describe the general process for manually installing FreeBSD onto a GPT-partitioned hard disk.

Prerequisites:

Process:

  1. Boot from the FreeBSD install DVD or USB stick and run the Fixit environment.
  2. Create new partition table on ad0 using GPT scheme:
  3. # gpart create -s GPT ad0
  4. Add 'freebsd-boot' partition to contain boot code ('-s' argument specifies partition size in 512 byte blocks):
  5. # gpart add -t freebsd-boot -s 128 ad0
  6. Write Protective MBR to sector 0 of disk and gptboot code into freebsd-boot partition
  7. # gpart bootcode -b /dist/boot/pmbr -p /dist/boot/gptboot -i 1 ad0
  8. Add 'freebsd-swap' partition:
  9. # gpart add -t freebsd-swap -s 8388608 ad0
  10. Add appropriately sized 'freebsd-ufs' partitions for /, /var, /usr and /home filesystems (I use swap-based tmpfs for /tmp)
  11. # gpart add -t freebsd-ufs -s 2097152 ad0
    # gpart add -t freebsd-ufs -s 2097152 ad0
    # gpart add -t freebsd-ufs -s 41942040 ad0
    # gpart add -t freebsd-ufs ad0
    
  12. List our partition table so far
  13. # gpart show ad0
    =>       34  312581741  ad0  GPT  (149G)
             34        128    1  freebsd-boot  (64K)
            162    8388608    2  freebsd-swap  (4.0G)
        8388770    2097152    3  freebsd-ufs  (1.0G)
       10485922    2097152    4  freebsd-ufs  (1.0G)
       12583074   41942040    5  freebsd-ufs  (20G)
       54525114  258056661    6  freebsd-ufs  (123G)
    
  14. Format freebsd-ufs partitions (p3 will be the root partition so softupdates are not enabled with '-U')
  15. # newfs ad0p3
    # newfs -U ad0p4
    # newfs -U ad0p5
    # newfs -U ad0p6
    
  16. Mount partitions under /mnt:
  17. # mount /dev/ad0p3 /mnt
    # cd /mnt
    # mkdir var usr home
    # mount /dev/ad0p4 /mnt/var
    # mount /dev/ad0p5 /mnt/usr
    # mount /dev/ad0p6 /mnt/home
    
  18. Install FreeBSD distribution to mounted filesystems:
  19. # export DESTDIR=/mnt
    # cd /dist/8.1-RELEASE
    # for dir in base catpages dict doc info lib32 manpages; do (cd $dir; ./install.sh); done
    # cd kernels
    # ./install.sh GENERIC
    # cd src
    # ./install.sh all
    
  20. Copy GENERIC kernel to expected location:
  21. # cd /mnt/boot
    # rmdir kernel
    # cp -Rp GENERIC kernel
    
  22. Create a new fstab
  23. # cd /mnt/etc
    # vi fstab
    
    /dev/ad0p3      /       ufs     rw      1       1
    /dev/ad0p4      /var    ufs     rw      2       2
    /dev/ad0p5      /usr    ufs     rw      2       2
    /dev/ad0p6      /home   ufs     rw      2       2
    /dev/ad0p2      none    swap    sw      0       0
    
  24. The hard disk now contains a minimal, unconfigured FreeBSD installation and should be bootable. Exit the Fixit environment, exit Sysinstall and reboot. Remove the CD while the machine resets.
  25. FreeBSD should boot up cleanly. Perform basic configuration steps:
    • Set root's password
    • Create /etc/rc.conf, setting hostname, network interface configuration, sshd_enable, etc
    • Set timezone by copying appropriate timezone file from /usr/share/zoneinfo/*/ to /etc/localtime
    • Create non-root user account

虹光大成就-密教灌頂(一)