I mentioned in "Everyone needs a server" in that I have a home server, which is made of a obsolete P3 micro-desktop and installed with a Ubuntu system. The main tasks are network firewall, file sharing, source code version control, development database, Webserver, ssh/SFTP, etc. It has been working normally for so many years. But after all, the times are evolving, and this machine is too old. Let's change it.
The previously conceived power-saving solution has become very popular now, so the finished NAS server won't talk about it, and there are also many choices for Self-Assembly. For example, the Intel Platform has low-end options such as atom, the high-end products include the CULV series and AMD product lines. At present, there are quite a few people assembling and configuring NAS or home servers on the Internet, and there are also a variety of software solutions, such as freenas Based on FreeBSD, or WHS Based on Windows.Hardware and software solutions
The first is hardware. Because my requirements are different from those of general NAS users, the NAS product basically cannot meet my DIY needs and can only be assembled by myself.
The CPU is selected for Intel's atom series, which is much less popular than AMD. The motherboard must be 17x17 MINI-ITX, because I used to put the machine is relatively small, the position inside can only put down the small chassis like Q5, and this kind of chassis can only install this motherboard. The larger the memory support, the better, but it is still subject to CPU restrictions. The more ports, the better. Because the storage function is very important, there must be at least two SATA ports, and the IDE can have the best and accept none. Although USB is of little use, it is not convenient to use less than four USB. Nic can be a few more, of course, there is a basic enough, of course, it is best to gigabit.
If you search for the above conditions, all netbooks must be abandoned, because they only have one Sata. It can only be found on a desktop or industrial motherboard. To save power, Atom's N series should be the best choice, but unfortunately it is mainly designed for netbooks and lacks DIY solutions. Even if it can be found, it is still a very old N270, but that performance is really not good, don't consider. I started to consider atom 330, which is a good balance between power consumption and performance. However, because it has been withdrawn from the market, basically it is a rebuild and repair solution, and there are too many problems. Therefore, we finally chose d525, dual-core, and 4 GB memory. The disadvantage of the D series is that the power consumption is much larger than that of the N series, and the fever problem is quite troublesome. The general configuration is as follows:
CPU: Intel d525
Motherboard: nm10 chipset
Memory: 2 GB (it is planned to expand to 4 GB. It is said that 2 GB of memory is barely running ZFS. Try it for now)
Hard Disk: 1 Tb (planned expansion to 2 TB)
As for the software, I certainly will not consider WHS, because I do not like windows, but I have said n times, except for my personal preferences, copyright issues (in addition to system copyrights, we also need to consider copyright issues for applications), virus issues, security issues, stability issues, and so on. Freenas is implemented for NAS and only has a small FreeBSD kernel. It is obviously not enough for me to use it. Although it can be done on the basis of it, it is always troublesome. Therefore, we decided to directly install a FreeBSD, and then install some software in it to meet our needs. The main reason why I don't use Ubuntu any more is that I want to try ZFS. Although Linux already has a variety of transplanted ZFS or ZFS-like solutions, it is not mature enough, in other words, even the ZFS 15 version of FreeBSD 8.2 is not perfect. We hope FreeBSD 9 will have a perfect ZFS.
There is nothing to say about hardware installation. It's just that the fever of the d525 is still a little big. If you don't add a fan in the summer, it's estimated that it won't last. In the end, you still have to add a 6010 small fan. It's a pity that you cannot completely mute it. If there is no performance requirement, it is no problem to use the N270 solution for heat dissipation.
The following describes how to install the software.Preparations before installation
In the past, another motherboard has an IDE port. You can connect to an optical drive to install the system. However, the Board is out of stock and cannot be purchased. The current Board has no ide port and can only be started with USB. Therefore, you need to create a USB boot disk first. Of course, the external USB drive is also supported.
For how to create a freebsd USB boot disk, refer to this article:
First download memstick. the FreeBSD installation file of the IMG version is currently in the 8.2 stable version. Because ZFS is used and large memory is required, the 64-bit version is downloaded, although it is said that the 32-bit version is barely usable, the configuration is a lot of trouble. After the USB flash drive is inserted, it is used in the system (my desktop system is Ubuntu 10.04, and Windows users should study it on their own:
sudo fdisk -l
Check the device name of the USB flash drive, such as SDB. Then use:
sudo dd if=FreeBSD-8.2-RELEASE-amd64-memstick.img of=/dev/sdb bs=10240 conv=sync
Use it to start the server and start installation.
For the entire installation process, refer to this article. Most of the following content is from this article.Hard Disk Planning
Before installation, plan the hard disk allocation. Although the partitions in ZFS are full of clouds and can be dynamically adjusted, there are still some problems to consider.
The first is GPT. As hard disk capacity increases, the old MBR partition cannot meet the requirements, so GPT will or has become the mainstream. The second is that the AF sector (the so-called 4kib sector) will or has become a standard format for large-capacity hard disks. The old 512b sector format is still compatible with the AF hard disk, however, the efficiency of using the 512b sector format (so-called 512e mode) on the AF hard disk is relatively low. See this article.
So I plan this 1 TB hard disk (the actual capacity is 932 GB ):
boot: 64Kswap: 4Gzroot: 16Gtank: 912G
There are four GPT partitions, with boot as the boot partition, swap as the swap partition, and zrot and tank as two ZFS pool partitions. There are two zpools because of the above mentioned af hard disk problem. In this example, zrot serves as the root ZFS of the system. Because 4kib sectors are not supported until the system is fully loaded, it can only be placed in root, and the traditional 512b sector format is used. Tank is the user ZFS and stores home, ports, and SRC here. This is the 4kib sector.
Although FreeBSD has long supported GPT partitioning, the old fdisk partitioning tool in sysinstall is still in use. In addition, because Rojo ot is also a ZFS partition, it cannot be implemented in sysinstall, therefore, the following installation procedures are all manual.
First, choose Fixit-USB to enter Fixit mode (Prompt: Fixit #) When sysinstall is started #)Installation: GPT Partition
Use gpart partition manually:
gpart create -s gpt ad4gpart add -s 64K -t freebsd-boot ad4gpart add -s 4G -t freebsd-swap -l swap0 ad4gpart add -s 16G -t freebsd-zfs -l zroot ad4gpart add -t freebsd-zfs -l tank ad4gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad4
Here, AD4 is the name of the hard disk after I use a USB flash drive. Please check and replace your hard disk name after startup.
The preceding commands are used to create GPT partition tables, create boot partitions, swap partitions, zrot partitions, and tank partitions, and write GPT boot records. Labels are added except for the boot partition to facilitate subsequent operations.Install: Create ZFS
First, you need to load the relevant ZFS module:
kldload /mnt2/boot/kernel/opensolaris.kokldload /mnt2/boot/kernel/zfs.kokldload /mnt2/boot/kernel/geom_nop.ko
Here, geom_nop is used for the later use of the 4kib partition format.
Create a system zpool first:
mkdir /boot/zfszpool create zroot /dev/gpt/zrootzpool set bootfs=zroot zroot
Create a tank zpool that supports 4 kib:
Gnop create-s 4096/dev/GPT/tankzpool create tank/dev/GPT/tank. nopzdb-C tank # Check ashift = 12 Note that 4kib is successful zpool export tankgnop destroy/dev/GPT/tank. nopzpool import tankzdb-C tank # Check again that ashift is still 12
First, create a virtual gnop device and specify the 4kib format. Pay attention to the tank. Nop. Check whether the value of the ashift parameter is 12 after creation. If the value is still 9 (in 512b format), check and redo it. After confirming that there are no errors, export the zpool, delete the gnop device, and then re-import the zpool. After checking that the ashift parameter is correct again, the zpool with 4kib is created successfully.
Create a ZFS partition. Because the system does not support the 4kib format, the root is put in the Rojo ot (except for/tmp, which will be loaded with MD later ), however, home is still in tank:
zfs create tank/homeInstallation: Prepare to install the system
As mentioned above, manual installation:
export DESTDIR="/zroot"cd /dist/8.*cd base && ./install.shcd ../lib32 && ./install.shcd ../manpages && ./install.shcd ../src && ./install.sh allcd ../kernels && ./install.sh genericcp -Rlpv /zroot/boot/GENERIC/* /zroot/boot/kernel/
Configure the basic system and ZFS boot Configuration
chroot /zrootInstallation: Pre-installation Configuration
Basic configuration file
Loader_zfs_support = Yes
Ahci_load = "yes"
Zfs_load = "yes"
VFS. Root. mountfrom = "ZFS: zrot"
VFS. Root. mountfrom. Options = "RW"
VFS. ZFS. prefetch_disable = 0
HW. PCI. do_power_nodriver = 3
Hostname = "gptzfsboot.freebsd.org"
Defaultrouter = "10.0.0.1"
Ifconfig_re0 = "Inet 10.0.0.1 netmask 255.255.255.0"
Tmpmfs = "yes"
Tmpsize = "512 M"
Zfs_enable = "yes"
Powerd_enable = "yes"
Powerd_flags = "-A hadp-B hadp-N hadp-I 25-P 1500"
/Dev/GPT/swap0 none swap SW 0 0Installation: Compile and install
Compile and install a bootloader that supports ZFS
mount -t devfs devfs /devexport DESTDIR=""cd /usr/src/sys/boot/make obj && make depend && makecd i386/loadermake installInstallation: configuration after installation
Basic Setting commands
Passwdtzsetupcd/etc/Mail & make aliases # exit chrootumount/devexitInstallation completed
cp /boot/zfs/zpool.cache /zroot/boot/zfs/export LD_LIBRARY_PATH=/mnt2/libzfs unmount -azfs set mountpoint=legacy zrootzfs set mountpoint=/home tank/homeexit
After the installation of the home server system is complete, you can perform system optimization and application configuration. For example, ZFS's compression function is used to store source code and ports, and a scheduled snapshot is created for important data and deduplication is performed for redundant data. The advantage of ZFS is here. In addition, some system monitoring software and various service software are installed.