• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

HOWTO: Install FreeBSD 9.0 RC-1 USB Flash, UFS+J (hands mode

valsorym

Well-Known Member

Thanks: 20
Messages: 419

#1
Do not judge harshly.
Today installed FreeBSD 9.0 RC1 and decided to share with applicants.
* applicants/competitors - people who are looking for information on the same topic. Sorry for my English.


Create USB Flash. **Be sure to read "D" section.
--------------------------------------------------
--------------------------------------------------
Now I have FreeBSD any version, and ftp/wget software.

Section A:
==========
Download FreeBSD-9.0-RC1-i386-memstick.img,
Code:
# mkdir ~/freebsd && cd ~/freebsd
# wget "ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/ISO-IMAGES/9.0/FreeBSD-9.0-RC1-i386-memstick.img"
Section B:
==========
Connect your USB Flash device and clear it. My Flash detect how /dev/da0:
Code:
# dd if=/dev/zero of=/dev/da0 bs=512 count=4
Section C:
==========
Create LiveUSB FreeBSD 9.0 RC-1 Flash.
Code:
# dd if=FreeBSD-9.0-RELEASE-i386-memstick.img of=/dev/da0 bs=64k
Section D:
==========
Rewrite parameters of your LiveUSB FreeBSD 9.0 Flash. My Flash has one slice - it detected how /dev/da0a:
Code:
# moutn -t ufs /dev/da0a /mnt
# echo "/dev/ufs/FreeBSD_Install / ufs rw,noatime 1 1" > /mnt/etc/fstab
* I added opportunity write in root (and others) sectors on LiveUSB.

If you have 4K sector size in your HDD, add it parameters in loader.conf. In any case, you can use the alignment of 4k.
[!] Further in the text, we will focus on the alignment of 4k sector size.
Code:
# echo 'kern.cam.ada.0.quirks="1"' >> /mnt/boot/loader.conf
[!] My HDD detected how /dev/ada0. If you have device /dev/ada1 - you must write how: kern.cam.ada.1.quirks="1" .. etc.


Create partition on your HDD.
--------------------------------
--------------------------------
Section A:
==========
Run LiveUSB FreeBSD 9.0 with your USB Flash device.
Code:
# umount /mnt && reboot now
[!] No the disconnect your FreeBSD LiveUSB.
* In your BIOS choose option boot from USB device.

Section B:
==========
You are run LiveUSB FreeBSD 9 and choose button <Live CD> in "Welcome" window. Okay, you have root access in LiveUSB FreeBSD 9.0 RC-1 OS.
Enter:
login: root
password: <empty>

Section C:
==========
To check the settings.
* If you use 4k sector size alignment, and added 'kern.cam.ada.N.quirks' in /boot/loader.conf, you should get the following result:

Code:
# geom disk list ada0
 Geom name: ada0
 Providers:
 1. Name: ada0
    Mediasize: 320072933376 (298G)
    Sectorsize: 512
    Stripesize: 4096
    Stripeoffset: 0
    Mode: r0w0e0
    descr: ST9320423AS
    ident: (null)
    fwsectors: 63
    fwheads: 16
* We can see "Stripesize: 4096", else you see "Stripesize: 512" bytes.

Section D:
==========
Clear all partitions of your HDD.
* We will use the gpart. Details available here. Thank wblock @.

Code:
# gpart show ada0
  =>      63 312581745 ipsd0 MBR  (298G)        
          63  11293632     1 !12 [active]  (5.4G)   
    11293695 301288113       - free -  (298G)
Now I have one partition:
Code:
# gpart delete -i 1 ada0
** If you have some others partition (2, 3, 4 ... 128) - remove it. If you do not do this - You can not run 'gpart destroy ada0'. You will receive a message: "Device busy!".
Code:
# gpart delete -i 2 ada0
# gpart delete -i 3 ada0
...
# gpart delete -i 128 ada0
Delete MBR sector (or other old scheme).
Code:
# gpart destroy ada0
Section E:
==========
Create new partition scheme on your HDD.
Create GPT scheme.
Code:
# gpart create -s GPT ada0
** In -b and -s flags use next cliche: Xk for Kb, Xm for Mb, Xg for Gb or empty, etc X - for bloks.
** I will use a 4k aligned and I use -a flag.

Code:
# gpart add -s 512k -a 4k -t freebsd-boot -l "boot" ada0
# gpart add -b 1m -s 2g -a 4k -t freebsd-ufs -l "root" ada0
# gpart add -s 4g -a 4k -t freebsd-swap -l "swap" ada0
# gpart add -s 4g -a 4k -t freebsd-ufs -l "var" ada0
# gpart add -s 4g -a 4k -t freebsd-ufs -l "tmp" ada0
# gpart add -s 32g -a 4k -t freebsd-ufs -l "usr" ada0
# gpart add -a 4k -t freebsd-ufs -l "home" ada0
Set the boot loader.
Code:
# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
bootcode written to ada0
Result for my HDD:
Code:
# gpart show ada0
 =>        34  625142381    ada0    GPT          (298G)
           34          6          - free -       (3.0k)
           40       1024       1  freebsd-boot   (512k)
         1064    4194304       2  freebsd-ufs    (2.0G)
      4195368    8388608       3  freebsd-swap   (4.0G)
     12583976    8388608       4  freebsd-ufs    (4.0G)
     20972584    8388608       5  freebsd-ufs    (4.0G)
     29361192   67108864       6  freebsd-ufs    (32G)
     96470056  528672352       7  freebsd-ufs    (252G)
    625142408          7          - free -       (3.5k)
Checking the alignment:
Code:
# diskinfo -v ada0
  ada0
      512             # sectorsize
      320072933376    # mediasize in bytes (298G)
      625142448       # mediasize in sectors
      4096            # stripsize
      0               # stripoffset
      620181          # Cylinders according to frimware.
      16              # Heads according to frimware.
      63              # Sectors according to frimware.
      5VH4CYKB        # Disk ident.
[!] echo stripoffset % stripsize | bc - should be 0.
Code:
# echo 0 % 4096 | bc
0
- it is good.

Section F:
==========
Create file system.
Use journaling softupdates SU+J - you should be use -j flag:
Code:
# newfs -J /dev/gpt/root
# newfs -j /dev/gpt/var
# newfs -J /dev/gpt/tmp
# newfs -j /dev/gpt/usr
# newfs -j /dev/gpt/home
* Sectors /root and /tmp has only magazine (use beeg -J flag), other has -SU+J scheme.


Install FreeBSD 9.0 on your HDD.
---------------------------------
---------------------------------
* For that I loved BSDINSTALL (against SYSINSTALL) - because you can turn off BSDINSTALL!
* Do not reboot and continue to work on!
Section A:
==========
Mount all slices for your system.
Code:
# mkdir -p /mnt/f9
# mount /dev/gpt/root /mnt/f9
# cd /mnt/f9
# mkdir -p boot var tmp usr
# chmod 1777 boot var tmp usr
# cd ~/

# mount /dev/gpt/var /mnt/f9/var
# mount /dev/gpt/tmp /mnt/f9/tmp
# mount /dev/gpt/usr /mnt/f9/usr

# mkdir -p /mnt/f9/usr/home
# mount /dev/gpt/home /mnt/f9/usr/home
Section B:
==========
Install system.
I recommend create folder on your USB Flash and create next scripts:
Code:
# mkdir -p /lorddevil
# cd /lorddevil/
# vi setupdevil
~~~~
Code:
#!/bin/sh
# Where will unpack the system.
rootsector='/mnt/f9'
       
# Whence do we unpack the system.
cd /usr/freebsd-dist

# Installation options (use the following packages):
# * All others pkg: doc.txz ports.txz src.txz
# * For x86 CPU (minimal): base.txz kernel.txz
# * For amd64 CPU (minimal): base.txz kernel.txz lib32.txz

# I use: "x86 CPU (minimal)":
for i in base.txz kernel.txz;
    do (cat ${i} | tar --unlink -xpJf - -C ${rootsector:-/}); done
      
exit 0
:wq!
~~~~

Run it:
Code:
# chmod 1555 setupdevil
# ./setupdevil
* Do not have time to drink tea! Do not go!

Section C:
==========
Create /etc/fstab file.
Open /mnt/f9/etc/fstab file, and write it:

Code:
       /dev/gpt/swap    none         swap    sw     0     0
       /dev/gpt/root    /            ufs     rw     1     1
       /dev/gpt/var     /var         ufs     rw     2     2
       /dev/gpt/tmp     /tmp         ufs     rw     2     2
       /dev/gpt/usr     /usr         ufs     rw     2     2
       /dev/gpt/home    /usr/home    ufs     rw     2     2
Section D:
==========
At the end of...
You can immediately skip to step 2.
1. Now you can further customize your system.
Mount /dev slice and change the root point:
Code:
# mount -t devfs /dev /mnt/f9/dev
# chroot /mnt/f9 /bin/sh
* Once you're done (setting the Internet, installing ports, rebuild the kernel, etc.) exit this mode and go to step 2.
Code:
# exit
2. Unmount sectors and reboot your computer.
Code:
# umount /mnt/f9/usr/home
# umount /mnt/f9/usr
# umount /mnt/f9/tmp
# umount /mnt/f9/var
# umount /mnt/f9
# reboot now
* If something can not unmount use: umoutt -f <mount_point>
[!] Do not forget to disconnect the USB Flash.
[!] After load real system rewrite root password.
 

valsorym

Well-Known Member

Thanks: 20
Messages: 419

#3
This HOWTO is convenient to write in the text file and save in their own USB Flash.
Code:
                           Install FreeBSD 9.0 RC-1
                             (H A N D S  M O D E)

Ukraine
10.11.2011
Doorways

------------------------------------------------------------------------------
    Create USB Flash.
------------------------------------------------------------------------------
    Now I have FreeBSD any version, and ftp/wget software.
    A. Download FreeBSD-9.0-RC1-i386-memstick.img,
       # mkdir ~/freebsd && cd ~/freebsd
       # wget "ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/i386/
                    ISO-IMAGES/9.0/FreeBSD-9.0-RC1-i386-memstick.img"

    B. Connect your USB Flash device and clear it.
       My Flash detect how /dev/da0:
       # dd if=/dev/zero of=/dev/da0 bs=512 count=4
       
    C. Create LiveUSB FreeBSD 9.0 RC-1 Flash.
       # dd if=FreeBSD-9.0-RELEASE-i386-memstick.img of=/dev/da0 bs=64k

    D. Rewrite parameters of your LiveUSB FreeBSD 9.0 Flash. 
       My Flash has one slice - it detected how /dev/da0a:
       # moutn -t ufs /dev/da0a /mnt
       # echo "/dev/ufs/FreeBSD_Install / ufs rw,noatime 1 1" > /mnt/etc/fstab
       * I added opportunity write in root (and others) sectors on LiveUSB.
 
       ** If  you  have  4K  sector  size  in  your HDD, add  it parameters in
          loader.conf. In any case, you can use the alignment of 4k.
          [!] Further in the text, we will focus on the alignment of 4k sector
          size.
       # echo 'kern.cam.ada.0.quirks="1"' >> /mnt/boot/loader.conf
       * [!] My HDD detected how /dev/ada0. If you have device /dev/ada1 - you
         must write how: kern.cam.ada.1.quirks="1" .. etc.
  
------------------------------------------------------------------------------     
    Create partition on your HDD.
------------------------------------------------------------------------------
    A. Run LiveUSB FreeBSD 9.0 with your USB Flash device.
       # umount /mnt && reboot now
       * [!] No the disconnect your FreeBSD LiveUSB.
       * In your BIOS choose option boot from USB device.

    B. You are run LiveUSB FreeBSD 9 and choose  button <Live CD> in "Welcome"
       window. Okay, you have root access in LiveUSB FreeBSD 9.0 RC-1 OS.
       Enter:
           login: root
           password: <empty>

    C. To check the settings.
       If you use 4k sector size alignment, and added  'kern.cam.ada.N.quirks'
       in /boot/loader.conf, you should get the following result: 

       # geom disk list ada0
         Geom name: ada0
         Providers:
         1. Name: ada0
            Mediasize: 320072933376 (298G)
            Sectorsize: 512
            Stripesize: 4096
            Stripeoffset: 0
            Mode: r0w0e0
            descr: ST9320423AS
            ident: (null)
            fwsectors: 63
            fwheads: 16

        * We can see "Stripesize: 4096", else you see "Stripesize: 512" bytes.

    D. Clear all partitions of your HDD.
       # gpart show ada0
         =>      63 312581745 ipsd0 MBR  (298G)        
                 63  11293632     1 !12 [active]  (5.4G)   
          11293695 301288113       - free -  (298G)

       Now I have one partition:
       # gpart delete -i 1 ada0

       ** If you have some others partition (2, 3, 4 ... 128) - remove  it. If
          you do not do this - You can not run 'gpart destroy ada0'. You  will
          receive a message: "Device busy!".
          # gpart delete -i 2 ada0
          # gpart delete -i 3 ada0
          ...
          # gpart delete -i 128 ada0

       Delete MBR sector (or other old scheme).
       # gpart destroy ada0

    E. Create new partition scheme on your HDD.
       Create GPT scheme.
       # gpart create -s GPT ada0

       ** In -b and -s flags use next cliche: Xk for Kb, Xm for Mb, Xg for Gb
          or empty, etc X - for bloks.
       ** I will use a 4k aligned and I use -a flag.

       # gpart add -s 512k -a 4k -t freebsd-boot -l "boot" ada0
       # gpart add -b 1m -s 2g -a 4k -t freebsd-ufs -l "root" ada0
       # gpart add -s 4g -a 4k -t freebsd-swap -l "swap" ada0
       # gpart add -s 4g -a 4k -t freebsd-ufs -l "var" ada0
       # gpart add -s 4g -a 4k -t freebsd-ufs -l "tmp" ada0
       # gpart add -s 32g -a 4k -t freebsd-ufs -l "usr" ada0
       # gpart add -a 4k -t freebsd-ufs -l "home" ada0

       Set the boot loader.
       # gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
       bootcode written to ada0

       Result for my HDD:
       # gpart show ada0
        =>        34  625142381    ada0    GPT          (298G)
                  34          6          - free -       (3.0k)
                  40       1024       1  freebsd-boot   (512k)
                1064    4194304       2  freebsd-ufs    (2.0G)
             4195368    8388608       3  freebsd-swap   (4.0G)
            12583976    8388608       4  freebsd-ufs    (4.0G)
            20972584    8388608       5  freebsd-ufs    (4.0G)
            29361192   67108864       6  freebsd-ufs    (32G)
            96470056  528672352       7  freebsd-ufs    (252G)
           625142408          7          - free -       (3.5k)

       Checking the alignment:
       # diskinfo -v ada0
        ada0
            512             # sectorsize
            320072933376    # mediasize in bytes (298G)
            625142448       # mediasize in sectors
            4096            # stripsize
            0               # stripoffset
            620181          # Cylinders according to frimware.
            16              # Heads according to frimware.
            63              # Sectors according to frimware.
            5VH4CYKB        # Disk ident.
       [!] echo stripoffset % stripsize | bc - should be 0.
       # echo 0 % 4096 | bc
       0
       - it is good.

    F. Create file system.
       Use journaling softupdates SU+J - you should be use -j flag:
       # newfs -J /dev/gpt/root
       # newfs -j /dev/gpt/var
       # newfs -J /dev/gpt/tmp
       # newfs -j /dev/gpt/usr
       # newfs -j /dev/gpt/home
    * Sectors /root and /tmp has only magazine (use beeg -J flag), other has
      -SU+J scheme.

------------------------------------------------------------------------------
    Install FreeBSD 9.0 on your HDD.
------------------------------------------------------------------------------
    * For that  I loved BSDINSTALL (against SYSINSTALL) - because you can turn
      off BSDINSTALL!
    * Do not reboot and continue to work on!
    A. Mount all slices for your system.
       # mkdir -p /mnt/f9
       # mount /dev/gpt/root /mnt/f9
       # cd /mnt/f9
       # mkdir -p boot var tmp usr
       # chmod 1777 boot var tmp usr
       # cd ~/

       # mount /dev/gpt/var /mnt/f9/var
       # mount /dev/gpt/tmp /mnt/f9/tmp
       # mount /dev/gpt/usr /mnt/f9/usr

       # mkdir -p /mnt/f9/usr/home
       # mount /dev/gpt/home /mnt/f9/usr/home

    B. Install system.
       I recommend create folder on your USB Flash and create next scripts:
       # mkdir -p /lorddevil
       # cd /lorddevil/
       # vi setupdevil
    ~~~~
        #!/bin/sh
       
        # Where will unpack the system.
        rootsector='/mnt/f9'
       
        # Whence do we unpack the system.
        cd /usr/freebsd-dist

        # Installation options (use the following packages):
        # * All others pkg: doc.txz ports.txz src.txz
        # * For x86 CPU (minimal): base.txz kernel.txz
        # * For amd64 CPU (minimal): base.txz kernel.txz lib32.txz

        # I use: "x86 CPU (minimal)":
        for i in base.txz kernel.txz;
            do (cat ${i} | tar --unlink -xpJf - -C ${rootsector:-/}); done
      
        exit 0
    ~~~~
       :wq!

       # chmod 1555 setupdevil
       # ./setupdevil
       
       * Do not have time to drink tea! Do not go!
    
    C. Create /etc/fstab file.
       Open /mnt/f9/etc/fstab file, and write it:

       /dev/gpt/swap    none         swap    sw     0     0
       /dev/gpt/root    /            ufs     rw     1     1
       /dev/gpt/var     /var         ufs     rw     2     2
       /dev/gpt/tmp     /tmp         ufs     rw     2     2
       /dev/gpt/usr     /usr         ufs     rw     2     2
       /dev/gpt/home    /usr/home    ufs     rw     2     2
       
    D. At the end of...
       You can immediately skip to step 2.
       1. Now you can further customize your system.
          Mount /dev slice and change the root point:
          # mount -t devfs /dev /mnt/f9/dev
          # chroot /mnt/f9 /bin/sh
          
          Once  you're done (setting the  Internet, installing  ports, rebuild
          the kernel, etc.) exit this mode and go to step 2.
          # exit

        2. Unmount sectors and reboot your computer.
           # umount /mnt/f9/usr/home
           # umount /mnt/f9/usr
           # umount /mnt/f9/tmp
           # umount /mnt/f9/var
           # umount /mnt/f9
           # reboot now

           * If something can not unmount use: umoutt -f <mount_point>
   [!] Do not forget to disconnect the USB Flash.
   [!] After load real system rewrite root password.
 

