4

I am using FreeBSD. My HDD has this set of partitions:

root@core:/media # gpart show
=>       63  390721905  ada0  MBR  (186G)
         63       1985        - free -  (993K)
       2048   13365248     1  !39  (6.4G)
   13367296         44        - free -  (22K)
   13367340  174063519     2  freebsd  [active]  (83G)
  187430859      57397        - free -  (28M)
  187488256  203231232     3  ebr  (97G)
  390719488         23        - free -  (12K)
  390719511       2394     4  freebsd  (1.2M)
  390721905         63        - free -  (32K)

=>        0  174063519  ada0s2  BSD  (83G)
          0  174063518       1  freebsd-ufs  (83G)
  174063518          1          - free -  (512B)

=>        0  203231232  ada0s3  EBR  (97G)
          0   14485504       1  linux-swap  (6.9G)
   14485504  188745728  229929  linux-data  (90G)

=>   0  2394  ada0s4  BSD  (1.2M)
     0  2394          - free -  (1.2M)

I want to add swap drive to FreeBSD by modifying linux swap. In fact I do not use linux drive at all, and don't care if it's removed.

I am doing this to modify partition:

root@core:/media # sudo gpart modify -i1 -t freebsd-swap ada0s3
gpart: pre-check failed: Operation canceled

What am I doing wrong? Any input is appreciated.

1
  • The output of lsblk could help me to give you a more precise answer :D
    – ncomputers
    Commented Feb 6, 2016 at 23:59

2 Answers 2

1

I am understanding, that you already have one linux-swap partition (ada0s3).

If this is the case, just add the partition to /etc/fstab

If not, I recommend you to use fdisk for MBR partition tables or gdisk for GPT partition tables instead to edit the partition table as you want and then execute: mkswap partition, swapon partition and then add the partition to /etc/fstab.

For example

#add /dev/ada0s3 to /etc/fstab as swap partition
echo "/dev/ada0s3   swap    swap    defaults    0   0" >> /etc/fstab
1

The EBR partition type is well-known as "extended partition" or "logical partition" (it is an MBR-only type of partition and is pretty old; from good old MS-DOS days). This is not something that is typical on FreeBSD since logical partitions are made natively with bsdlabel.

From the gpart(8) manpage:

 MBR        Master Boot Record is used on PCs and removable media.
            Requires the GEOM_PART_MBR kernel option.  The GEOM_PART_EBR
            option adds support for the Extended Boot Record (EBR), which
            is used to define a logical partition.  The
            GEOM_PART_EBR_COMPAT option enables backward compatibility for
            partition names in the EBR scheme.  It also prevents any type
            of actions on such partitions.

The last sentence makes clear that FreeBSD's GEOM part module is going to block actions on this type of partitions. And you should not add ada0s3 as swap because it is a logical partition and this might confuse other operating systems (even FreeBSD might have a problem then). And you surely don't intend to have a 97 GB swap partition, as far as I understood.

If you don't need the Linux system on the EBR at all, you can boot up a Linux live CD and remove the logical partition entirely using your favorite fdisk tool. Then it will be marked as free space and you can go back to FreeBSD and modify it with gpart.

One further warning: be careful that FreeBSD has installed its boot manager, because if the primary booting system is Linux, you may need to restore the boot loader with a FreeBSD live CD after deleting the EBR partition. Whatever you do, be sure you know what you do, because you can lose access to data or even irreversibly lose it. Backups are always appropriate in such situations.

You must log in to answer this question.

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