0

I am using the FreeBSD 14.0.

I follow the instructions at https://www.transip.eu/knowledgebase/entry/138-how-do-create-partition-freebsd/ to create a UFS partition, as below: enter image description here

But always get "Invalid argument" error. The main problem is that the error does not provide enough details on which argument is invalid. So I totally get confused on this.

Thanks

4
  • Please edit your question to show the output of gpart show da2 prior to doing the gpart add ....
    – Jim L.
    Commented May 23 at 7:39
  • @JimL., Thank you. Just add it. Also the disk is a USB drive and it becomes da1 now.
    – alancc
    Commented May 23 at 14:40
  • 1
    Why are you using MBR? GPT is the norm nowadays. Also, the example at the link you cite is specifically a GPT example. MBR disks are laid out differently, so you need to focus on one or the other. Following GPT instructions for an MBR disk won't work. If you really have to use MBR, look at forums.freebsd.org/threads/…
    – Jim L.
    Commented May 23 at 16:05
  • @JimL., Thank you very much. I recreate the GPT and then the partition is created successfully.
    – alancc
    Commented May 23 at 16:46

2 Answers 2

0

I destroy the original MBR first:

gpart destroy da1

Then create GPT on the disk:

gpart create    -s GPT da1

Then show the partition table

gpart show

Then create the new partition:

gpart add -t freebsd-ufs -b 40 -s 133120 da1

That completes successfully!

0

The filesystem type value freebsd-ufs is exclusive to GPT partition schemes, but you have created an MBR partition scheme. If you wish to use MBR, you will need to create an MBR partition with the type freebsd, for a BSD disklabel. You will then add labels to this partition such as UFS and swap.

Be very careful using gpart as it does not have any safeguards. Saving a backup of all your devices' partition tables with gpart backup is a good practice here. These could be restored later in the event of a mistake. Since modifying a partition table does not change the contents of the partition, restoring the partition table with gpart restore will easily "fix" these mistakes. Even an experienced user can accidentally use da0 where they meant da1 and delete the wrong partition. See the gpart(8) man page for additional details and examples.

Because this is a USB stick, and assuming it will simply be used it for external storage, there are two options. The simplest is to not partition the device at all, and create a UFS filesystem that encompasses the entire device with newfs /dev/daX. The device can then be mounted directly. The downside is that plugging this device into a Windows machine will prompt the user to format it.

If a partition table is required, use GPT partitions instead. First, remove the existing MBR partition table, then create a new GPT partition scheme, and finally add a UFS partition:

 gpart destroy <device> # remove existing MBR partition table
 gpart create -s GPT <device> # create GPT partition scheme
 gpart bootcode -b /boot/pmbr <device> # add protective MBR for legacy apps
 gpart add -t freebsd-ufs <device> # add UFS partition spanning device

gpart will choose the first available sector and create a partition spanning the entire device.

Note, if you want this to be bootable, there are additional steps that must be performed and additional partitions required. The gpart(8) man page has excellent examples for creating a bootable GPT device.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .