# Help me mount filesystem in FreeBSD 9.0 RC-1



## valsorym (Nov 9, 2011)

[ I can not mount filesystem in FreeBSD 9.0 RC-1 ]

Hi all, now I install FreeBSD 9.0 RC-1 don't use "bsdinstall".
I create USB Flash from FreeBSD-9.0-RC1-i386-memstick.img.
Reboot my laptop and load from My USB choose <Live CD> in "Welcome" window.

Use gpart software I destroy my HDD (/dev/ada0). After, I create GPT scheme and next partition view:
* For boot sector I use -t freebsd-boot, from swap - freebsd-swap, for other - freebsd-ufs.

```
# gpart show -l ada0
       =>          34    625142381    ada0     GPT     (298G)
                   34          256       1     boot    (128k)
                  290      8388608       2     swap    (4.0G)
              8388898      4194304       3     root    (2.0G)
             12583202      8388608       4     var     (4.0G)
             20971810      8388608       5     tmp     (4.0G)
             29360418     67108864       6     usr      (32G)
             96469282    528673133       7     home    (252G)

        # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
```
Me need mount all sectors and repack: base.txz, kernel.txz, doc.txz, ports.txz, src.txz from /usr/freebsd-dist in My HDD. 
* For that I loved BSDINSTALL (against SYSINSTALL) - because you can turn off BSDINSTALL!


```
# mkdir -p /mnt/f9
```

I don't understand.

```
# mount -t ufs /dev/ad0p3 /mnt/f9
mount: /dev/ad0p3 : Invalid argument

# mount -t ufs /dev/ada0p3 /mnt/f9
mount: /dev/ada0p3 : Invalid argument

# mount /dev/gpt/root /mnt/f9
mount: /dev/gpt/root : Invalid argument
```
Where Is my bad? (Non in DNA (deoxyribonucleic acid) - even told the doctor)

That's all that I could do:

```
Install FreeBSD 9.0 RC-1


    Create USB Flash.
    =================
    Now I have FreeBSD any version, and ftp/wget.
    1. 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"

    2. 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
       
    3. Create LiveUSB FreeBSD 9.0 RC-1 Flash.
       # dd if=FreeBSD-9.0-RELEASE-i386-memstick.img of=/dev/da0 bs=64k

    4. Rewrite parameters of your LiveUSB FreeBSD 9.0 Flash. 
       * My Flash has one slice - it detected how /dev/da0s1:
       # moutn -t ufs /dev/da0s1 /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 block size in your HDD, add it parameters in
       loader.conf. If it is not - go to the "Create partition on your HDD"
       section.
       # echo 'kern.cam.ada.0.quirks="1"' >> /mnt/boot/loader.conf
       * ! My HDD detected how /dev/ada0, If you  used GPT scheme and your
         block size be have 4096b ~ 4Kb. If you have device /dev/ada1 - you
         must write how: kern.cam.ada.1.quirks="1" .. etc.
       
    Create partition on your HDD.
    =============================
    1. Run LiveUSB FreeBSD 9.0.
       # umount /mnt
       # reboot now
       * ! No the disconnect your FreeBSD LiveUSB.
       * Enter in your BIOS to boot from USB device.

    2. You are run LiveUSB FreeBSD 9.0 and choose button <LiveCD> in "Welcome"
       window. Okay, you have root access in virtual OS FreeBSD 9.0.
       *Sorry for my English.
       Enter login: root
       password: <empty>

    3. To check the settings.
       If you use 4k b/s in your HDD, and added 'kern.cam.ada.0.quirks="1" in
       loader.conf: 

       # 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".

    4. Clear all partitions of my 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

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

       Create BOOT sector ~ 128Kb.
       * If you use 4k boot size on your HDD, use first seek in 40 blocks
         (etc: -b 40) to align the sections. I have a 512b block size on my
         HDD, I use -b 34 blocks seek.
       (in -b and -s flags use next cliche: Xk for Kb, Xm for Mb, Xg for Gb or
       empty, etc X - for bloks).
       # gpart add -b 34 -s 128k -t freebsd-boot -l "boot" ada0

       Create SWAP ~ 4G.
       # gpart add -b 290 -s 4g -t freebsd-swap -l "swap" ada0

       Creste ROOT sector ~ 2G.
       * Use freebsd-zfs type if you use ZFS. In FreeBSD 8 you should be load:
         kldload /mnt2/boot/kernel/opensolaris.ko
         kldload /mnt2/boot/kernel/zfs.ko
       I be used UFS file system.
       # gpart add -b 8388898 -s 2g -t freebsd-ufs -l "root" ada0

       Create VAR sector ~ 4G.
       # gpart add -b 12583202 -s 4g -t freebsd-ufs -l "var" ada0
    
       Create TMP sector ~ 4G.
       # gpart add -b 20971810 -s 4g -t freebsd-ufs -l "tmp" ada0

       Create USR sector ~ 32G.
       # gpart add -b 29360418 -s 32g -t freebsd-ufs -l "usr" ada0

       Create HOME sector ~ OTHER.
       # gpart add -b 96469282  -t freebsd-ufs -l "home" ada0

       * This moment, I realized that the flag -b I could not write.
       Result.
       # gpart show -l ada0
       =>          34    625142381    ada0     GPT     (298G)
                   34          256       1     boot    (128k)
                  290      8388608       2     swap    (4.0G)
              8388898      4194304       3     root    (2.0G)
             12583202      8388608       4     var     (4.0G)
             20971810      8388608       5     tmp     (4.0G)
             29360418     67108864       6     usr      (32G)
             96469282    528673133       7     home    (252G)
    
       Install protective Protected MBR (pmbr) from programs that do not know
       GPT, and GPART loader gptzfsboot.
       # gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0

    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!
    Now my device HDD has look:
        /dev/ad0
        /dev/ad0p1      - boot
        /dev/ad0p2      - swap
        ... (3 - root, 4 - var, 5 - tmp, 6 - usr)
        /dev/ad0p7      - home
    
    1. Mount all sectors (slices) for your system.
       # mkdir -p /mnt/f9

!!!!!!!!!!!!!! I do not know how to mount !!!!!!!!!!!!!!!
```


