|
Guides All Guides and HOWTO's. |
|
Thread Tools | Display Modes |
|
|||
Makefile for Vermaden's FreeBSD ZFS root install adapted for 4K sector disks
Introduction
What does the Makefile do? The comments at the beginning of the file gives an explanation: Code:
# This BSD makefile merely automates Vermaden's "'ZFS madness / boot # environments" mirrored disk setup. # # For a complete description of this particular ZFS only setup see below. # # The ZFS configuration described by Vermaden does not align the # disk partitions for 'Avanced Format' 4K disks and also does not # instruct ZFS to use 4K blocks for the write and read operations. # # The procedure implemented here does align the EFI/gpt partitions # used on a 4K (8 x 512) # sector boundary. By using the 'gnop' trick # the FreeBSD ZFS implementation is coached to use an 'ashift' value # of 12 (2^12 = 4096) # This value makes ZFS read and write on 4K boundaries # # Credits for the ZFS install procedure: # # Slawomir Wojciech Wojtczak (vermaden) # http://forums.freebsd.org/showthread.php?t=31662 # http://www.daemonforums.org/showthread.php?t=7099 # # Sources and /credits for the 4K alignment issue and gnop hack: # # Warren Block (wblock@) for his numerous posts about partition alignment: # http://forums.freebsd.org (Installation and Storage sections) # http://www.wonkity.com/~wblock/docs/...w_standard_gpt # Ivan Voras for the gnop workaround: # http://ivoras.sharanet.org/blog/tree...or-drives.html # George Kontostanos (gkontos) for using gnop and a ZFS cache file: # http://forums.freebsd.org/showthread.php?t=23544 # http://www.aisecure.net/2012/01/16/rootzfs/
Overview of the Makefile targets The utility ones:
The pre-installation tasks can be performed individually or by using the pre_install target:
The actual installation:
The post-installation tasks done by target post_install:
For the really lazy ones among us there is a target 'all' that does it all: Code:
pre_install: trailer partition gnop4k pool4k export gnop_destroy import \ chk_ashift zfs_options zfs_fs zfs_swap install: trailer for THIS in ${INSTALL_SETS} ; do \ tar --unlink -xvpJf $${THIS} -C ${MOUNT} ;\ done ls -l ${MOUNT} zpool status ${POOL} zpool iostat ${POOL} zfs list post_install: trailer loader.conf fstab rc.conf zfs_boot zfs_umount mountpoint all: trailer pre_install install post_install By changing the makefile variables you can adapt the installation to your wishes. Code:
POOL = super ROOT_SET = ${POOL}/ROOT BOOT_SET = ${ROOT_SET}/default # --- installation file sets SETS = base.txz kernel.txz DIR = /usr/freebsd-dist # On FreeBSD liveCD/DVD/memstick .for X in ${SETS} INSTALL_SETS += ${DIR}/${X} .endfor Code:
DISKTYPE = ada DISKTYPE = md .if ${DISKTYPE} == "md" # --- memory disks see md(4) and mdconfig(8) # size of disk needs to be at least 64M else you encounter this error: # "cannot create 'pool': one or more devices is less than the minimum size (64M)" MD_SIZE = 2g SWAPSIZE = 256m DISK_1 = /dev/md1 DISK_2 = /dev/md2 DISKS = ${DISK_1} ${DISK_2} # --- gpt/EFI labels LABEL_ZFS = mdisk_ LABEL_BOOT = mdboot Code:
.else # --- real spinning rust disks DISK_1 = /dev/ada1 DISK_2 = /dev/ada2 DISKS = ${DISK_1} ${DISK_2} SWAPSIZE = 4G # --- gpt/EFI labels LABEL_ZFS = SYSTEM_ LABEL_BOOT = BOOT_ .endif Code:
TMP = /tmp CACHEFILE = ${TMP}/zpool.cache TEMPLATE_RC_CONF= ${TMP}/template_rc.conf MOUNT = /mnt RC_CONF = ${MOUNT}/etc/rc.conf LOADER_CONF = ${MOUNT}/boot/loader.conf FSTAB = ${MOUNT}/etc/fstab Code:
Code:
Checking for installation sets ... Set /usr/freebsd-dist/base.txz : found! Set /usr/freebsd-dist/kernel.txz : found! Code:
Checking for 'rc.conf' template ... /tmp/template_rc.conf not found exit 100 *** [show] Error code 100 Code:
----------- rc.conf template ---------- cat /tmp/template_rc.conf # ------ rc.conf #defaultrouter=192.168.222.10 hostname='althusser.utp.xnet' network_interfaces='bge0' ifconfig_bge0="SYNCDHCP" # --- daemons inetd_enable=NO sshd_enable=yes sendmail_enable=yes # --- time synchronization ntpd_enable=YES #openntpd_enable=YES
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump Last edited by J65nko; 8th August 2013 at 09:01 PM. |
|
|||
Pre-installation steps
For demonstration purpose two memory or RAM disks will be used. Code:
# diskinfo on these disks.Code:
To use this target on one of my disks reporting a 512 sectorsize to the OS but having a stripesize of 4096, I can override the makefile variable DISKS on the command line; Code:
WARNING: the following command will remove all partitioning information from the disks as defined in the makefile. Please make sure that this is correct and double-check the settings you configured by running # make show . You will lose data if the settings refer to the wrong disk.Code:
Code:
Code:
A ZFS storage pool with these freshly created 4K devices is the next step. Code:
Code:
Code:
Code:
Note that for some reason the import does not use the GPT labels, but the partition numbers. I only noticed this when I test with memory disks. With real disks the import uses the labels: Code:
Code:
Code:
Code:
In the original procedure the ZFS swap space is configured after rebooting into the new system, but let us do it now. Code:
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump Last edited by J65nko; 5th August 2013 at 11:13 PM. Reason: Added WARNING |
|
|||
Installation
Let us go for it. Code:
Post-installation Initializing /boot/loader.conf Code:
Code:
Code:
Code:
Code:
Code:
Code:
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump Last edited by J65nko; 5th August 2013 at 10:08 PM. |
|
|||
One of the first versions of the makefile without all the whistles and bells like the 4K alignment stuff, and variables:
Code:
DISKS = /dev/ada1 /dev/ada2 DISKS = /dev/md1 /dev/md2 partition: .for X in ${DISKS} if gpart show ${X} ; then gpart destroy -F ${X} ; fi gpart create -s GPT ${X} NUMBER=$$( echo ${X} | tr -c -d '0-9' ) ;\ gpart add -t freebsd-boot -l bootcode$${NUMBER} -s 128k ${X} ;\ gpart add -t freebsd-zfs -l sys$${NUMBER} ${X} gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${X} .endfor pool: zpool create -f -o cachefile=/tmp/zpool.cache sys mirror /dev/gpt/sys* zpool status zpool list options: zfs set mountpoint=none sys zfs set checksum=fletcher4 sys zfs set atime=off sys zfs create sys/ROOT zfs create -o mountpoint=/mnt sys/ROOT/default zpool set bootfs=sys/ROOT/default sys # ================================================================================ pre_install: partition pool options install: cd /usr/freebsd-dist ;\ for X in base.txz kernel.txz; do \ tar --unlink -xpJf $${X} -C /mnt ;\ done @echo Current directory: $$(pwd) post_install: zfs_boot loader.conf fstab rc.conf umount mountpoint all: pre_install install post_install # ================================================================================ zfs_boot: cp /tmp/zpool.cache /mnt/boot/zfs/ loader.conf: echo 'zfs_load=YES' >> /mnt/boot/loader.conf echo 'vfs.root.mountfrom="zfs:sys/ROOT/default"' >> /mnt/boot/loader.conf fstab: # ---- create empty /etc/fstab file touch /mnt/etc/fstab rc.conf: echo 'zfs_enable=YES' >> /mnt/etc/rc.conf umount: zfs list zfs umount -a mountpoint: zfs set mountpoint=legacy sys/ROOT/default zfs list
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump Last edited by J65nko; 7th August 2013 at 01:43 PM. |
|
|||
Placeholder 4
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
|
|||
Methods to get the Makefile to the FreeBSD live CD session
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump Last edited by J65nko; 6th August 2013 at 01:05 PM. |
|
|||
The Makefile for downloading. Please rename it to Makefile:
# mv Makefile-ZFS-madness-1.18.txt Makefile
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump Last edited by J65nko; 8th August 2013 at 12:31 PM. |
Tags |
4k disk, 4k sector alignment, advanced format disks, freebsd, make, makefile, zfs, zfs madness, zfs root |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to remove boot sector viruses? | CyberJet | OpenBSD General | 8 | 15th July 2011 07:50 PM |
HOWTO: Modern FreeBSD Install (vermaden way) | vermaden | Guides | 10 | 11th July 2011 07:05 AM |
${REINPLACE_CMD} on Makefile | indiocolifa | FreeBSD Ports and Packages | 3 | 26th March 2009 11:16 PM |
Makefile Problem | BadWolf | Programming | 4 | 15th March 2009 01:58 PM |
ports config and makefile scripting | boincv | FreeBSD Ports and Packages | 6 | 1st October 2008 07:57 AM |