So, stuff happened that made it necessary for me to do a manual installation, also, I really wanted to. Most of what I need is listed in FreeBSD handbook 17.2 so it wasn't an imposible task. I've done a lot of partitioning over time, but GPT did look like it might be a step in a good direction.

First of all we locate the disk we need to fix using camcontrol.

root@amd-dev01:~ # camcontrol devlist
<ST9100823A 3.02>                  at scbus0 target 0 lun 0 (ada0,pass0)
<CF CARD 4GB Ver3.06K>             at scbus0 target 1 lun 0 (ada1,pass1)
<Generic External 2.06>            at scbus2 target 0 lun 0 (da0,pass2)
<Generic STORAGE DEVICE 9451>      at scbus3 target 0 lun 0 (da1,pass3)
<FREEBSD CTLDISK 0001>             at scbus4 target 0 lun 0 (da2,pass4)
root@amd-dev01:~ #

Here it's very important to be at least 100% sure that you're dealing with the right disk, the stuff that follows can really make a right mess of things.

So here I'll have cheated a bit, I'm going to be using da2, I've mounted a ISCSI drive using FreeBSDs ISCSI to export it from my storage server, I've even cheated some more, I've created a partition table on the drive so it doesn't look empty, but I want to use GPT for this so I'll try and create it.

root@amd-dev01:~ # gpart create -s GPT da2
gpart: geom 'da2': File exists

That shows me something is allready there, so I recheck to make sure it's the right drive and destroy the old partition and create a new gpt partition.

root@amd-dev01:~ # gpart destroy -F da2
da2 destroyed
root@amd-dev01:~ # gpart create -s GPT da2
da2 created

Then we add the partions we want, I usually got for a very simple setup, boot block if needed, swap partition as large as I can justify, and everything else in one large partition. This works ok with UFS filesystems and works like a charm on ZFS that can do all kinds of magic, if I have the RAM for it, I pick ZFS.

root@amd-dev01:~ # gpart add -t freebsd-boot -l iscsiboot -s 512K da2
da2p1 added
root@amd-dev01:~ # gpart add -t freebsd-swap -l iscsiswap -s 2G da2
da2p2 added
root@amd-dev01:~ # gpart add -t freebsd-ufs -l iscsiroot da2
da2p3 added
root@amd-dev01:~ # gpart show da2
=>       40  209715120  da2  GPT  (100G)
         40          8       - free -  (4.0K)
         48       1024    1  freebsd-boot  (512K)
       1072    4194304    2  freebsd-swap  (2.0G)
    4195376  205519776    3  freebsd-ufs  (98G)
  209715152          8       - free -  (4.0K)

This is where the whole gpt system shines a bit, I've set the labels to something unique so now I don't even have to worry about what drive I'm working on, and that's really good because the next commands can also mess up a system in a bad way.

root@amd-dev01:~ # newfs -Uj /dev/gpt/iscsiroot
/dev/gpt/iscsiroot: 100351.5MB (205519776 sectors) block size 32768, fragment size 4096
        using 161 cylinder groups of 626.22MB, 20039 blks, 80256 inodes.
        with soft updates
super-block backups (for fsck_ffs -b #) at:
 192, 1282688, 2565184, 3847680, 5130176, 6412672, 7695168, 8977664, 10260160, 11542656, 12825152,
 14107648, 15390144, 16672640, 17955136, 19237632, 20520128, 21802624, 23085120, 24367616,
 25650112, 26932608, 28215104, 29497600, 30780096, 32062592, 33345088, 34627584, 35910080,
 37192576, 38475072, 39757568, 41040064, 42322560, 43605056, 44887552, 46170048, 47452544,
 48735040, 50017536, 51300032, 52582528, 53865024, 55147520, 56430016, 57712512, 58995008,
 60277504, 61560000, 62842496, 64124992, 65407488, 66689984, 67972480, 69254976, 70537472,
 71819968, 73102464, 74384960, 75667456, 76949952, 78232448, 79514944, 80797440, 82079936,
 83362432, 84644928, 85927424, 87209920, 88492416, 89774912, 91057408, 92339904, 93622400,
 94904896, 96187392, 97469888, 98752384, 100034880, 101317376, 102599872, 103882368, 105164864,
 106447360, 107729856, 109012352, 110294848, 111577344, 112859840, 114142336, 115424832, 116707328,
 117989824, 119272320, 120554816, 121837312, 123119808, 124402304, 125684800, 126967296, 128249792,
 129532288, 130814784, 132097280, 133379776, 134662272, 135944768, 137227264, 138509760, 139792256,
 141074752, 142357248, 143639744, 144922240, 146204736, 147487232, 148769728, 150052224, 151334720,
 152617216, 153899712, 155182208, 156464704, 157747200, 159029696, 160312192, 161594688, 162877184,
 164159680, 165442176, 166724672, 168007168, 169289664, 170572160, 171854656, 173137152, 174419648,
 175702144, 176984640, 178267136, 179549632, 180832128, 182114624, 183397120, 184679616, 185962112,
 187244608, 188527104, 189809600, 191092096, 192374592, 193657088, 194939584, 196222080, 197504576,
 198787072, 200069568, 201352064, 202634560, 203917056, 205199552
Using inode 4 in cg 0 for 33554432 byte journal
newfs: soft updates journaling set
root@amd-dev01:~ #

Time to roll on a minimal system so it can be booted up and verified that it runs. And we'll do it on with pretty ascii using dpv.

root@amd-dev01:~ # mount /dev/gpt/iscsiroot /mnt
root@amd-dev01:~ # cd /mnt/
root@amd-dev01:/mnt # ls
.snap           .sujournal
root@amd-dev01:/mnt # mkdir -p usr/freebsd-install
root@amd-dev01:/mnt # fetch -o usr/freebsd-install/ \
? http://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -r`/kernel.txz \
? http://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -r`/base.txz
usr/freebsd-install//kernel.txz               100% of   30 MB   86 kBps 06m02s
usr/freebsd-install//base.txz                 100% of   80 MB  125 kBps 10m56s
root@amd-dev01:/mnt # dpv -x "cpio -i -d --quiet" -m \
? 32255748:kernel.txz usr/freebsd-install/kernel.txz \
? 84673592:base.txz usr/freebsd-install/base.txz
116,929,340 bytes read @  75,535.0 bytes/sec.
root@amd-dev01:/mnt # 

And then it's time to install the bootblocks needed.

root@amd-dev01:~ # gpart bootcode -b /mnt/boot/pmbr -p /mnt/boot/gptboot -i 1 da2
partcode written to da2p1
bootcode written to da2

Now there's plenty of room to customize the startup, I usually (ok, I've done it twice now :-)) prefer something like.

root@amd-dev01:~ # cp /etc/resolv.conf /mnt/etc
root@amd-dev01:~ # pkg -r /mnt bootstrap
root@amd-dev01:~ # pkg -r /mnt install -y vim-lite zsh sudo git py27-virtualenv py36-virtualenv
root@amd-dev01:~ # vim /mnt/etc/rc.conf

Due to the use of gpt and labels, the fstab end up looking quite nice, with no reference to the physical location of the drive, but only references to the labels we put in GPT.

/etc/fstab

/dev/gpt/iscsiroot  /   ufs  rw 1 1
/dev/gpt/iscsiswap  none swap sw

And then it's time for a reboot and see if everything worked


Comments

comments powered by Disqus