# Format to UFS2 using newfs, in installation



## Areeb Qaisar (Nov 14, 2016)

Hello,
  I have a UEFI System with GPT Partition Table.
  During the installation of FreeBSD 11, I need to format a partition to UFS2. The FreeBSD installer does not allows to format an existing partition. It instead only allows to create a new partition, which will be then be formatted. Is there any way that we can use an existing Ext4/NTFS or even an unformatted partition, and format it to UFS2?

  I have searched and even through commands, the only options I have found are, first by adding a GPT partition.

```
# gpart add -t freebsd-ufs -l ssdrootfs -b 1m -s 2g ada0
  # newfs -U -t /dev/gpt/ssdrootfs
```
  Is it possible to do something like 

```
# newfs OnExisting ada0p6
```


----------



## SirDice (Nov 14, 2016)

You cannot newfs(8) a filesystem when it's mounted.


----------



## Areeb Qaisar (Nov 14, 2016)

I have not mounted it yet. Lets say I have an unformatted partition located at /dev/sda8 (In Linux Terminology)  and ada0p8 (In FreeBSD). 
 I start the FreeBSD Setup from USB. Now All I want to do is to use the existing ada0p8 partition, and format it and start the installation. 
 Instead of deleting the partition and then re-creating it.


----------



## SirDice (Nov 14, 2016)

As long as the partition type is freebsd-ufs this should be possible. If it's another partition type you will have to remove it and re-create it with the correct type.


----------



## ANOKNUSA (Nov 15, 2016)

Some relevant information from uefi(8):



> boot1.efi searches partitions of type freebsd-ufs and freebsd-zfs for loader.efi.  The search begins with partitions on the device from which boot1.efi was loaded, and continues with other available partitions.  If both freebsd-ufs and freebsd-zfs partitions exist on the same device the freebsd-zfs partition is preferred.  boot1.efi then loads and executes loader.efi.



So you'll need to recreate the partition if you want the system to boot.


----------



## wblock@ (Nov 15, 2016)

I thought you could mount partitions or locations for / (or also /var, and /usr) and tell bsdinstall(8) to use them.  My success level with that installer is low, and I usually use my own or copy and upgrade existing installations.


----------



## SirDice (Nov 15, 2016)

If I remember correctly you can simply select the partition during the installer and mark it to newfs(8) it. But honestly, it's been a while since I last used that.


----------



## Areeb Qaisar (Nov 15, 2016)

I have figured it out.
The target partition which I want to use is Partition No. 11 : ada0p11.

I have used gdisk in Ubuntu to change the typecode for Partition No. 11 to A503 (which is the gdisk's type code for Freebsd-ufs).
This can also be done in Windows using DISKPart. Use the following commands


```
SELECT DISK 0
SELECT PARTITION 11
Set id=516E7CB6-6ECF-11D6-8FF8-00022D09712B
```

My Original query was that how to do this from FreeBSD installer.
Anyhow, now after changing the typecode, I plugged in my USB memstick, and started the notebook with
EFI USB Device.

When at the Partition Option, I selected 'Shell'

Create a new UFS2 File system on partition 11.

```
newfs –U /dev/ada0p11
```

Mount the partition at /mnt

```
mount –w /dev/ada0p11 /mnt
```

create a new fstab file using ee:

```
ee /tmp/bsdinstall_etc/fstab
```

Add the following in the fstab file, and then press [ESC] and select leave editor and then save the changes.

```
/dev/ada0p11    /    ufs    rw    1    1
```

Type exit, to return to the installer. The installer will proceed as normal.

Next copy the bootx64.efi from the UEFI Partition of the USB, to the existing UEFI Partition of the SSD.
You may need to rename this file to any other name. I used bootx64-freebsd.efi.
Then add its entry in the firmware boot manager (using efibootmgr, if on Linux) and (using EasyUEFI if on Windows). I don't know how to do this in FreeBSD. You may consider to chainload this entry from your existing multiboot manager such as Grub, Refind, Systemd-boot or what ever you are using.


----------



## Areeb Qaisar (Nov 21, 2016)

I have one more question related to mounting of NTFS.
I have installed KDE 4 and using KDM Login Manager on FreeBSD 11.

Now I want to mount the NTFS Filesystem located at /dev/ada1s1

I have installed  sysutils/fusefs-ntfs and added an entry in /etc/rc.conf

```
fusefs_enable="YES"
```

And an entry in fstab file:

```
/dev/ada1s1 /datadrive ntfs rw,late,mountprog=/usr/local/bin/ntfs-3g 0 0
```

And I am getting this error:

```
fuse: failed to open fuse device: No such file or directory.
```
I have studied the threads here and here, and they are talking about that adding fuse.ko worked, and kldload fuse also worked.

Can you please elaborate a little bit, how to do this?


----------



## topcat (Nov 21, 2016)

I have bookmarks to these two pages written by wblock
http://www.wonkity.com/~wblock/docs/html/disksetup.html
http://www.wonkity.com/~wblock/docs/html/ssd.html
During installation, I drop to shell and set up the partitions manually. I find it more straightforward, and it does exactly what I want. See also
https://www.freebsd.org/doc/handbook/bsdinstall-partitioning.html Section 2.6.5 "Shell mode partitioning".


----------



## ANOKNUSA (Nov 22, 2016)

Areeb Qaisar said:


> Can you please elaborate a little bit, how to do this?



The module needs to be loaded during boot time if you want the drive mounted at boot. You need to add `fuse_load="YES"` to /boot/loader.conf, and remove the line from /etc/rc.conf.


----------



## Areeb Qaisar (Nov 24, 2016)

ANOKNUSA said:


> The module needs to be loaded during boot time if you want the drive mounted at boot. You need to add `fuse_load="YES"` to /boot/loader.conf, and remove the line from /etc/rc.conf.



Adding `fuse_load="YES"` to /boot/loader.conf worked.
I have now removed the entry from /etc/rc.conf
Thanks


----------



## Areeb Qaisar (Nov 24, 2016)

topcat said:


> I have bookmarks to these two pages written by wblock
> http://www.wonkity.com/~wblock/docs/html/disksetup.html
> http://www.wonkity.com/~wblock/docs/html/ssd.html
> During installation, I drop to shell and set up the partitions manually. I find it more straightforward, and it does exactly what I want. See also
> https://www.freebsd.org/doc/handbook/bsdinstall-partitioning.html Section 2.6.5 "Shell mode partitioning".



I have also done the same.
I dropped to the shell and created the new file system using


```
newfs –U /dev/ada0p11
```


----------

