User Tools

Site Tools


unix:freebsd:system_builds:basic_freebsd_installation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
unix:freebsd:system_builds:basic_freebsd_installation [2019/11/05 15:19] rodolicounix:freebsd:system_builds:basic_freebsd_installation [2019/12/03 15:35] (current) rodolico
Line 9: Line 9:
 When it comes time to partition the drive, I choose //manual// and set up from the command line. The main reason for this is that the FreeBSD installer in automatic mode does not allow you to set up without a swap partition, and I like **swap files** instead of swap partitions. While possibly slower, you have the flexibility to adjust the amount of space allocated to swap. This has saved me headaches in the past. When it comes time to partition the drive, I choose //manual// and set up from the command line. The main reason for this is that the FreeBSD installer in automatic mode does not allow you to set up without a swap partition, and I like **swap files** instead of swap partitions. While possibly slower, you have the flexibility to adjust the amount of space allocated to swap. This has saved me headaches in the past.
  
-From the command line, do the following. This assumes your boot drive is ada0. This is directly stolen from [[http://www.wonkity.com/~wblock/docs/html/ssd.html]], though it is summarized here.+Also, just because it simplifies things, I remove all of the data drives. Normally, we have a single boot drive, then several drives which will contain data, generally as a ZFS file system. By removing the drives, I know which one is the one I want to install onto. This can cause problems since adding drives after a system is configured can rename existing drives. However, if your boot drive is on an internal connection (most modern servers have this capability) or you make sure it is in the first drive bay, drive renaming is not an issue. 
 + 
 +From the command line, do the following. This assumes your boot drive is ada0. This is directly stolen from [[http://www.wonkity.com/~wblock/docs/html/ssd.html]], though it is summarized and modified it here
 + 
 +We are working in blocks, for the most part, which are normally 512bytes long.
  
 <code bash> <code bash>
Line 15: Line 19:
 gpart create -s gpt ada0 gpart create -s gpt ada0
 # add a very, very small partition for boot # add a very, very small partition for boot
-gpart add -t freebsd-boot -s 512k -a4k -l ssdboot ada0+# This begins at block 40 (2M) and is 472 blocks long (236k) 
 +gpart add -t freebsd-boot -b 40 -s 472 -l ssdboot ada0
 # set it up to be bootable # set it up to be bootable
 gpart bootcode -b /boot/pmbr -p /boot/gptboot -i1 ada0 gpart bootcode -b /boot/pmbr -p /boot/gptboot -i1 ada0
Line 21: Line 26:
 # if you want, you can specify the size with the -s parameter # if you want, you can specify the size with the -s parameter
 # as in '-s 100g' to only use 100G # as in '-s 100g' to only use 100G
 +# For SSD's without TRIM, set at 80% of available space
 gpart add -t freebsd-ufs -l ssdrootfs -b 1m ada0 gpart add -t freebsd-ufs -l ssdrootfs -b 1m ada0
 # format the second partition. # format the second partition.
Line 30: Line 36:
 **Note:** the referenced article actually uses separate partitions for /var and /usr. In my case, we are generally setting things up in a way that this is just over complication, though in some installations it is necessary to break it down further. **Note:** the referenced article actually uses separate partitions for /var and /usr. In my case, we are generally setting things up in a way that this is just over complication, though in some installations it is necessary to break it down further.
  
-Complete the installation and reboot.+Complete the installation. Be sure to add one user to the wheel group, or they will not be able to su to root. If you forget, when you log in for the first time (as root), add the user manually:
  
-===== Post Installation Partitions =====+<code bash>pw user  mod  username -G wheel</code> 
 + 
 +where //username// is the username you want to add. 
 + 
 +===== Post Installation File System Modifications =====
  
 Note that /tmp is missing and there is no swap space. The first thing I want to do is set /tmp and /var/tmp to use the same ramdisk (aka tmpfs). Assuming I have sufficient RAM, I can allocate some space for tmp, which makes things faster and cleaner. Note that /tmp is missing and there is no swap space. The first thing I want to do is set /tmp and /var/tmp to use the same ramdisk (aka tmpfs). Assuming I have sufficient RAM, I can allocate some space for tmp, which makes things faster and cleaner.
  
 Additionally, I want to create a swap file to replace the partition. Swap is very nice to have, but rarely used, but I had one case where my swap partition was just too damned small and the server started acting squirrely whenever there was a lot of ZFS activity. Additionally, I want to create a swap file to replace the partition. Swap is very nice to have, but rarely used, but I had one case where my swap partition was just too damned small and the server started acting squirrely whenever there was a lot of ZFS activity.
 +
 +  - Make a backup copy of /etc/fstab
 +  - create a 4G file to be used for swap space. modify size as necessary
 +  - Create the entry in fstab for the swap space
 +  - turn on swap
 +  - create a tmpfs entry in fstab for /tmp
 +  - move /var/tmp to point to /tmp
 +  - activate /tmp. This could cause instability if something is being used, so reboot very soon
 +  - display mounts (prove we did what we expected to)
 +  - reboot to be on safe side
  
 <code bash> <code bash>
-# create a 4G file to be used for swap spacemodify size as necessary+cp /etc/fstab /etc/fstab.bak
 dd if=/dev/zero of=/swapfile bs=1G count=4 dd if=/dev/zero of=/swapfile bs=1G count=4
-# Create the entry in fstab 
 echo 'md99  none  swap  sw,file=/swapfile 0 0' >> /etc/fstab echo 'md99  none  swap  sw,file=/swapfile 0 0' >> /etc/fstab
-# create tmpfs entry in fstab for /tmp+swapon -a
 echo 'tmpfs  /tmp  tmpfs  rw,mode=01777 0 0' >> /etc/fstab echo 'tmpfs  /tmp  tmpfs  rw,mode=01777 0 0' >> /etc/fstab
-# move /var/tmp to point to /tmp 
 rm -fR /var/tmp rm -fR /var/tmp
 ln -s /tmp /var/tmp ln -s /tmp /var/tmp
-# activate /tmp. This could cause instability 
 rm -fR /tmp/* rm -fR /tmp/*
 mount /tmp mount /tmp
-# Just to be on the safe side, reboot+mount
 reboot reboot
 </code> </code>
  
 +===== Install some basic packages =====
  
-I generally like some things that are not installed by default for FreeBSD (or Debian Linux, or Microsoft Windows, or Apple OSX, for that matter). For instance, I accept the larger size of bash for the extra functionality, and I'm lost without the //joe// editor+I generally like some things that are not installed by default for FreeBSD (or Linux, or Microsoft Windows, or Apple OSX, for that matter). For instance, I accept the larger size of bash for the extra functionality, and I'm lost without the //joe// editor. Some people are just more comfortable with a web UI than the standard CLI, so they might consider installing webmin ([[https://webmin.com]]). We will install 
 +  * joe (because it's my favorite editor) 
 +  * postfix (because I hate sendmail) 
 +  * bash (a lot more robust than sh) 
 +  * perl5 (I write a lot of perl scripts) 
 +  * pv (very cool for long running copies) 
 +  * sudo (allows users to be elevated to root without giving them root's password) 
 +  * screen (very, very cool for long running processes) 
 +  * webmin (if you want a webui for managing a lot of things on the system) 
 +  * ipmitool (if this is a server with ipmi enabled functions) 
 +  * pbzip2 and xz (good compression technologies) 
 +  * smartmontools (monitors your hard drive health)
  
-Because of that, tend to write sets of scripts and/or instructions.+I've label the steps as to indicate what the code is setting up so you can easily not use some packages.
  
-<code bash basicinstall.sh> +  - Install the packages - Answer 'Y' when asked if you want to enable postfix<code bash> 
-#! /usr/bin/env sh +pkg install joe perl5 pv pbzip2 sudo screen webmin ipmitool postfix bash smartmontools 
- +</code
-#NOTE: this is an sh script, the default for FreeBSD +  - Set up postfix and disable sendmail<code bash>service sendmail stop
-#sh requires the # for a comment be a part of a word, +
-#thus the commenting style here. +
-#we install bash which is a more powerful shell that I +
-#like a lot. +
- +
-#install some basic tools. screen is a very useful tool. +
-#I use sudo to give users access to root without knowing the password +
- +
-pkg install joe postfix bash perl5 pv pbzip2 sudo screen +
- +
-#Expect the question, and answer "Y" for yes +
-#Would you like to activate Postfix in /etc/mail/mailer.conf [n]? y +
- +
-#now that they are installed, start configuring them. +
- +
-#Add IPMI if desired. Note that IPMI is only useful +
-#for physical machines that have the IPMI interface +
- +
-#enable ipmi module +
-pkg install ipmitool  +
-kldload ipmi +
-echo 'ipmi_load="YES"' >> /boot/loader.conf +
- +
-#set up bash +
-mount -t fdescfs fdesc /dev/fd +
-cp /etc/fstab /etc/fstab.bak +
-echo '# enable bash' >> /etc/fstab +
-echo 'fdesc  /dev/fd  fdescfs  rw     0' >> /etc/fstab +
-chsh -bash rodolico +
- +
- +
-#shut down sendmail, disable it, and enable postfix +
-service sendmail stop+
 sysrc postfix_enable="YES" sysrc postfix_enable="YES"
 sysrc sendmail_enable="NONE" sysrc sendmail_enable="NONE"
- 
-#sets up postfix configuration as only mail server 
 mv /etc/mail/mailer.conf /etc/mail/mailer.conf.old mv /etc/mail/mailer.conf /etc/mail/mailer.conf.old
 install -m 0644 /usr/local/share/postfix/mailer.conf.postfix /etc/mail/mailer.conf install -m 0644 /usr/local/share/postfix/mailer.conf.postfix /etc/mail/mailer.conf
- 
-#clean up some stuff left over by sendmail 
 echo 'daily_clean_hoststat_enable="NO"' >> /etc/periodic.conf echo 'daily_clean_hoststat_enable="NO"' >> /etc/periodic.conf
 echo 'daily_status_mail_rejects_enable="NO"' >> /etc/periodic.conf echo 'daily_status_mail_rejects_enable="NO"' >> /etc/periodic.conf
 echo 'Daily_status_include_submit_mailq="NO"' >> /etc/periodic.conf echo 'Daily_status_include_submit_mailq="NO"' >> /etc/periodic.conf
 echo 'daily_submit_queuerun="NO"' >> /etc/periodic.conf echo 'daily_submit_queuerun="NO"' >> /etc/periodic.conf
-#add postfix user to mail group so it has access to sasl 
 pw group mod mail -m postfix pw group mod mail -m postfix
-#start postfix 
 service postfix start service postfix start
-#configuration stored in /usr/local/etc/postfix+</code> 
 +  - Set up bash<code bash>mount -t fdescfs fdesc /dev/fd 
 +cp /etc/fstab /etc/fstab.bak 
 +echo 'enable bash' >> /etc/fstab 
 +echo 'fdesc  /dev/fd  fdescfs  rw     0' >> /etc/fstab 
 +chsh -s bash username 
 +</code> 
 +  - Set up webmin<code bash>/usr/local/lib/webmin/setup.sh 
 +echo "webmin_enable="YES"" >> /etc/rc.conf 
 +/usr/local/etc/rc.d/webmin start</code> 
 +  - Set up ipmitool<code bash>kldload ipmi 
 +echo 'ipmi_load="YES"' >> /boot/loader.conf</code> 
 +  - Set up smartmontools to monitor your drives<code bash># edit the next file for your system after you copy it 
 +cp /usr/local/etc/smartd.conf.sample  /usr/local/etc/smartd.conf 
 +echo 'daily_status_smart_devices="/dev/ad0 /dev/da0"' >>/etc/periodic/daily/850.smartmontool 
 +chmod 755 /etc/periodic/daily/850.smartmontool 
 +echo 'smartd_enable="YES"' >> /etc/rc.conf 
 +service smartd start
 </code> </code>
  
-Notewhen you created a new user, if you did not add them to the wheel group, you will need to do that after the fact (or they can not issue the su command to become root)Add a user to the wheel group with the following:+===== References ===== 
 +  * [[https://doxfer.webmin.com/Webmin/Installation]] 
 +  * [[http://www.wonkity.com/~wblock/docs/html/ssd.html]] 
 +  * [[https://www.cyberciti.biz/faq/freebsd-bash-installation/]]
  
-<code>pw user  mod  username -G wheel</code> 
- 
-where //username// is the username you want to add. 
unix/freebsd/system_builds/basic_freebsd_installation.1572988781.txt.gz · Last modified: 2019/11/05 15:19 by rodolico