Professional Documents
Culture Documents
BIOS limitations
• 16-bit processor mode
• 1MB addressable space
UEFI advantages
• UEFI v2.3.1 in April 2011
• Disk device compatibility (GUID Partition Table)
• Processor compatibility (x86, x64, ARM)
2
Computer Center, CS, NCTU
GUID Partition Table – (1)
GPT
• Maximum capacity: 8ZBytes (273 bytes)
• Used on some BIOS system
3
Computer Center, CS, NCTU
GUID Partition Table – (2)
GPT
• LBA 0: Legacy MBR
• LBA 1: GPT Header
• LBA 2~33: Partition Entries
128 partitions
• LBA 34~: Partitions
4
Computer Center, CS, NCTU
GUID Partition Table – (3)
5
Computer Center, CS, NCTU
GUID Partition Table – (4)
7
Computer Center, CS, NCTU
GUID Partition Table – (6)
8
Computer Center, CS, NCTU
GUID Partition Table – (7)
freebsd-boot 83BD6B9D-7F41-11DC-BE0B-001560B84F0F
freebsd 516E7CB4-6ECF-11D6-8FF8-00022D09712B
freebsd-swap 516E7CB5-6ECF-11D6-8FF8-00022D09712B
freebsd-ufs 516E7CB6-6ECF-11D6-8FF8-00022D09712B
freebsd-vinum 516E7CB8-6ECF-11D6-8FF8-00022D09712B
freebsd-zfs 516E7CBA-6ECF-11D6-8FF8-00022D09712B
9
Computer Center, CS, NCTU
FreeBSD – gpart (1)
gpart(8)
• Control utility for the disk partitioning GEOM class (ad0)
GEOM_PART_MBR (ad0 ad0s1)
– GEOM_PART_BSD (ad0s1 ad0s1a)
GEOM_PART_GPT (ad0 ad0p1)
10
Computer Center, CS, NCTU
FreeBSD – gpart (2)
gpart(8)
• gpart add -t type [ … ] ad0
type: freebsd-boot, freebsd-swap, freebsd-ufs, freebsd-zfs, freebsd
-b start
-s size
-a alignment: -a 4k for 4K-sector HDD
-i index
-l label: used on partitioning schemes that support partition labels
• gpart delete –i index ad0
• gpart show [ -l | -r ] [ -p ] ad0
-l: print partition labels instead of partition type
-r: show GUID
-p: show provider names instead of partition indexes
11
Computer Center, CS, NCTU
FreeBSD – gpart (3)
gpart(8)
• gpart bootcode [ -b bootcode ] [ -p partcode -i index ] ad0
-b: embed bootstrap code into the partitioning scheme’s metadata
-p: write bootstrap code into a partition
Bootstraping for MBR scheme
– /boot/mbr or /boot/boot0 in partition table’s metadata
» /boot/mbr searches partition with active attribute
» /boot/boot0 has a boot manager
– /boot/boot in BSD partition table’s metadata
Bootstraping for GPT scheme
– /boot/pmbr in the first disk sector (Protective MBR)
» /boot/pmbr searches the freebsd-boot partition
– /boot/gptboot or /boot/gptzfsboot in freebsd-boot partition
» /boot/gptboot searches the freebsd-ufs partition to run /boot/loader
» /boot/gptzfsboot searches the freebsd-zfs partition to run /boot/zfsloader
12
Computer Center, CS, NCTU
FreeBSD – gpart (4)
gpart(8)
• gpart modify -i index [ -l label ] [ -t type ] ad0
• gpart resize -i index [ -a alignment ] [ -s size ] ad0
• gpart { set | unset } -a attrib -i index ad0
Set "Active" for MBR scheme
– gpart set -a active –i 1 ad0
• gpart { backup | restore } ad0
• gpart recover ad0
GPT-only
• gpart { command … -f x | commit | undo } ad0
13
Computer Center, CS, NCTU
Root On ZFS – (1)
Root On ZFS
• Using MBR disk
UFS /boot
FreeBSD-ZFS partition in a FreeBSD MBR slice
– dd if=/mnt2/boot/zfsboot of=/dev/ad0s3 count=1
– dd if=/mnt2/boot/zfsboot of=/dev/ad0s3a skip=1 seek=1024
FreeBSD MBR slice
– Fails to boot
• Using GPT disk
Disadvantage
– Can’t dual boot using FreeBSD commercial bootcode
– Using GPT-aware grub setup and hybrid GPT/MBR
16
Computer Center, CS, NCTU
Root On ZFS – (4)
Finish install
• Create /etc/fstab
swap
• Set mount points for zfs filesystems
zfs set mountpoint=blah zroot/blah
Alternatively, you can specify these in /etc/fstab
18
Computer Center, CS, NCTU
Root On ZFS – (6)
gpart show
# gpart show
=> 34 83886013 ada0 GPT (40G)
34 128 1 freebsd-boot (64k)
162 4194304 2 freebsd-swap (2.0G)
4194466 79691581 3 freebsd-zfs (38G)
swapinfo
# swapinfo
Device 1K-blocks Used Avail Capacity
/dev/gpt/swap0 2097152 0 2097152 0%
19
Computer Center, CS, NCTU
Root On ZFS – (7)
zpool status -v
# zpool status -v
pool: zroot
state: ONLINE
scan: none requested
config:
20
Computer Center, CS, NCTU
Root On ZFS – (8)
zfs list
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
zroot 657M 36.5G 344M legacy
zroot/home 31K 36.5G 31K legacy
zroot/tmp 36K 36.5G 36K /tmp
zroot/usr 311M 36.5G 311M /usr
zroot/usr/ports 95K 36.5G 33K /usr/ports
zroot/usr/ports/distfiles 31K 36.5G 31K /usr/ports/distfiles
zroot/usr/ports/packages 31K 36.5G 31K /usr/ports/packages
zroot/usr/src 31K 36.5G 31K /usr/src
zroot/var 461K 36.5G 126K /var
zroot/var/crash 31.5K 36.5G 31.5K /var/crash
zroot/var/db 116K 36.5G 85K /var/db
zroot/var/db/pkg 31K 36.5G 31K /var/db/pkg
zroot/var/empty 31K 36.5G 31K /var/empty
zroot/var/log 45K 36.5G 45K /var/log
zroot/var/mail 31K 36.5G 31K /var/mail
zroot/var/run 48.5K 36.5G 48.5K /var/run
zroot/var/tmp 32K 36.5G 32K /var/tmp
21
Computer Center, CS, NCTU
Root On ZFS – (9)
mount
# mount
zroot on / (zfs, local, noatime)
devfs on /dev (devfs, local, multilabel)
zroot/tmp on /tmp (zfs, local, nosuid)
zroot/usr on /usr (zfs, local, noatime)
zroot/usr/ports on /usr/ports (zfs, local, noatime, nosuid)
zroot/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, noatime, noexec, nosuid)
zroot/usr/ports/packages on /usr/ports/packages (zfs, local, noatime, noexec, nosuid)
zroot/usr/src on /usr/src (zfs, local, noatime, noexec, nosuid)
zroot/var on /var (zfs, local, noatime)
zroot/var/crash on /var/crash (zfs, local, noatime, noexec, nosuid)
zroot/var/db on /var/db (zfs, local, noatime, noexec, nosuid)
zroot/var/db/pkg on /var/db/pkg (zfs, local, noatime, nosuid)
zroot/var/empty on /var/empty (zfs, local, noatime, noexec, nosuid, read-only)
zroot/var/log on /var/log (zfs, local, noatime, noexec, nosuid)
zroot/var/mail on /var/mail (zfs, local, noatime, noexec, nosuid)
zroot/var/run on /var/run (zfs, local, noatime, noexec, nosuid)
zroot/var/tmp on /var/tmp (zfs, local, nosuid)
22
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (1)
http://www.freebsd.org/doc/handbook/bsdinstall.html
23
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (2)
Install、Shell、Live CD
24
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (3)
Setting hostname
25
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (4)
26
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (5)
Partitioning methods
• Shell – gpart(8)、fdisk(8)、bsdlabel(8)
27
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (6)
Guided Partitioning
• Select disk
• Replace { ad | da }
by ada
• { ad | da }’s are linked
to ada’s
28
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (7)
29
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (8)
Manual Partitioning
30
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (9)
31
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (10)
Add partitions
• freebsd-boot
FreeBSD boot code. This partition must be first on the disk.
32
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (11)
Final confirmation
33
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (12)
34
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (13)
Post-installation
• root password
• Network interfaces
Wired – Static IPv4 / DHCP / Static IPv6 / SLAAC
Wireless
DNS
• Time Zone
• Services
• Add users
35
Computer Center, CS, NCTU
bsdinstall (FreeBSD 9) – (14)
Final configuration
36
Computer Center, CS, NCTU
Soft Updates Journaling – (1)
37
Computer Center, CS, NCTU
Soft Updates Journaling – (2)
Ordering constrains
• Name in on-disk directory must be deleted
• Deallocate on-disk inode
• Release file’s blocks to free-space bitmap
Soft Updates
• Dependency structures
Only inconsistencies
• Blocks marked in use that are free
• Inodes marked in use that are free
38
Computer Center, CS, NCTU
Soft Updates Journaling – (3)
39
Computer Center, CS, NCTU
Soft Updates Journaling – (4)
40