gkontos

Daemon

Thanks: 455
Messages: 2,094

#4
Just out of curiosity, why would you go to all this trouble instead of using bsdinstaller ?

PS wget is not part of the OS binaries. You can use fetch instead.

Regards,

George
 

valsorym

Well-Known Member

Thanks: 20
Messages: 419

#5
Originally Posted by gkontos.
Just out of curiosity, why would you go to all this trouble instead of using bsdinstaller ?
It's very interesting! I recently went to the Windows OS (8 years, I ate, drank, never smoked, with Windows 95/98/200/NT) - UNIX opening for me - so I discovery it!

Originally Posted by gkontos.
PS wget is not part of the OS binaries. You can use fetch instead.
Ok, thanks. Thank you!
 

wblock@

Administrator
Staff member
Administrator
Moderator
Developer

Thanks: 3,607
Messages: 13,850

#6
umount(8) is misspelled in the last part. Also, I suggest using SUJ on all filesystems to avoid long fsck times.
 

valsorym

Well-Known Member

Thanks: 20
Messages: 419

#7
Originally Posted by wblock@.
umount(8) is misspelled in the last part.
Yes, thank you. My bad. I corrected all.

Originally Posted by wblock@.
Also, I suggest using SUJ on all filesystems to avoid long fsck times.
I wanted to increase the speed of these sections.
** For this reason, I had never thought to use the log to /tmp. (To understand this, read this post.)

But thanks anyway! I'll think about it.
 
Top