Other Moving free disk space between MBR and BSD

Hello,
I am a complete novice in FreeBSD, How do I transfer free disk space between BSD and MBR?
Currently the partitions on my drive look like this:
Code:
gpart show
=>       63  488394992  ada0  MBR  (233G)
         63          1        - free -  (512B)
         64  488394984     1  freebsd  [active]  (233G)
  488395048          7        - free -  (3.5K)

=>        0  488394984  ada0s1  BSD  (233G)
          0  104857600       1  freebsd-ufs  (50G)
  104857600   16777216       2  freebsd-swap  (8.0G)
  121634816  366760168          - free -  (175G)

I would like to move the free partition from the BSD to the MBR because my backup program sees the BSD as a whole and makes a copy as a 250GB partition. As in the image below.
img.JPG


Thanks for your help
 
easiest way is to create ada0s1d with bsdlabel but then you will have 2 partitions for data
or stop/delete swap, edit label, growfs, recreate swap
you can do that with bsdconfig / disk management i think (not sure about the growfs part)
 
Hello,
I am a complete novice in FreeBSD, How do I transfer free disk space between BSD and MBR?

MBR is the disk scheme, as opposed to GPT partitions.

The free space is in ada0s1, and cannot be moved before there, there's no room.

Currently the partitions on my drive look like this:
Code:
gpart show
=>       63  488394992  ada0  MBR  (233G)
         63          1        - free -  (512B)
         64  488394984     1  freebsd  [active]  (233G)
  488395048          7        - free -  (3.5K)

=>        0  488394984  ada0s1  BSD  (233G)
          0  104857600       1  freebsd-ufs  (50G)
  104857600   16777216       2  freebsd-swap  (8.0G)
  121634816  366760168          - free -  (175G)

If you use
gpart show -p
instead, you'll see that partition 1 on slice ada0s1 is called ada0s1a (the 50G).

You should be able to tell the backup software (which is it?) to backup just ada0s1a rather than all of ada0s1.

I would like to move the free partition from the BSD to the MBR because my backup program sees the BSD as a whole and makes a copy as a 250GB partition. As in the image below.

BSD is the type of partitions, already under the MBR scheme; you can't do that.

As covacat suggests, you can add the 175G free space as ada0s1d, or several smaller ones if you prefer, using gpart(8) or bsdconfig(8).

Either way, be careful, at least till you have a backup!
 
First of all, make a copy of information about existing partition structures;
Run both commands and save the output outside of your FreeBSD.
You can redirect output to file using >> if you familiar with using console.
fdisk -p /dev/ada0
bsdlabel /dev/ada0s1

You have MBR partition (slice in FreeBSD notation) which cover all your physical disk.
Code:
64  488394984     1  freebsd  [active]  (233G)
Inside this MBR partition you have two FreeBSD partitions and some free space.
Code:
=>        0  488394984  ada0s1  BSD  (233G)
          0  104857600       1  freebsd-ufs  (50G)
  104857600   16777216       2  freebsd-swap  (8.0G)
  121634816  366760168          - free -  (175G)

If you need "to move" free size 175G then you should resize MBR partition, reducing its size.
If you will have done this - your free space will be moved as free MBR space and your backup software should not to backup it.

I know how to resize MBR parition with fdisk(), but it may be too hard for newbies.
fdisk -p /dev/ada0 > /tmp/fdisk-ada0
Edit /tmp/fdisk-ada0, specify new size for 1st partition.
It should be more than ~60GB, because you have 50G + 8G FreeBSD-partitions.
As a size of MBR partition you can choose a little bit larger value than 1st sector of FreeBSD-free area.
You have start sector of free-space equal 121634816, so you can use 130000000 for fdisk.
Save fdisk's config file, and write it back using a command fdisk -f /tmp/fdisk-ada0 /dev/ada0
It may be usefull to disable swap before this action using swapoff().
Also you should have backup of all data before doing anything with partitions. Use builtin software to have a full backup.
In other case you can make temporary full backup with any other software, and remove the backup after you successfully resized your disk.

It is possible to do the same with gpart, but I never used gpart for similar tasks.
In my opinion, you can do it with gpart in this way, but doublecheck everything, and wait for another replies here.
gpart resize -i 1 -s 70G ad0

Also try to google about "freebsd gpart resize mbr partition" but keep in mind that you need to decrease size of the MBR partition.
 
I think it should work to just gpart resize -i 1 -s 121634816 ad0
I dont think there is any data at the end of a BSD partition, and the beginning (where the boot blocks are) doesn't change.

But this may require to boot from a different media, to have this disk fully closed, nothing running from it.
 
gpart resize -i 1 -s 121634816 ad0
121634816 it is an offset inside 1st MBR partition. But 1st MBR partition starts from sector 64.
So end of freebsd-swap should be somewhere near 121634816+64 sectors.
In my opinion, MBR freebsd partition should have end of partition after 121634880 sectors.
But I prefer to choose a little bit largest value just in case, to avoid partition overlaping.
 
121634816 it is an offset inside 1st MBR partition. But 1st MBR partition starts from sector 64.
So end of freebsd-swap should be somewhere near 121634816+64 sectors.
Hm... 121634816 is 104857600 + 16777216, that is the end of the used space within the BSD label. So that would be the used size within the BSD label, which is new intended size of it, which might be given as the -s (size) option for gpart resize. That's what I was thinking...
 
Back
Top