----------



## valsorym (Nov 9, 2011)

Oh, pancake. I did not ask the file system (I do not  make the formatting).


----------



## wblock@ (Nov 9, 2011)

doorways said:
			
		

> [ I can not mount filesystem in FreeBSD 9.0 RC-1 ]
> 
> Hi all, now I install FreeBSD 9.0 RC-1 don't use "bsdinstall".
> I create USB Flash from FreeBSD-9.0-RC1-i386-memstick.img.
> ...



Looks mostly good.  The root filesystem normally comes before swap, although that's not a big deal.  Alignment is not quite even for 4K sectors, probably not a problem with a 300G drive.



> Me need mount all sectors and repack: base.txz, kernel.txz, doc.txz, ports.txz, src.txz from /usr/freebsd-dist in My HDD.
> * For that I loved BSDINSTALL (against SYSINSTALL) - because you can turn off BSDINSTALL!
> 
> 
> ...



Creating the partitions with gpart(8) does not format them.  For that, use newfs(8):
`# newfs -j /dev/gpt/root`


----------



## valsorym (Nov 9, 2011)

```
# newfs /dev/gpt/root
# newfs -U /dev/gpt/var
# newfs -U /dev/gpt/tmp
# newfs -U /dev/gpt/usr
# newfs -U /dev/gpt/home

# mount /dev/gpt/root /mnt/f9
```

- All work! Sorry me.


----------



## valsorym (Nov 9, 2011)

What do you think: I should be delete this post?


----------



## valsorym (Nov 9, 2011)

Yes, thank you wblock@.


----------



## wblock@ (Nov 9, 2011)

On FreeBSD-9, I would use -j to enable SU+J.  Somewhere recently I thought I saw something about not using soft updates when using SU+J, but can't find it now.


----------



## valsorym (Nov 9, 2011)

> Originally Posted by *wblock@*.
> Alignment is not quite even for 4K sectors, probably not a problem with a 300G drive.



I did not do the alignment for 4k.
I just described this moment. Do you think me need to do alignment?
How do I know what block size in my HDD? (Only in the technical info my HDD?)


----------



## valsorym (Nov 9, 2011)

> Originally Posted by *wblock@*.
> On FreeBSD-9, I would use -j to enable SU+J. Somewhere recently I thought I saw something about not using soft updates when using SU+J, but can't find it now.



Oh, thanks for the tip. Do not worry, all the information I can find myself. I only need beacons that would know where to go.


----------



## wblock@ (Nov 9, 2011)

doorways said:
			
		

> I did not do the alignment for 4k.
> I just described this moment. Do you think me need to do alignment?
> How do I know what block size in my HDD? (Only in the technical info my HDD?)



`% diskinfo -v ad0`
might show it correctly.  Some drives lie, saying that have 512-byte sectors even when they do not.  Most drives with 4K sectors are either 1T or larger, or SSDs.  Even on disks with 512-byte sectors, aligning partitons to 4K will do no harm and is not a bad habit.  Also see the -a option to gpart(8).


