Solved [Solved] Install FreeBSD 9 without bsdinstall

Demontager

Member

Reaction score: 4
Messages: 61

Recently rented remote server and by default it comes with FreeBSD9.1 amd64 on UFS. Only one hard drive available. The problem is that provider offers only FreeBSD recovery CD. So I need to install ZFS using recovery without having the automatic bsdinstall installer.
My steps:
Code:
gpart destroy -F ada0
gpart create -s gpt ada0
add -b 34 -s 64k -t freebsd-boot ada0
gpart add -s 4G -t freebsd-swap -l swap0 ada0
gpart add -t freebsd-zfs -l disk0 ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0

gpart show
=>        34  3907029101  ada0  GPT  (1.8T)
          34         128     1  freebsd-boot  (64k)
         162           6        - free -  (3.0k)
         168     4194304     2  freebsd-swap  (4.0G)
     4194472  3902834656     3  freebsd-zfs  (1.8T)
  3907029128           7        - free -  (3.5k)
From this point don't know how to proceed to base.txz kernel.txz bootstraping.
Server configuration: Intel Core i3, 8 GB RAM, 2 TB HDD
 

vanessa

Active Member

Reaction score: 16
Messages: 183

I suggest something like the following (attention, I don't check if I missed something, so think over it):

# kldload zfs
# zpool create zroot /dev/gpt/disk0
# zpool set bootfs=zroot zroot
# fetch [url=ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/9.2-RELEASE/base.txz]ftp://ftp.freebsd.org/pub/FreeBSD/relea ... E/base.txz[/url]
# tar xfp base.txz -C /zroot
repeat for kernel.txz and eventually for lib32.txz
# chroot /zroot
# echo 'zfs_enable="YES"' > /etc/rc.conf
# echo 'hostname="_hostname here_"' >> /etc/rc.conf
# echo 'ifconfig_XX0="DHCP"' >> /etc/rc.conf
# echo 'zfs_load="YES"' > /boot/loader.conf
# echo 'vfs.root.mountfrom="zfs:zroot"' >> /boot/loader.conf
# passwd
# tzsetup

Don't forget to also create /etc/fstab with a line for the swap inside.
 
OP
Demontager

Demontager

Member

Reaction score: 4
Messages: 61

Thanks for the manuals!
Since my server in OVH, searched bit specific info and found here http://kdl.nobugware.com/post/2012/02/07/freebsd-90-zfs-root-ovh
Then adapted for one hard drive. Everything seems fine until i do
Code:
rescue-bsd# zfs set mountpoint=legacy rpool/root
cannot unmount '/tmp/mntzfs': Device busy
To be quick i have created bash script
Code:
#!/bin/sh

#Create slices
gpart destroy -F ada0
gpart create -s gpt ada0
gpart add -b 34 -s 64k -t freebsd-boot ada0
gpart add -s 4G -t freebsd-swap -l swap0 ada0 
gpart add -t freebsd-zfs -l disk0 ada0 
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0 

#Create ZFS
zpool create -o cachefile=/boot/zfs/zpool.cache -m none -f rpool /dev/gpt/disk0 
zfs set checksum=fletcher4 rpool 
zfs create rpool/root 
mkdir /tmp/mntzfs 
zfs set mountpoint=/tmp/mntzfs rpool/root  
zfs create -o canmount=off  rpool/root/usr 
zfs create  -o canmount=off rpool/root/var 
zfs create -o compression=on -o exec=on -o setuid=off rpool/root/tmp 
zfs create -o compression=gzip -o setuid=off  rpool/root/usr/ports 
zfs create -o compression=off -o exec=off -o setuid=off rpool/root/usr/ports/distfiles 
zfs create -o compression=off -o exec=off -o setuid=off rpool/root/usr/ports/packages 
zfs create -o compression=gzip -o exec=off -o setuid=off  rpool/root/usr/src 
zfs create -o compression=lzjb rpool/root/usr/obj 
zfs create -o compression=lzjb  -o exec=off     -o setuid=off   rpool/root/var/crash 
zfs create -o compression=off -o exec=off -o setuid=off   rpool/root/var/empty 
zfs create -o compression=lzjb  -o exec=on -o setuid=off   rpool/root/var/tmp  
zpool export rpool 
zpool import -o cachefile=/tmp/zpool.cache rpool 
chmod 1777 /tmp/mntzfs/tmp 
chmod 1777 /tmp/mntzfs/var/tmp  

#Fetch files
cd /tmp/mntzfs 
mkdir fileinstall 
cd fileinstall 
fetch http://ftp1.fr.FreeBSD.org/pub/FreeBSD/releases/amd64/9.2-RELEASE/base.txz 
fetch http://ftp1.fr.FreeBSD.org/pub/FreeBSD/releases/amd64/9.2-RELEASE/kernel.txz 
cat base.txz | tar --unlink -xpJf - -C /tmp/mntzfs
cat kernel.txz | tar --unlink -xpJf - -C /tmp/mntzfs
cp /tmp/zpool.cache /tmp/mntzfs/boot/zfs/zpool.cache 

#Add configs
echo 'zfs_enable="YES"' >> /tmp/mntzfs/etc/rc.conf 
echo 'zfs_load="YES"' >> /tmp/mntzfs/boot/loader.conf 
echo 'if_em_load="YES"' >> /tmp/mntzfs/boot/loader.conf 
echo 'vfs.root.mountfrom="zfs:rpool/root"' >> /tmp/mntzfs/boot/loader.conf  
echo 'sshd_enable="YES"' >> /tmp/mntzfs/etc/rc.conf 
echo 'ifconfig_em0="inet 198.100.XXX.XX netmask 255.255.255.0 broadcast 198.100.XXX.XX"' >> /tmp/mntzfs/etc/rc.conf 
echo 'defaultrouter="198.100.XXX.XXX"' >> /tmp/mntzfs/etc/rc.conf 
echo 'hostname="ks60052.ip-198-XXX-XX.net"' >> /tmp/mntzfs/etc/rc.conf
 

wblock@

Beastie Himself
Developer

Reaction score: 3,683
Messages: 13,851

Demontager said:
To be quick i have created bash script
Code:
#!/bin/sh

#Create slices
gpart destroy -F ada0
gpart create -s gpt ada0
gpart add -b 34 -s 64k -t freebsd-boot ada0
That keeps showing up, it must be in some common article. I think it is sub-optimal. This is better, creating an aligned boot partition (which does not really matter) that is the maximum allowed size:
Code:
gpart add -t freebsd-boot -l gpboot -b 40 -s 512K ada0
Add the first filesystem partition starting at block 2048 (1M) for compatibility with other software and alignment:

Code:
gpart add -b 2048 -s 4G -t freebsd-swap -l swap0 ada0
 
OP
Demontager

Demontager

Member

Reaction score: 4
Messages: 61

Great, thank you! Installation accomplished fine and system rebooted to FreeBSD 9.2 on ZFS.

Still missed something:
Code:
portsnap fetch
Looking up portsnap.FreeBSD.org mirrors... none found.
Fetching public key from portsnap.FreeBSD.org... failed.
No mirrors remaining, giving up
Also a question, it is ok for my configuration to keep 8 GB swap on ZFS? Machine planned as web server to host plenty of dynamic websites.

Current status:
Code:
 zfs list
NAME                             USED  AVAIL  REFER  MOUNTPOINT
rpool                           9.06G  1.78T    31K  none
rpool/root                       825M  1.78T   824M  legacy
rpool/root/tmp                    35K  1.78T    35K  /tmp
rpool/root/usr                   188K  1.78T    31K  /usr
rpool/root/usr/obj                31K  1.78T    31K  /usr/obj
rpool/root/usr/ports              95K  1.78T    33K  /usr/ports
rpool/root/usr/ports/distfiles    31K  1.78T    31K  /usr/ports/distfiles
rpool/root/usr/ports/packages     31K  1.78T    31K  /usr/ports/packages
rpool/root/usr/src                31K  1.78T    31K  /usr/src
rpool/root/var                   126K  1.78T    31K  /var
rpool/root/var/crash            31.5K  1.78T  31.5K  /var/crash
rpool/root/var/empty              31K  1.78T    31K  /var/empty
rpool/root/var/tmp                32K  1.78T    32K  /var/tmp
rpool/swap                      8.25G  1.78T    16K  -
 

rusty

Well-Known Member

Reaction score: 45
Messages: 267

1/ Sounds like a firewall or network issue.

2/ Should be able to alter swap's size with;
zfs set volsize=nG rpool/swap
 
OP
Demontager

Demontager

Member

Reaction score: 4
Messages: 61

Oops, I forgot /etc/resolv.conf:
Code:
nameserver 8.8.8.8
nameserver 8.8.4.4
Fetching normally now. Big thanks to everyone who helped me in this thread!
 
Top