The ability to select the kernel when booting turned out to be very convenient for debugging - if something does not work, then alternately loading with different kernels and in the same way the system can be identified in the assembly of which the problem is - the kernel or the world.
$ echo "setenv BASE /root/caBSD" >> /root/.login $ echo "setenv WORKDIR /root/caBSD/_work" >> /root/.login
$ freebsd-update fetch $ freebsd-update install $ reboot
$ mkdir -p ${BASE}/{conf,tools,pkg.local} $ mkdir -p ${WORKDIR}/{vanilla,custom,mnt}
/ root / caBSD / _work / - the main working directory, $ {WORK}. Subdirectories in it:
vanilla / - here we configure the root of the future system, installworld, installkernel
mnt / - temporary mount point
custom / - we will create .iso / .img images from the contents of this directory
# # tools/CABSD-DEV include GENERIC ident CABSD-DEV # makeoptions NO_MODULES=1 # sc nodevice sc nodevice vga # , options TMPFS # Efficient memory filesystem options GEOM_ELI # Disk encryption. device crypto # core crypto support options NO_SWAPPING # Disable swapping of stack pages
# # tools/CABSD cpu I486_CPU cpu I586_CPU cpu I686_CPU ident CABSD makeoptions NO_MODULES=1 # Don't compile modules options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support #options UFS_ACL # Support for access control lists options MD_ROOT # MD is a potential root device options ROOTDEVNAME=\"ufs:/dev/md0\" # The root device and filesystem type can be compiled in options MSDOSFS # MSDOS Filesystem options CD9660 # ISO 9660 Filesystem options TMPFS # Efficient memory filesystem #options NULLFS # NULL filesystem #options PROCFS # Process filesystem (requires PSEUDOFS) #options PSEUDOFS # Pseudo-filesystem framework options GEOM_PART_GPT # GUID Partition Tables. options GEOM_LABEL # Provides labelization options GEOM_ELI # Disk encryption. options COMPAT_FREEBSD4 # Compatible with FreeBSD4 options COMPAT_FREEBSD5 # Compatible with FreeBSD5 options COMPAT_FREEBSD6 # Compatible with FreeBSD6 options COMPAT_FREEBSD7 # Compatible with FreeBSD7 #options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI #options SYSVSHM # SYSV-style shared memory options SYSVMSG # SYSV-style message queues options SYSVSEM # SYSV-style semaphores options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions options KBD_INSTALL_CDEV # install a CDEV entry in /dev options PROCDESC # Support for process descriptors #options INCLUDE_CONFIG_FILE # Include this file in kernel options NO_SWAPPING # Disable swapping of stack pages # To make an SMP kernel, the next two lines are needed options SMP # Symmetric MultiProcessor Kernel device apic # I/O APIC device cpufreq # CPU frequency control # Bus support. device acpi device pci #device eisa # Floppy drives #device fdc # USB support https://www.freebsd.org/doc/en/books/handbook/usb-disks.html device scbus # SCSI bus (required for ATA/SCSI) device da # Direct Access (disks) device uhci # UHCI PCI->USB interface device ohci # OHCI PCI->USB interface device ehci # EHCI PCI->USB interface (USB 2.0) device xhci # XHCI PCI->USB interface (USB 3.0) device usb # USB Bus (required) device umass # Disks/Mass storage - Requires scbus and da device cd # CD device ukbd # Keyboard device ahci # AHCI-compatible SATA controllers device ata # Legacy ATA/SATA controllers options ATA_STATIC_ID # Static device numbering #device mvs # Marvell 88SX50XX/88SX60XX/88SX70XX/SoC SATA #device siis # SiliconImage SiI3124/SiI3132/SiI3531 SATA # atkbdc0 controls both the keyboard and the PS/2 mouse device atkbdc # AT keyboard controller device atkbd # AT keyboard # kbdcontrol (keymap, keyrate) device kbdmux # keyboard multiplexer # vt is the new video console driver device vt device vt_vga options TERMINAL_NORM_ATTR=(FG_GREEN|BG_BLACK) options MAXCONS=4 # number of virtual consoles # Number of initial kernel page table pages used for early bootstrap. # This number should include enough pages to map the kernel, any # modules or other data loaded with the kernel by the loader, and data # structures allocated before the VM system is initialized such as the # vm_page_t array. Each page table page maps 4MB (2MB with PAE). # , #options NKPT=31 device crypto # core crypto support # Pseudo devices. device loop # Network loopback device random # Entropy device #device padlock_rng # VIA Padlock RNG device rdrand_rng # Intel Bull Mountain RNG #device ether # Ethernet support device md # Memory "disks" # EOF
# # tools/worldbuild.conf # WITHOUT_ACCT= WITHOUT_ACPI= WITHOUT_AMD= WITHOUT_APM= WITHOUT_ARM_EABI= WITHOUT_ASSERT_DEBUG= WITHOUT_AT= WITHOUT_ATM= WITHOUT_AUDIT= WITHOUT_AUTHPF= # tools/worldinstall.conf # # WITHOUT_BINUTILS= WITHOUT_BLUETOOTH= WITHOUT_BMAKE= WITHOUT_BSD_CPIO= WITHOUT_BSNMP= WITHOUT_CALENDAR= WITHOUT_CAPSICUM= WITHOUT_CDDL= WITHOUT_CLANG= WITHOUT_CLANG_EXTRAS= WITHOUT_CLANG_FULL= WITHOUT_CPP= # , libcrypt geli openssl # WITHOUT_CRYPT= WITHOUT_CTM= WITHOUT_CXX= WITHOUT_DICT= WITHOUT_EXAMPLES= WITHOUT_FDT= WITHOUT_FLOPPY= WITHOUT_FMTREE= # , # WITHOUT_FORTH= # , # WITHOUT_FREEBSD_UPDATE= WITHOUT_GAMES= WITHOUT_GCC= WITHOUT_GCOV= WITHOUT_GDB= WITHOUT_GNU= WITHOUT_GNUCXX= WITHOUT_GNU_SUPPORT= WITHOUT_GPIB= WITHOUT_GPIO= WITHOUT_GROFF= WITHOUT_GSSAPI= WITHOUT_HTML= WITHOUT_HYPERV= WITHOUT_ICONV= WITHOUT_INET= WITHOUT_INET_SUPPORT= WITHOUT_INET6= WITHOUT_INET6_SUPPORT= WITHOUT_INFO= # tools/worldinstall.conf # WITHOUT_INSTALLLIB= WITHOUT_IPFILTER= WITHOUT_IPFW= WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_JAIL= WITHOUT_KDUMP= WITHOUT_KERBEROS= WITHOUT_KERBEROS_SUPPORT= WITHOUT_KERNEL_SYMBOLS= WITHOUT_LDNS= WITHOUT_LDNS_UTILS= # , # WITHOUT_LEGACY_CONSOLE= # amd64, i386 # WITHOUT_LIB32= WITHOUT_LIBCPLUSPLUS= # , . # , # WITHOUT_LOCALES= WITHOUT_LOCATE= WITHOUT_LPR= WITHOUT_LS_COLORS= WITHOUT_MAIL= WITHOUT_MAILWRAPPER= WITHOUT_MAKE= WITHOUT_MAN= WITHOUT_MAN_UTILS= # libncurces /usr/bin/vi jupp . # WITHOUT_NCURSESW= WITHOUT_NDIS= WITHOUT_NETCAT= WITHOUT_NETGRAPH= WITHOUT_NETGRAPH_SUPPORT= WITHOUT_NIS= WITHOUT_NLS= WITHOUT_NLS_CATALOGS= WITHOUT_NMTREE= WITHOUT_NS_CACHING= WITHOUT_NTP= WITHOUT_OPENSSH= # , openssl , # . # openssl # WITHOUT_OPENSSL= WITHOUT_PAM_SUPPORT= WITHOUT_PC_SYSINSTALL= WITHOUT_PF= WITHOUT_PKGBOOTSTRAP= WITHOUT_PMC= WITHOUT_PORTSNAP= WITHOUT_PPP= WITHOUT_PROFILE= WITHOUT_QUOTAS= WITHOUT_RCMDS= WITHOUT_RCS= # /rescue WITHOUT_RESCUE= WITHOUT_ROUTED= WITHOUT_SENDMAIL= WITHOUT_SHAREDOCS= WITHOUT_SOURCELESS= WITHOUT_SOURCELESS_UCODE= WITHOUT_SOURCELESS_HOST= WITHOUT_SSP= WITHOUT_SVNLITE= # syscons , newcons - vt(4) WITHOUT_SYSCONS= WITHOUT_SYSINSTALL= # tcsh # WITHOUT_TCSH= WITHOUT_TELNET= WITHOUT_TESTS= WITHOUT_TEXTPROC= # tools/worldinstall.conf # # WITHOUT_TOOLCHAIN= WITHOUT_UNBOUND= WITHOUT_USB= WITHOUT_UTMPX= # , vt # WITHOUT_VT= WITHOUT_WIRELESS= WITHOUT_WIRELESS_SUPPORT= WITHOUT_WPA_SUPPLICANT_EAPOL= WITHOUT_ZFS= # , tz . # , # WITHOUT_ZONEINFO=
# # tools/worldinstall.conf # # Set to not install binutils (as, c++-filt, gconv, ld, nm, objcopy, objdump, readelf, size and strip) WITHOUT_BINUTILS= # Set this if you do not want to install optional libraries. For example when creating a nanobsd(8) image. WITHOUT_INSTALLLIB= # Set to not install programs used for program development, compilers, debuggers etc. The option does not work for build targets. # When set, it also enforces the following options: # WITHOUT_BINUTILS, WITHOUT_CLANG, WITHOUT_CLANG_EXTRAS, WITHOUT_CLANG_FULL, WITHOUT_GCC, WITHOUT_GDB WITHOUT_TOOLCHAIN=
With these options, we disable compilation of both clang and gcc.
$ setenv CC `whereis -bq clang` $ setenv CPP `whereis -bq clang-cpp` $ setenv CXX `whereis -bq clang++`
$ ln -sf ${BASE}/tools/CABSD /usr/src/sys/i386/conf
$ cd /usr/src # rm -rf /usr/obj # $ make buildworld USER=IT HOSTNAME=hq.example.net SRCCONF=${BASE}/tools/worldbuild.conf __MAKE_CONF=/dev/null # $ make buildkernel USER=IT HOSTNAME=hq.example.net SRCCONF=${BASE}/tools/worldbuild.conf __MAKE_CONF=/dev/null KERNCONF=CABSD $ cd ${BASE}
$ cd /usr/src # . __MAKE_CONF - . $ make installworld DESTDIR=${WORKDIR}/vanilla SRCCONF=${BASE}/tools/worldbuild.conf __MAKE_CONF=${BASE}/tools/worldinstall.conf # etc $ make distribution DESTDIR=${WORKDIR}/vanilla SRCCONF=${BASE}/tools/worldbuild.conf __MAKE_CONF=${BASE}/tools/worldinstall.conf # $ make installkernel DESTDIR=${WORKDIR}/vanilla SRCCONF=${BASE}/tools/worldbuild.conf __MAKE_CONF=${BASE}/tools/worldinstall.conf KERNCONF=CABSD # , GENERIC - /boot/kernel # $ mkdir -p ${WORKDIR}/vanilla/tmp/boot/kernel # 800 . . $ cp -p /boot/kernel/{kernel,*.ko} ${WORKDIR}/vanilla/tmp/boot/kernel/ $ chflags -R noschg ${WORKDIR}/vanilla $ cd ${BASE}
#!/bin/csh # # tools/_linkrescue.sh cd ${WORKDIR}/vanilla echo "Before:" du -hc bin sbin usr/bin usr/sbin rescue foreach FILE (`ls rescue`) if ( -f bin/${FILE} ) then ln -f rescue/${FILE} bin/${FILE} else if ( -f sbin/${FILE} ) then ln -f rescue/${FILE} sbin/${FILE} else if ( -f usr/bin/${FILE} ) then ln -f rescue/${FILE} usr/bin/${FILE} else if ( -f usr/sbin/${FILE} ) then ln -f rescue/${FILE} usr/sbin/${FILE} endif end echo "After:" du -hc bin sbin usr/bin usr/sbin rescue cd ${BASE}
# - , # , , chroot . # pkg $ pkg -N || env ASSUME_ALWAYS_YES=YES pkg bootstrap # ${WORKDIR}, $ mkdir -p ${WORKDIR}/pkg.db $ setenv PKG_DBDIR ${WORKDIR}/pkg.db # $ pkg-static update # ${WORKDIR}/vanilla, chroot $ mkdir -p ${WORKDIR}/vanilla/tmp/pkg.files/All # , . $ pkg-static fetch --output ${WORKDIR}/vanilla/tmp/pkg.files --dependencies --yes misc/clex editors/jupp $ unsetenv PKG_DBDIR # (${BASE}/pkg.local). # - $ install -m 0644 ${BASE}/pkg.local/* ${WORKDIR}/vanilla/tmp/pkg.files/All # , $ rm -f ${WORKDIR}/vanilla/var/db/pkg/local.sqlite # $ cd ${WORKDIR}/vanilla $ find tmp/pkg.files/All/* -type f -exec pkg-static -c ${WORKDIR}/vanilla add {} \; $ cd ${BASE}
$ chroot ${WORKDIR}/vanilla pw useradd ca -c "Certification authority operator" -m -G operator -s /bin/csh # UID GID ( 1001:1001, ...) $ chroot ${WORKDIR}/vanilla id -u ca > ${WORKDIR}/ca.uid $ chroot ${WORKDIR}/vanilla id -g ca > ${WORKDIR}/ca.gid # UTF-8 $ echo "setenv MM_CHARSET UTF-8" >> ${WORKDIR}/vanilla/home/ca/.login $ echo "setenv LANG en_US.UTF-8" >> ${WORKDIR}/vanilla/home/ca/.login # path ( /ca) # , openssl - , . $ echo "set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /ca)" >> ${WORKDIR}/vanilla/home/ca/.cshrc # vi , EDITOR $ echo "setenv EDITOR jupp" >> ${WORKDIR}/vanilla/home/ca/.cshrc # , $ echo "setenv OPENSSL_CONF /ca/conf/ca.conf" >> ${WORKDIR}/vanilla/home/ca/.login $ echo "setenv CA_OID 1.3.6.1.4.1.nnnnn" >> ${WORKDIR}/vanilla/home/ca/.login
#!/bin/sh -ex ## # conf/ca.sh ## cd ~ # - 'ca' - # 1. clex mkdir -p ~/.config/clex cat << EOF > ~/.config/clex/config # # CLEX configuration file # CMD_F3=more -- $f CMD_F4=jupp -- $f CMD_F5=cp -ir -- $f $2 CMD_F6=mv -i -- $f $2 CMD_F7=mkdir -- CMD_F8=rm -- $f EOF # 2. vi #cat << EOF > ~/.nexrc #set verbose showmode #set nomesg #EOF # 3. .logout, touch .logout
# conf/ca.sh r-xr-xr-x ${WORKDIR}/vanilla/home/ca $ install -m 0555 -o root -g wheel conf/ca.sh ${WORKDIR}/vanilla/home/ca/ # $ chroot ${WORKDIR}/vanilla su - ca -c /home/ca/ca.sh # $ rm -f ${WORKDIR}/vanilla/home/ca/ca.sh
## # conf/fstab ## /dev/md0 / ufs rw 0 0 # 50 /tmp. tmpfs /tmp tmpfs rw,mode=1777,size=50m,noexec 0 0 # noauto /dev/gpt/ca /ca ufs rw,noauto,noatime 0 0 /dev/gpt/keys.eli /ca.keys ufs ro,noauto,noatime 0 0 /dev/gpt/exchange /ca.certs msdosfs rw,longnames,-u=ca,-g=ca,-m=0640,-M=0750,noauto,noatime 0 0
Please note that the fstab partition with keys for the CA is mounted in read-only mode, so you should remember to remount it for writing before creating the keys (mount -u -o rw /dev/gpt/keys.eli).
# . , # CD $ echo "mount /dev/gpt/ca" >> ${WORKDIR}/vanilla/home/ca/.login $ echo "mount /dev/gpt/keys.eli" >> ${WORKDIR}/vanilla/home/ca/.login $ echo "mount /dev/gpt/exchange" >> ${WORKDIR}/vanilla/home/ca/.login # $ echo "umount /dev/gpt/ca" >> ${WORKDIR}/vanilla/home/ca/.logout $ echo "umount /dev/gpt/keys.eli" >> ${WORKDIR}/vanilla/home/ca/.logout $ echo "umount /dev/gpt/exchange" >> ${WORKDIR}/vanilla/home/ca/.logout
Please note - if the .login and .cshrc files already existed in the user directory 'ca', and we could add there without fear of damage to the owner or rights, then the .logout file was not created when the user entered. Therefore, if we don’t want its owner to be root: ca, you need to create it from under user ca, at least using the conf / ca.sh script
## # conf/devfs.rules ## [localrules=5] # # '/dev/' add path 'gpt/*' group operator mode 0660 # add path 'da*' group operator mode 0660
## # conf/sysctl.conf ## # allow regular users to mount file systems vfs.usermount=1
## # conf/ttys ## # # $FreeBSD: releng/10.1/etc/etc.i386/ttys 267236 2014-06-08 17:50:07Z nwhitehorn $ # @(#)ttys 5.1 (Berkeley) 4/17/89 # console none unknown off secure # 'ca' ttyv0 "/usr/libexec/getty CA" xterm on secure # 'root' ttyv1 "/usr/libexec/getty Pc" xterm on secure
## # conf/gettytab ## # $FreeBSD: releng/10.1/etc/gettytab 241708 2012-10-18 22:20:02Z peterj $ # from: @(#)gettytab 5.14 (Berkeley) 3/27/91 # default:\ :cb:ce:ck:lc:fd#1000:im=\r\n%s/%m (%h) (%t)\r\n\r\n:sp#1200:\ :if=/etc/issue: P|Pc|Pc console:\ :ht:np:sp#9600: # 'ca' CA:\ :al=ca:tc=Pc:
====^^^=^^=^^=^^=^^== == ==
## # conf/rc.conf ## # # $FreeBSD: releng/10.1/etc/defaults/rc.conf 273188 2014-10-16 22:00:24Z hrs $ ############################################################## ### Important initial Boot-time options #################### ############################################################## rc_debug="NO" # Set to YES to enable debugging output from rc.d rc_info="YES" # Enables display of informational messages at boot. devd_enable="NO" # Run devd, to trigger programs on device tree changes. devd_flags="" # Additional flags for devd(8). gptboot_enable="YES" # GPT boot success/failure reporting. # GELI disk encryption configuration. geli_devices="gpt/keys" # List of devices to automatically attach in addition to # GELI devices listed in /etc/fstab. geli_tries="" # Number of times to attempt attaching geli device. # If empty, kern.geom.eli.tries will be used. geli_default_flags="" # Default flags for geli(8). geli_autodetach="YES" # Automatically detach on last close. # Providers are marked as such when all file systems are # mounted. # Example use. #geli_devices="da1 mirror/home" #geli_da1_flags="-p -k /etc/geli/da1.keys" #geli_da1_autodetach="NO" #geli_mirror_home_flags="-k /etc/geli/home.keys" fsck_y_enable="NO" # Set to YES to do fsck -y if the initial preen fails. fsck_y_flags="" # Additional flags for fsck -y # , "NO" background_fsck="NO" # Attempt to run fsck in the background where possible. ############################################################## ### Network configuration sub-section ###################### ############################################################## ### Basic network and firewall/security options: ### hostname="root2sub1" # Set this! hostid_enable="NO" # Set host UUID. #network_interfaces="lo0" # List of network interfaces (or "auto"). #ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration. network_interfaces="" # List of network interfaces (or "auto"). ### Network daemon (miscellaneous) ### hostapd_enable="NO" # Run hostap daemon. syslogd_enable="NO" # Run syslog daemon (or NO). ### IPv6 options: ### ip6addrctl_enable="NO" # Set to YES to enable default address selection ipv6_network_interfaces="none" # List of IPv6 network interfaces # (or "auto" or "none"). ############################################################## ### Mail Transfer Agent (MTA) options ###################### ############################################################## # Settings for /etc/rc.sendmail and /etc/rc.d/sendmail: sendmail_enable="NO" # Run the sendmail inbound daemon (YES/NO). ############################################################## ### Miscellaneous administrative options ################### ############################################################## # , 'ca' devfs_rulesets="/etc/defaults/devfs.rules /etc/devfs.rules" # Files containing # devfs(8) rules. devfs_system_ruleset="localrules" # The name (NOT number) of a ruleset to apply to /dev devfs_set_rulesets="" # A list of /mount/dev=ruleset_name settings to # apply (must be mounted already, ie fstab(5)) devfs_load_rulesets="YES" # Enable to always load the default rulesets cron_enable="NO" # Run the periodic job daemon. crashinfo_enable="NO" # Automatically generate crash dump summary. kern_securelevel_enable="NO" # kernel security level (see security(7)) kern_securelevel="-1" # range: -1..3 ; `-1' is the most insecure # Note that setting securelevel to 0 will result # in the system booting with securelevel set to 1, as # init(8) will raise the level when rc(8) completes. update_motd="NO" # update version info in /etc/motd (or NO) entropy_file="NO" # Set to NO to disable caching entropy through reboots. # /var/db/entropy-file is preferred if / is not avail. dmesg_enable="YES" # Save dmesg(8) to /var/run/dmesg.boot newsyslog_enable="NO" # Run newsyslog at startup. mixer_enable="NO" # Run the sound mixer. ############################################################## ### System console options ################################# ############################################################## #keyboard="" # keyboard device to use (default /dev/kbd0). keymap="ru.win" # keymap in /usr/share/{syscons,vt}/keymaps/* (or NO). keyrate="fast" # keyboard rate to: slow, normal, fast (or NO). #keybell="NO" # See kbdcontrol(1) for options. Use "off" to disable. #keychange="NO" # function keys default values (or NO). #cursor="NO" # cursor type {normal|blink|destructive} (or NO). #scrnmap="NO" # screen map in /usr/share/syscons/scrnmaps/* (or NO). #font8x14="NO" # font 8x14 from /usr/share/{syscons,vt}/fonts/* (or NO). #font8x8="NO" # font 8x8 from /usr/share/{syscons,vt}/fonts/* (or NO). blanktime="NO" # blank time (in seconds) or "NO" to turn it off. moused_nondefault_enable="NO" # Treat non-default mice as enabled unless # specifically overriden in rc.conf(5). # , font8x16="xxx.fnt"
## # conf/hosts ## 127.0.0.1 localhost
# # conf/termcap # # @(#)termcap.src 8.2 (Berkeley) 11/17/93 # $FreeBSD: releng/10.1/share/termcap/termcap.src 267734 2014-06-22 16:48:21Z gavin $ xterm|X11 terminal emulator:\ :tc=xterm-new: # To add a termcap entry under FreeBSD for a new terminal type, insert # the entry in the appropriate location in /etc/termcap then issue this # command: # # cap_mkdb /etc/termcap # xterm-clear:\ :te=\E[?1049l:ti=\E[?1049h:\ :tc=xterm-new: xterm-new|modern xterm:\ :@7=\EOF:@8=\EOM:F1=\E[23~:F2=\E[24~:K2=\EOE:Km=\E[M:\ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:\ :k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:kI=\E[2~:\ :kN=\E[6~:kP=\E[5~:kd=\EOB:kh=\EOH:kl=\EOD:kr=\EOC:ku=\EOA:\ :tc=xterm-basic: # # This chunk is used for building the VT220/Sun/PC keyboard variants. xterm-basic|modern xterm common:\ :am:bs:km:mi:ms:ut:xn:AX:\ :Co#8:co#80:kn#12:li#24:pa#64:\ :AB=\E[4%dm:AF=\E[3%dm:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\ :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=\E(B:al=\E[L:\ :as=\E(0:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\ :cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:\ :ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[!p\E[?3;4l\E[4l\E>:\ :kD=\E[3~:kb=^H:ke=\E[?1l\E>:ks=\E[?1h\E=:kB=\E[Z:le=^H:md=\E[1m:\ :me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:op=\E[39;49m:\ :rc=\E8:rs=\E[!p\E[?3;4l\E[4l\E>:sc=\E7:se=\E[27m:sf=^J:\ :so=\E[7m:sr=\EM:st=\EH:\ :ue=\E[24m:up=\E[A:us=\E[4m:ve=\E[?12l\E[?25h:vi=\E[?25l:vs=\E[?12;25h: # # END OF TERMCAP # ------------------------
## # conf/freebsd-update.conf ## # $FreeBSD: releng/10.1/etc/freebsd-update.conf 258121 2013-11-14 09:14:33Z glebius $ # Trusted keyprint. KeyPrint 800651ef4b4c71c27e60786d7b487188970f4b4169cc055784e21eb71d410cc5 # Server or server pool from which to fetch updates. ServerName update.FreeBSD.org # Components of the base system which should be kept updated. Components world kernel # Directory in which to store downloaded updates and temporary # files used by FreeBSD Update. WorkDir /mnt # When installing a new kernel perform a backup of the old one first # so it is possible to boot the old kernel in case of problems. BackupKernel no
'help' - Ctrl+Shift
#!/bin/sh ## # conf/help ## cat << EOF mfs2: $ mount /dev/gpt/system /mnt $ mdconfig -a -t vnode -f /mnt/mfs2 -u 1 $ mount /dev/md1 /media ... /mdia ... $ umount /media $ mdconfig -d -u 1 $ umount /mnt MS DOS (as root) $ mount_msdosfs -u ca -g ca -m 0640 -M 0750 -l /dev/da1s1 /mnt (as user) $ mount_msdosfs -m 0640 -M 0750 -l /dev/da1s1 ~/mnt DOS (CR/LF) Unix : $ tr -d '\r' < in.txt > out.txt (as root) $ date . memory disk $ mount -t tmpfs -o size=100m tmpfs ~/mnt EOF
#!/bin/sh ## # conf/manpath ## # WITHOUT_MAN=, manpath , whereis echo ""
# etc # $ install -m 0644 -o root -g wheel conf/{devfs.rules,freebsd-update.conf,fstab,gettytab} ${WORKDIR}/vanilla/etc/ $ install -m 0644 -o root -g wheel conf/{hosts,issue,motd,rc.conf,sysctl.conf,ttys} ${WORKDIR}/vanilla/etc/ # usr/bin $ install -m 0555 -o root -g wheel conf/{help,manpath} ${WORKDIR}/vanilla/usr/bin/ # usr/share/misc $ install -m 0644 -o root -g wheel conf/termcap ${WORKDIR}/vanilla/usr/share/misc/ # . $ tzsetup -s -C ${WORKDIR}/vanilla Asia/Yekaterinburg # , # Windows, , UTC. # Empty file. Its presence indicates that the machine's CMOS clock is set to local time. $ touch ${WORKDIR}/vanilla/etc/wall_cmos_clock # root ( ) $ pw -V ${WORKDIR}/vanilla/etc usermod root -h 0
$ vtfontcvt tools/keyrus.bdf keyrus.fnt $ install -m 0444 -o root -g wheel keyrus.fnt ${WORKDIR}/vanilla/usr/share/vt/fonts/ $ echo 'font8x16="keyrus.fnt"' >> ${WORKDIR}/vanilla/etc/rc.conf
# custom/boot/ loader_default.conf # boot/kernel/ - GENERIC , boot/kernel.cabsd/ - $ mkdir -p ${WORKDIR}/custom/boot/{defaults,kernel,kernel.cabsd} # # () $ cp -p ${WORKDIR}/vanilla/boot/kernel/kernel ${WORKDIR}/custom/boot/kernel.cabsd/ # (GENERIC) $ cp -p ${WORKDIR}/vanilla/tmp/boot/kernel/kernel ${WORKDIR}/custom/boot/kernel/
## # conf/loader.conf ## # () autoboot_delay="5" # mfs_load="YES" mfs_type="md_image" # mfs1 ( gzip, .gz ) mfs_name="/mfs1" # /boot/${kernel}/${bootfile} kernel="kernel.cabsd" # /boot sub-directory containing kernel and modules #bootfile="kernel" # Kernel name (possibly absolute path) #kernel_options="" # Flags to be passed to the kernel # newcons: # https://www.freebsd.org/cgi/man.cgi?query=vt(4) # caBSD sc, vt, . # GENERIC , UTF-8 . # kern.vty=vt # Enable halt keyboard combination. kern.vt.kbd_halt=1 # Enable power off key combination. kern.vt.kbd_poweroff=1 # Enable reboot key combination, usually Ctrl+Alt+Del. kern.vt.kbd_reboot=1 # Enable debug request key combination, usually Ctrl+Alt+Esc. kern.vt.kbd_debug=0 # Enable panic key combination. kern.vt.kbd_panic=0
## # conf/loader_gen1.conf ## # # - GENERIC mfs1. # , loader.conf mfs_name="/mfs1" tmpfs_load="YES" #geom_eli_load="YES" exec=".( Loading GENERIC kernel and mfs1 root image ) cr" kernel="kernel" # /boot sub-directory containing kernel and modules bootfile="kernel" # Kernel name (possibly absolute path) kernel_options="" # Flags to be passed to the kernel
## # conf/loader_gen2.conf ## # # - GENERIC mfs2. # , loader.conf mfs_name="/mfs2" tmpfs_load="YES" #geom_eli_load="YES" exec=".( Loading GENERIC kernel and mfs2 root image ) cr" kernel="kernel" # /boot sub-directory containing kernel and modules bootfile="kernel" # Kernel name (possibly absolute path) kernel_options="" # Flags to be passed to the kernel
PROC START ();
ON MODULE HEAD;
DRAW (“RAMKA1”);
CONCLUSION: "Welcome to caBSD";
...
OFF MODULE HEAD;
;
\ \ conf/loader.rc \ \ Example of the file which is automatically loaded by /boot/loader on startup. \ $FreeBSD: releng/10.1/share/examples/bootforth/loader.rc 87636 2001-12-11 00:49:34Z jhb $ include /boot/loader.4th s" /boot/screen.4th" O_RDONLY fopen dup fload fclose s" /boot/frames.4th" O_RDONLY fopen dup fload fclose s" /boot/menuconf.4th" O_RDONLY fopen dup fload fclose initialize drop cr main_menu
\ \ conf/menuconf.4th \ \ Simple greeting screen, presenting basic options. \ XXX This is far too trivial - I don't have time now to think about something more fancy... :-/ \ $FreeBSD: releng/10.1/share/examples/bootforth/menuconf.4th 65480 2000-09-05 16:30:09Z dcs $ : title f_single \ - whxy 60 11 10 4 box 30 4 at-xy ." Welcome to caBSD " me ; : menu 2 fg 15 7 at-xy ." 1. Start caBSD kernel and first root image (auto)" 15 8 at-xy ." 2. Start GENERIC kernel and first root image" 15 9 at-xy ." 3. Start GENERIC kernel and second root image" 15 10 at-xy ." 4. Reboot" me ; : tkey ( d -- flag | char ) seconds + begin 1 while dup seconds u< if drop -1 exit then key? if drop key exit then repeat ; : prompt 14 fg 15 13 at-xy ." Enter your option (1,2,3,4): " 10 tkey dup 32 = if drop key then dup 0< if \ . drop 49 then dup emit me ; : help_text 10 17 at-xy ." * Choose 1 to proceed with standard bootstrapping." 10 18 at-xy ." * Choose 2 or 3 to run special configuration file." 10 19 at-xy ." * Choose 4 in order to warm boot your machine." 10 21 at-xy ." * Anyway you have few seconds to interrupt boot," 10 22 at-xy ." change parameters and type 'boot' to continue" ; : (reboot) 0 reboot ; : main_menu begin 1 while clear f_double 79 23 1 1 box title menu help_text prompt cr cr cr dup 49 = if drop 1 25 at-xy cr ." Proceeding with standard boot. Please wait..." cr 0 boot-conf exit then dup 50 = if drop 1 25 at-xy cr ." Loading /boot/loader_gen1.conf. Please wait..." cr s" /boot/loader_gen1.conf" read-conf 0 boot-conf exit then dup 51 = if drop 1 25 at-xy cr ." Loading /boot/loader_gen2.conf. Please wait..." cr s" /boot/loader_gen2.conf" read-conf 0 boot-conf exit then dup 52 = if drop 1 25 at-xy cr ['] (reboot) catch abort" Error rebooting" then 15 12 at-xy ." Key " emit ." is not a valid option!" 15 13 at-xy ." Press any key to continue..." key drop repeat ;
# , .4th ( , beastie.4th brand.4th - ) $ cp -p ${WORKDIR}/vanilla/boot/{loader,loader.help,*.rc,*.4th} ${WORKDIR}/custom/boot $ cp -p ${WORKDIR}/vanilla/boot/defaults/loader.conf ${WORKDIR}/custom/boot/defaults $ rm -f ${WORKDIR}/custom/boot/{beastie.4th,brand.4th} # loader*.conf conf/ boot $ install -m 0644 -o root -g wheel conf/{loader,loader_gen1,loader_gen2}.conf ${WORKDIR}/custom/boot/ $ install -m 0644 -o root -g wheel conf/{loader.rc,menuconf.4th} ${WORKDIR}/custom/boot/ # GPT, . $ cp -p ${WORKDIR}/vanilla/boot/{pmbr,gptboot,cdboot} ${WORKDIR}
# '' GENERIC . # . , tmpfs.ko mfs $ cp -p ${WORKDIR}/vanilla/tmp/boot/kernel/tmpfs.ko ${WORKDIR}/custom/boot/kernel $ strip ${WORKDIR}/custom/boot/kernel/tmpfs.ko # /boot, installkernel $ rm -rf ${WORKDIR}/vanilla/boot # $ mkdir -p ${WORKDIR}/vanilla/boot/modules # '' - geom_eli.ko crypto.ko $ cp -p ${WORKDIR}/vanilla/tmp/boot/kernel/{geom_eli,crypto}.ko ${WORKDIR}/vanilla/boot/modules $ strip ${WORKDIR}/vanilla/boot/modules/{geom_eli,crypto}.ko # /boot, $ rm -rf ${WORKDIR}/vanilla/tmp/boot # $ ls -l ${WORKDIR}/custom/boot/{kernel,kernel.cabsd}/kernel $ strip ${WORKDIR}/custom/boot/{kernel,kernel.cabsd}/kernel $ strip --remove-section=.note --remove-section=.comment ${WORKDIR}/custom/boot/{kernel,kernel.cabsd}/kernel # # freebsd-update GENERIC , - # . . . $ gzip -9 -f ${WORKDIR}/custom/boot/kernel.cabsd/kernel # kgzip -o ${WORKDIR}/custom/boot/kernel.cabsd/kernel ${WORKDIR}/custom/boot/kernel.cabsd/kernel # gzip -9 -f ${WORKDIR}/custom/boot/kernel/kernel $ ls -l ${WORKDIR}/custom/boot/{kernel,kernel.cabsd}/kernel*
# # tools/files2keep # etc/rc.d/DAEMON etc/rc.d/FILESYSTEMS etc/rc.d/LOGIN etc/rc.d/NETWORKING etc/rc.d/SERVERS etc/rc.d/adjkerntz etc/rc.d/devfs etc/rc.d/dmesg etc/rc.d/geli etc/rc.d/geli2 etc/rc.d/gptboot etc/rc.d/hostname etc/rc.d/initrandom etc/rc.d/ldconfig etc/rc.d/mountcritlocal etc/rc.d/postrandom etc/rc.d/random etc/rc.d/root etc/rc.d/securelevel etc/rc.d/syscons etc/rc.d/sysctl etc/pam.d/login #etc/pam.d/other etc/pam.d/passwd etc/pam.d/system usr/libexec/getty usr/share/locale/en_US.UTF-8 usr/share/locale/ru_RU.UTF-8 #usr/share/misc/init.ee usr/share/misc/termcap usr/share/vt/keymaps/ru.kbd usr/share/vt/keymaps/ru.shift.kbd usr/share/vt/keymaps/ru.win.kbd usr/share/zoneinfo/Asia/Yekaterinburg usr/share/zoneinfo/Europe/Moscow usr/share/zoneinfo/UTC usr/local/etc/joe/syntax/conf.jsf usr/local/etc/joe/syntax/csh.jsf usr/local/etc/joe/syntax/diff.jsf usr/local/etc/joe/syntax/sh.jsf
# # tools/files2delete_bin # bin/chio bin/domainname bin/ed bin/pax sbin/bsdlabel sbin/camcontrol sbin/ccdconfig sbin/comcontrol sbin/ddb sbin/dhclient sbin/dhclient-script sbin/dump sbin/dumpon sbin/etherswitchcfg sbin/fdisk sbin/fsirand sbin/gbde sbin/ggatec sbin/ggated sbin/ggatel sbin/gvinum sbin/hastctl sbin/hastd sbin/ifconfig sbin/iscontrol sbin/kldconfig sbin/kldunload sbin/mksnap_ffs sbin/mount_fusefs sbin/mount_nfs sbin/nfsiod sbin/nos-tun sbin/nvmecontrol sbin/ping sbin/resolvconf sbin/restore sbin/route sbin/savecore sbin/sconfig sbin/setkey sbin/spppcontrol sbin/swapctl usr/bin/asa usr/bin/banner usr/bin/brandelf usr/bin/chat usr/bin/chfn usr/bin/chkey usr/bin/colldef usr/bin/cpasswd usr/bin/cpuset usr/bin/crontab usr/bin/csup usr/bin/ctlstat usr/bin/dialog usr/bin/dtc usr/bin/ee usr/bin/elf2aout usr/bin/elfdump usr/bin/fetch usr/bin/file usr/bin/finger usr/bin/ftp usr/bin/gcore usr/bin/gencat usr/bin/ipcrm usr/bin/ipcs usr/bin/iscsictl usr/bin/keylogin usr/bin/keylogout usr/bin/ktrace usr/bin/ktrdump usr/bin/lam usr/bin/lastcomm usr/bin/leave usr/bin/lockf usr/bin/look usr/bin/lorder usr/bin/m4 usr/bin/mandoc usr/bin/mesg usr/bin/mkdep usr/bin/mkfifo usr/bin/mklocale usr/bin/mt usr/bin/netstat usr/bin/newgrp usr/bin/nfsstat usr/bin/pagesize usr/bin/passwd usr/bin/pr usr/bin/protect usr/bin/rctl usr/bin/revoke usr/bin/rpcinfo usr/bin/rs usr/bin/rup usr/bin/rusers usr/bin/rwall usr/bin/send-pr usr/bin/showmount usr/bin/smbutil usr/bin/sockstat usr/bin/stdbuf usr/bin/su usr/bin/tabs usr/bin/talk usr/bin/tcopy usr/bin/tee usr/bin/tftp usr/bin/tip usr/bin/tsort usr/bin/units usr/bin/unvis usr/bin/vis usr/bin/vmstat usr/bin/wall usr/bin/what usr/bin/whois usr/bin/write usr/sbin/adduser usr/sbin/arp usr/sbin/asf usr/sbin/automountd usr/sbin/binmiscctl usr/sbin/boot0cfg usr/sbin/bootparamd usr/sbin/bootpef usr/sbin/bootptest usr/sbin/bsdconfig usr/sbin/bsdinstall usr/sbin/callbootd usr/sbin/cdcontrol usr/sbin/chroot usr/sbin/ckdist usr/sbin/clear_locks usr/sbin/cpucontrol usr/sbin/crashinfo usr/sbin/cron usr/sbin/ctladm usr/sbin/ctld usr/sbin/dconschat usr/sbin/digictl usr/sbin/dumpcis usr/sbin/etcupdate usr/sbin/fifolog_create usr/sbin/fifolog_reader usr/sbin/fifolog_writer usr/sbin/fwcontrol usr/sbin/getfmac usr/sbin/getpmac usr/sbin/i2c usr/sbin/ifmcstat usr/sbin/inetd usr/sbin/iscsid usr/sbin/keyserv usr/sbin/kgmon usr/sbin/kgzip usr/sbin/lptcontrol usr/sbin/memcontrol usr/sbin/mergemaster usr/sbin/mfiutil usr/sbin/mixer usr/sbin/mlxcontrol usr/sbin/mount_smbfs usr/sbin/mountd usr/sbin/moused usr/sbin/mptable usr/sbin/mptutil usr/sbin/mtest usr/sbin/newsyslog usr/sbin/nfscbd usr/sbin/nfsd usr/sbin/nfsdumpstate usr/sbin/nfsrevoke usr/sbin/nfsuserd usr/sbin/nmtree usr/sbin/nologin usr/sbin/pciconf usr/sbin/periodic usr/sbin/powerd usr/sbin/procctl usr/sbin/quot usr/sbin/rarpd usr/sbin/rmt usr/sbin/rmuser usr/sbin/rpc.lockd usr/sbin/rpc.statd usr/sbin/rpc.umntall usr/sbin/rpcbind usr/sbin/rtprio usr/sbin/services_mkdb usr/sbin/setfib usr/sbin/setfmac usr/sbin/setpmac usr/sbin/sicontrol usr/sbin/smbmsg usr/sbin/snapinfo usr/sbin/spkrtest usr/sbin/spray usr/sbin/syslogd usr/sbin/sysrc usr/sbin/tcpdchk usr/sbin/tcpdmatch usr/sbin/tcpdrop usr/sbin/tcpdump usr/sbin/timed usr/sbin/timedc usr/sbin/traceroute usr/sbin/trpt usr/sbin/ugidfw usr/sbin/vipw usr/sbin/wake usr/sbin/watch usr/sbin/watchdog usr/sbin/zdump usr/sbin/zic usr/sbin/zzz # vi usr/bin/vi
# # tools/files2delete_etc # etc/X11 etc/auto_master etc/autofs etc/bluetooth etc/crontab etc/ddb.conf etc/defaults/bluetooth.device.conf etc/defaults/periodic.conf etc/devd etc/devd.conf etc/dhclient.conf etc/disktab etc/dumpdates etc/ftpusers etc/gss etc/hosts etc/hosts.allow etc/hosts.equiv etc/inetd.conf etc/libalias.conf etc/mac.conf etc/mail etc/mtree etc/netconfig etc/netstart etc/networks etc/newsyslog.conf etc/newsyslog.conf.d etc/nsmb.conf etc/ntp etc/pam.d #etc/pam.d/passwd etc/pccard_ether etc/periodic etc/phones etc/pkg etc/ppp etc/rc.bsdextended etc/rc.d etc/rc.firewall etc/rc.initdiskless etc/rc.resume etc/rc.sendmail etc/rc.suspend etc/remote etc/rpc etc/security etc/skel etc/ssh etc/ssl etc/syslog.conf etc/termcap.small etc/zfs
# # tools/files2delete_lib # lib/libalias.so.7 lib/libalias_cuseeme.so lib/libalias_dummy.so lib/libalias_ftp.so lib/libalias_irc.so lib/libalias_nbt.so lib/libalias_pptp.so lib/libalias_skinny.so lib/libalias_smedia.so lib/libbegemot.so.4 lib/libcam.so.6 lib/libgcc_s.so.1 lib/libipsec.so.4 lib/libpcap.so.8 lib/libreadline.so.8 lib/libthr.so.3 lib/libulog.so.0 libexec/resolvconf # OpenSSL IBM 4758 CCA hardware engine support usr/lib/engines/lib4758cca.so # OpenSSL AEP hardware engine support usr/lib/engines/libaep.so # OpenSSL Atalla hardware engine support usr/lib/engines/libatalla.so # OpenSSL CHIL hardware engine support usr/lib/engines/libchil.so # OpenSSL CryptoSwift hardware engine support usr/lib/engines/libcswift.so # OpenSSL Nuron hardware engine support usr/lib/engines/libnuron.so # OpenSSL SureWare hardware engine support usr/lib/engines/libsureware.so # OpenSSL UBSEC hardware engine support usr/lib/engines/libubsec.so usr/lib/private usr/lib/libBlocksRuntime.so.0 usr/lib/libalias.so usr/lib/libauditd.so.5 usr/lib/libbegemot.so usr/lib/libbsm.so.3 usr/lib/libcam.so usr/lib/libcurses.so usr/lib/libcursesw.so usr/lib/libdwarf.so.3 usr/lib/libexecinfo.so.1 usr/lib/libfetch.so.6 usr/lib/libform.so.5 usr/lib/libformw.so.5 usr/lib/libgcc_s.so usr/lib/libgomp.so.1 usr/lib/libhistory.so.8 usr/lib/libipsec.so usr/lib/libmagic.so.4 usr/lib/libmemstat.so.3 usr/lib/libmenu.so.5 usr/lib/libmenuw.so.5 usr/lib/libpanel.so.5 usr/lib/libpanelw.so.5 usr/lib/libpcap.so usr/lib/libproc.so.2 usr/lib/libpthread.so usr/lib/libradius.so.4 usr/lib/libreadline.so usr/lib/librt.so.1 usr/lib/librtld_db.so.2 usr/lib/libsmb.so.4 usr/lib/libstdbuf.so.1 usr/lib/libstdthreads.so.0 usr/lib/libtacplus.so.5 usr/lib/libtermcap.so usr/lib/libtermcapw.so usr/lib/libtermlib.so usr/lib/libtermlibw.so usr/lib/libthr.so usr/lib/libthread_db.so.3 usr/lib/libtinfo.so usr/lib/libtinfow.so usr/lib/libugidfw.so.4 usr/lib/libutempter.so usr/lib/libvgl.so.6 usr/lib/libwrap.so.6 usr/lib32 usr/libdata usr/libexec
# # tools/files2delete_local # usr/local/libdata usr/local/man usr/local/share usr/local/etc/joe/charmaps usr/local/etc/joe/syntax
# # tools/files2delete_pam # usr/lib/pam_chroot.so usr/lib/pam_deny.so usr/lib/pam_echo.so usr/lib/pam_exec.so usr/lib/pam_ftpusers.so usr/lib/pam_group.so usr/lib/pam_guest.so #usr/lib/pam_lastlog.so #usr/lib/pam_login_access.so #usr/lib/pam_nologin.so #usr/lib/pam_opie.so #usr/lib/pam_opieaccess.so usr/lib/pam_passwdqc.so usr/lib/pam_permit.so usr/lib/pam_radius.so usr/lib/pam_rhosts.so usr/lib/pam_rootok.so #usr/lib/pam_securetty.so #usr/lib/pam_self.so usr/lib/pam_tacplus.so #usr/lib/pam_unix.so
# # tools/files2delete_var # var/account var/at var/audit var/authpf var/crash var/cron var/db/hyperv var/db/ipf var/db/pkg var/db/ports var/db/portsnap var/games var/heimdal var/mail var/msgs var/run/ppp var/run/wpa_supplicant var/rwho var/spool var/unbound var/yp
# # tools/files2delete_other # usr/games usr/include usr/share/bsdconfig usr/share/dtrace usr/share/examples usr/share/info # keys? usr/share/keys usr/share/locale usr/share/man usr/share/mdocml usr/share/misc usr/share/nls usr/share/openssl usr/share/skel usr/share/tabset usr/share/vi usr/share/vt/keymaps usr/share/zoneinfo
# , $ rm -f keepfiles.tar # , tools/files2keep $ tar --create --file keepfiles.tar --directory ${WORKDIR}/vanilla --dereference --files-from tools/files2keep # . # , for, , # , : $ cat tools/files2delete_bin | egrep -v '(^#|^\s*$)' | xargs -I % -t -L 1 find ${WORKDIR}/vanilla -samefile ${WORKDIR}/vanilla/% -exec rm -rf {} \; # -samefile $ cat tools/files2delete_etc | egrep -v '(^#|^\s*$)' | xargs -I % -t -L 1 find ${WORKDIR}/vanilla/% -exec rm -rf {} \; $ cat tools/files2delete_local | egrep -v '(^#|^\s*$)' | xargs -I % -t -L 1 find ${WORKDIR}/vanilla/% -exec rm -rf {} \; $ cat tools/files2delete_other | egrep -v '(^#|^\s*$)' | xargs -I % -t -L 1 find ${WORKDIR}/vanilla/% -exec rm -rf {} \; $ cat tools/files2delete_pam | egrep -v '(^#|^\s*$)' | xargs -I % -t -L 1 find ${WORKDIR}/vanilla/% -exec rm -rf {} \; $ cat tools/files2delete_lib | egrep -v '(^#|^\s*$)' | xargs -I % -t -L 1 find ${WORKDIR}/vanilla/% -exec rm -rf {} \; $ cat tools/files2delete_var | egrep -v '(^#|^\s*$)' | xargs -I % -t -L 1 find ${WORKDIR}/vanilla/% -exec rm -rf {} \; # $ tar --extract --file keepfiles.tar --verbose --directory ${WORKDIR}/vanilla $ rm -f keepfiles.tar
$ find / -type f -amin -15 > /ca.certs/files-keep $ find / -type f -not -amin -15 > /ca.certs/files-delete
# /usr. $ find ${WORKDIR}/vanilla/usr -type d -empty -delete # $ chroot ${WORKDIR}/vanilla find -L / -type l -exec rm -f {} \; # $ rm -rf ${WORKDIR}/vanilla/tmp/pkg.files # pkg $ rm -rf ${WORKDIR}/pkg.db # $ rm -f ${WORKDIR}/vanilla/var/db/pkg/local.sqlite # termcap db $ chroot ${WORKDIR}/vanilla cap_mkdb /usr/share/misc/termcap # 'nologin' - # , 372 , 'false' # freebsd-update . $ ln -f ${WORKDIR}/vanilla/usr/bin/false ${WORKDIR}/vanilla/usr/sbin/nologin # $ mkdir -p -m 0700 ${WORKDIR}/vanilla/{ca,ca.keys,ca.certs} # $ mkdir -p -m 0700 ${WORKDIR}/vanilla/home/ca/mnt # $ chroot ${WORKDIR}/vanilla chown ca:ca /ca /ca.keys /ca.certs /home/ca/mnt # mfs . () , # , freebsd-update. makefs : # -b free-blocks - Ensure that a minimum of 'free-blocks' free blocks (512 bytes) exist in the image # -f free-files - Ensure that a minimum of 'free-files' free files (inodes) exist in the image # -o fs-options - Set file system specific options # -t fs-type - Create an 'fs-type' file system image # . 1 , $ makefs -b 1m -f 100 -o label=sysimg1 -t ffs ${WORKDIR}/custom/mfs1 ${WORKDIR}/vanilla # , . $ gzip -9 -f ${WORKDIR}/custom/mfs1 # . 10 . $ makefs -b 10m -f 100 -o label=sysimg2 -t ffs ${WORKDIR}/custom/mfs2 ${WORKDIR}/vanilla
$ makefs -t cd9660 -o bootimage=i386\;${WORKDIR}/cdboot,label=caBSD,no-emul-boot,rockridge caBSD-10.1-i386.iso ${WORKDIR}/custom # $ ls -l caBSD-10.1-i386.iso
# $ rm -f caBSD-10.1-i386.img caBSD-10.1-i386.txt # uid/gid 'ca' # , chroot , # 'ca' id $ set CA_UID=`cat ${WORKDIR}/ca.uid` $ set CA_GID=`cat ${WORKDIR}/ca.gid` # ${WORKDIR}/custom ( ). $ set SYSSIZE=`du -sm ${WORKDIR}/custom | cut -f 1` # . , # UFS . $ set SYSSIZE=`expr ${SYSSIZE} + 3` # . GENERIC 17 . freebsd-update # . "BackupKernel yes" freebsd-update.conf, # . /boot/kernel tmpfs, , , # . 30 . $ set SYSSIZE=`expr ${SYSSIZE} + 30` # (system + exchange + ca + keys) $ set IMGSIZE=`expr ${SYSSIZE} + 1 + 1 + 1` # img $ dd if=/dev/zero of=caBSD-10.1-i386.img count=${IMGSIZE} bs=1m # md $ set MDDEVICE=`mdconfig -a -t vnode -f caBSD-10.1-i386.img`
md , img , — «ls /dev/md*» «mdconfig -d -u N», 'N' md . , ${MDDEVICE}
# , man gpart $ gpart create -s GPT ${MDDEVICE} # Embed GPT bootstrap code into a protective MBR: $ gpart bootcode -b ${WORKDIR}/pmbr ${MDDEVICE} # Create a dedicated freebsd-boot partition that can boot FreeBSD from a freebsd-ufs partition, # and install bootstrap code into it. We uses 88 blocks (44 kB) so the next partition will be # aligned on a 64 kB boundary. The boot partition itself is aligned on a 4 kB boundary # 4k - SSD . # . $ gpart add -b 40 -s 1m -t ms-basic-data -l exchange ${MDDEVICE} $ gpart add -a 4k -s 64k -t freebsd-boot -l boot ${MDDEVICE} $ gpart add -a 4k -s ${SYSSIZE}m -t freebsd-ufs -l system ${MDDEVICE} $ gpart add -a 4k -s 1m -t freebsd-ufs -l ca ${MDDEVICE} $ gpart add -a 4k -t freebsd-ufs -l keys ${MDDEVICE} # , 1 # , $ gpart show ${MDDEVICE} # $ gpart backup ${MDDEVICE} > caBSD-10.1-i386.txt $ unset SYSSIZE IMGSIZE
# # "-F 32", FAT32, - . # 1 - FAT12 $ newfs_msdos -L exchange /dev/gpt/exchange # . freebsd-boot -> "-i 2" $ gpart bootcode -p ${WORKDIR}/gptboot -i 2 ${MDDEVICE} # # -O - filesystem type; # -n - disable snapshot. Background fsk must be OFF in rc.conf # -o - optimization; # -m - free-space. The percentage of space reserved from normal users; # -U - , -t - SSD $ newfs -O2 -n -o space -m 0 -L system /dev/gpt/system # $ newfs -O2 -n -o space -m 0 -L ca /dev/gpt/ca # . # . # (user key + company key) # /dev/gpt/keys, # -a Enable data integrity verification (authentication) using the given algorithm # -B File name to use for metadata backup # -s Change decrypted provider's sector size. # HMAC , . , # - , . HMAC # . $ geli init -B caBSD-10.1-i386.gelibak -s 4096 /dev/gpt/keys # , . . # , . $ cat caBSD-10.1-i386.gelibak | b64encode caBSD-10.1-i386.gelibak >> caBSD-10.1-i386.txt # '-r' - Attach read-only provider. # # - geli_default_flags="-r" rc.conf. 'ro' fstab $ geli attach /dev/gpt/keys # /dev/gpt/keys.eli # (dd if=/dev/random of=/dev/gpt/keys.eli bs=4096), , # . (4k) , geli init # ( keys.eli) $ newfs -O2 -n -o space -m 0 -L gelikeys /dev/gpt/keys.eli # , df -h : Filesystem Size Used Avail Capacity Mounted on /dev/md0 14M 13M 690K 95% / devfs 1.0K 1.0K 0B 100% /dev tmpfs 50M 4.0K 50M 0% /tmp /dev/gpt/ca 828K 240K 588K 29% /ca /dev/gpt/keys.eli 720K 4.0K 716K 1% /ca.keys /dev/gpt/exchange 999K 6.5K 992K 1% /ca.certs
# [keys] , geli. , # $ mount /dev/gpt/keys.eli ${WORKDIR}/mnt # " " $ touch ${WORKDIR}/mnt/.created-keys.eli # 'ca' $ chown -R ${CA_UID}:${CA_GID} ${WORKDIR}/mnt # $ umount ${WORKDIR}/mnt $ geli detach /dev/gpt/keys.eli # [exchange]. # -m maximum file permissions for files # -M maximum file permissions for directories $ mount_msdosfs -u ${CA_UID} -g ${CA_GID} -m 0640 -M 0750 -l /dev/gpt/exchange ${WORKDIR}/mnt # UFS , . # , fstab. $ touch ${WORKDIR}/mnt/.created-exchange $ umount ${WORKDIR}/mnt # [ca] . # , tools/ca.tar.gz. $ mount /dev/gpt/ca ${WORKDIR}/mnt $ tar --extract --gunzip --no-same-permissions --file tools/ca.tar.gz --directory ${WORKDIR}/mnt # rw-r----- $ chmod -R u=rw,g=r,o= ${WORKDIR}/mnt/* # conf rwxr-x--- $ chmod u=rwx,g=rx,o= ${WORKDIR}/mnt/conf # rwxr-x--- $ chmod u=rwx,g=rx,o= ${WORKDIR}/mnt/*.sh $ touch ${WORKDIR}/mnt/.created-ca $ chown -R ${CA_UID}:${CA_GID} ${WORKDIR}/mnt $ umount ${WORKDIR}/mnt # [system] $ mount /dev/gpt/system ${WORKDIR}/mnt # $ cp -av ${WORKDIR}/custom/. ${WORKDIR}/mnt/ $ umount ${WORKDIR}/mnt # $ mdconfig -d -u ${MDDEVICE} $ unset MDDEVICE CA_UID CA_GID # $ ls -l caBSD-10.1-i386.img
$ cd ${BASE} # GENERIC , , freebsd-update # gunzip ${WORKDIR}/custom/boot/kernel/kernel.gz # custom /boot, GENERIC # -b basedir - Operate on a system mounted at basedir # -d workdir - Store working files in workdir # -f conffile - Read configuration options from conffile $ freebsd-update fetch -b ${WORKDIR}/custom -d ${WORKDIR}/mnt -f ${WORKDIR}/vanilla/etc/freebsd-update.conf # $ freebsd-update fetch -b ${WORKDIR}/vanilla -d ${WORKDIR}/mnt -f ${WORKDIR}/vanilla/etc/freebsd-update.conf
$ cd ${WORKDIR}/mnt # /media/sys # $ ln -s `echo ${WORKDIR}/custom | sha256 -q`-install ${WORKDIR}/mnt/`echo /media/sys | sha256 -q`-install # - /media/mfs $ ln -s `echo ${WORKDIR}/vanilla | sha256 -q`-install ${WORKDIR}/mnt/`echo /media/mfs | sha256 -q`-install # $ tar -cvf ${BASE}/update.tar . $ cd ${BASE}
# , /mnt - # /etc/freebsd-update.conf , /media $ mkdir /media/{sys,mfs,flash} # $ mount /dev/gpt/system /media/sys # /media/sys /boot . # /dev/md1 (md0 /) $ mdconfig -a -t vnode -f /media/sys/mfs2 -u 1 $ mount /dev/md1 /media/mfs # /media/flash $ mount_msdosfs -l /dev/da1s1 /media/flash # , tmpfs # $ du -h /media/flash/update.tar # $ mount -t tmpfs -o size=100m tmpfs /mnt # /mnt $ tar -xvf /media/flash/update.tar -C /mnt # ( ) # gunzip /media/sys/boot/kernel/kernel.gz # freebsd-update , $ sysctl kern.bootfile="/media/sys/boot/kernel/kernel" # $ freebsd-update install -b /media/sys -d /mnt # . . # - # gzip -9 /media/sys/boot/kernel/kernel # $ freebsd-update install -b /media/mfs -d /mnt # $ umount /media/flash $ umount /mnt $ umount /media/mfs $ mdconfig -d -u 1 $ umount /media/sys $ rmdir /media/{sys,mfs,flash} $ reboot # , # $ freebsd-version 10.1-RELEASE-p12 $ openssl version OpenSSL 1.0.1l-freebsd 15 Jan 2015
Source: https://habr.com/ru/post/262151/
All Articles