----------



## valsorym (Nov 10, 2011)

Thank you wblock@.



> Originally Posted by *wblock@.*
> Even on disks with 512-byte sectors, aligning partitons to 4K will do no harm and is not a bad habit.


It is good. 


```
# diskinfo -v ada0
ada0
    512             # sectorsize
    320072933376    # mediasize in bytes (298G)
    625142448       # mediasize in sectors
    512             # stripsize
    0               # stripoffset
    620181          # Cylinders according to frimware.
    16              # Heads according to frimware.
    63              # Sectors according to frimware.
    5VH4CYKB        # Disk ident.
```

We are interesting "stripeoffset" string. If balance by div on "stripsize" is zero - it is okay. 
[CMD="Code c/c++:"]0 % 512 // == 0[/CMD]
But I shared my HDD use 512b sectorsize. 

I add to my LiveCd on my USB Flash device in /boot/loader.conf next command:
`kern.cam.ada.0.quirks="1"`

Save, and reboot my LiveCd.
* Before I writed what I rewrite /etc/fstab on my LiveCd and add opportunity RW.

```
# cat /etc/fstab
/dev/ufs/FreeBSD_Install / ufs rw,noatime 1 1
```

Okay, now I removing all slices (gpart delete -i N ada0) and use: gpart destroy ada0.


```
# gpart create -s GPT ada0
```

If we are use 4k sector size alignment then first sector should be has seek on 40 blocks.
Boot sector be has 128Kb.


```
# gpart add -b 40 -s 128k -a 4k -t freebsd-boot -l "boot" ada0
# gpart show ada0
=>        34  625142381    ada0    GPT          (298G)
          34          6          - free -       (3.0k)
          40        256       1  freebsd-boot   (128k)
         296  625142119          - free -       (298G)
```
What do you think: Is that bad?


```
# gpart add -s 4g -a 4k -t freebsd-swap -l "swap" ada0
# gpart add -s 2g -a 4k -t freebsd-ufs -l "root" 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

# gpart show ada0
=>        34  625142381    ada0    GPT          (298G)
          34          6          - free -       (3.0k)
          40        256       1  freebsd-boot   (128k)
         296    8388608       2  freebsd-swap   (4.0G)
     8388904    4194304       3  freebsd-ufs    (2.0G)
    12583208    8388608       4  freebsd-ufs    (4.0G)
    20971816    8388608       5  freebsd-ufs    (4.0G)
    29360424   67108864       6  freebsd-ufs    (32G)
    96469288  528673120       7  freebsd-ufs    (252G)
   625142408          7          - free -       (3.5k)
```

It is good or not good?


```
# 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.
```
[CMD="Code c/c++:"] stripoffset % stripsize // should be 0[/CMD]
[CMD="Code c/c++:"] 0 % 4096 // == 0[/CMD]
* If believe docs - it is good.

Finaly:

```
# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
```

Tell me - it is good layout?


----------



## wblock@ (Nov 10, 2011)

Looks okay.  A couple of notes.

Using labels is good.  It's also a good idea to make them unique to that disk to prevent duplicate labels when another disk is connected.

Also, I would probably switch the first UFS partition with the swap partition.  Performance-wise, little difference, but it's semi-standard to have the first filesystem partition start at 1M.  So freebsd-boot (512K), blank space, freebsd-ufs (starts at 1M, 2G size), freebsd-swap (4G), ...


----------



## valsorym (Nov 10, 2011)

> Originally Posted by *wblock@.*
> So freebsd-boot (512K), blank space, freebsd-ufs (starts at 1M, 2G size), freebsd-swap (4G), ...



Thank you. I work (after destroy my HDD):
It so.

```
# gpart create -s GPT ada0
# 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
```

And result:

```
# 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)
```
wblock@ thank you  for the tips.
* You're like an angel in the realm of demons.


----------



## valsorym (Nov 10, 2011)

O, I format my system next view:

```
# newfs -J /dev/gpt/root
       # newfs -j /dev/gpt/var
       # newfs -U /dev/gpt/tmp
       # newfs -j /dev/gpt/usr
       # newfs -j /dev/gpt/home
```
* Magazine in /tmp  is superfluous.
* root sector do not use SU+J, I use -J (only magazine).


----------



## wblock@ (Nov 10, 2011)

Might as well use SU+J on /tmp also, just so that if the machine reboots there isn't a long wait for fsck on that filesystem.

Thanks for the compliments!


----------



## valsorym (Nov 10, 2011)

Thank for you!
Final accord in here.


----------

