Solved Assistance with gpart

Hi. I want to add a new partition to my hard drive. In the installation process I let there be 150 GB memory for this.

So far I have been using
Code:
sudo gpart add -t freebsd -s 100G ada0
ada0s2 added

sudo gpart show
=>       63  625142385  ada0  MBR  (298G)
         63          1        - free -  (512B)
         64  314572800     1  freebsd  [active]  (150G)
  314572864  209715200     2  freebsd  (100G)
  524288064  100854384        - free -  (48G)

=>        0  314572800  ada0s1  BSD  (150G)
          0  306184192       1  freebsd-ufs  (146G)
  306184192    8388607       2  freebsd-swap  (4.0G)
  314572799          1          - free -  (512B)

At first I tried adding -t freebsd-ufs but since invalid argument I went with freebsd.
Now I wonder why gpart is not displaying ada0s2. I have checked and found /dev/ada0s2 so it's somewhat added to the system.

The thing is that I thought I'd remake it and make it a little bigger (up to 120 GB) instead but now gpart can't find the geom ada0s2. I missed to label/index it as well making it even harder to target.

I have with great carefulness tried different commands trying to delete ada0s2 and add a new one but with no avail at all. Have been going through the manual for gpart 4 times as well as for geom but I can't get my head around it. (I have had a hard time understanding hard drive disks altogether.)

Please halp.

- - - michael_hackson
 
That setup looks quite out of place. Is this a modern setup? Because then I'd strongly recommend using a GPT partition scheme over both MBR and BSD.

So something in the likes of # gpart create -s GPT <drive> followed by adding the right slices using gpart add. You'd use either freebsd-ufs if you need to use the UFS filesystem or freebsd-zfs for, well, ZFS obviously.

Even so... Using freebsd-ufs together with a BSD partitioning scheme looks seriously out of place to me. If this is something new you're setting up then I'd repartition the whole thing.

(edit)

It's been quite a while but I'm also fairly certain (not 100% sure!) that you cannot use 2 partitions of type freebsd together on a single drive. The problem is that the partition itself is already subdivided into separate filesystems, which as far as I recall, could cause problems with overlap.
 
I made this setup last night to learn how to partition manually because the system was in need of a reinstall. I found some YouTube guides on this and why I went with MBR over GPT is because I want to have an easier time with dualboot/bootloaders, since this system is a non-uefi anyway.

freebsd-zfs is a nice thing but since this is a Desktop PC with a single hard drive I have read myself into believing this to be more work for less gain in this case scenario.

The question of how to delete this still remains and I think it will end up in more studies/trial-errors and do again, do right. My goal in mind would be to have something like:

Code:
63  625142385  ada0  MBR  (298G)
         63          1        - free -  (512B)
         64  314572800     1  freebsd  [active]  (150G)
  524288064  100854384        - free -  (48G)

=>        0  314572800  ada0s1  BSD  (150G)
          0  306184192       1  freebsd-ufs  (146G)
  306184192    8388607       2  freebsd-swap  (4.0G)
  314572799          1          - free -  (512B)

            0  314572800  ada0s2  DebootstrappedDevuan  (100G)
          0  306184192       1  freebsd-ufs  (96)
  306184192    8388607       2  freebsd-swap  (4.0G)
  314572799          1          - free -  (512B)

I can imagine that dualbooting may be a bordering subject whereat support may not be given at this forum but it would be a nice thing to make the partitioning possible for this kind of setup.

You'd still go with GPT on a BIOS system and get the bootloader working from there? Current recommendations from Thread 63286 is to use MBR scheme, which I find quite nifty.

I'll try some ideas.
 
When I look for maximum compatibility, I prefer MBR
- some old BIOS doesn't like at all GPT. I have encountered strange behaviors in the past with GPT and some old motherboard
- Some old branded computer may have vicious restrictions in their BIOS that reject a GPT drive

I use GPT on some modern hardware, generally with UEFI

Following you will find a script that builds FreeBSD partitions on a 64 GB flash key following MBR scheme
An additional partition in FAT32 is added to receive further DOS, and the boot show up the menu to switch between partition

This is just an example, this doesn't mean you should use the parameters I have defined
This is just a case to analyze to learn better how we can deal with MBR

I found more easy to copy a script of my own rather than explaining in multiple messages the syntax to use
No doubt that other people will send their suggestions

For GPT this is slighty different.

Code:
############################################################

# Warning !!!! Set manually the target drive to rebuild to #

# for safety always uncomment the following line after     #

# a complete operation.                                    #

# Given for a 64 GO  SanDisk Extrem USB3 flash Key         #

# This unit is not a 4096 stripped sized block             #

# (see diskinfo -c dax) so setting fragment size           #

# to default sector size 512 bytes and block size to 8x     #

# sector size 4096 bytes                                   #

# Adjust values according to the target drive              #

# This applies the old MBR scheme                     #

############################################################


echo "Enter the device name to configure as it appears in /dev"

read drive


[ -z "$drive" ] && echo "Secure exit..." && exit

[ ! -e /dev/"$drive" ] && echo "Unable to find the device" && echo "Secure exit..." && exit


echo "Enter the device type, 1 for USB Key, 2 for portable drive"

read media


[ -z "$media" ] && echo "Secure exit..." && exit


if [ "$media" = "1" -o "$media" = 2 ]; then


[ "$media" = "1" ] && media="Key"


[ "$media" = "2" ] && media="Drv"


else


echo "Secure exit..."

exit


fi


echo "Enter the agent number"

read agent


flag="ko"

case $agent in


( [0-9] )

flag="ok"

;;

esac


[ "$flag" = "ko" ] && echo "Secure exit..." && exit


echo "This will erase all your date on the drive "$drive

echo "Please confirm [YES]"

read Validation


[ "$Validation" != "YES" ] && exit



# 1 => Clean

gpart destroy -F /dev/$drive


# 2 => Create mbr scheme

gpart create -s mbr /dev/$drive


# 3 => Insert Bootcode". We choose the boot0 rather than mbr

# to pop up a menu at startup to choose between the slices so further

# the fat 32 slice could be bootable with a DOS filesystem


# FreeBSD Menu switcher at bootstart

gpart bootcode -b /boot/boot0 /dev/$drive


# No FreeBSD Menu

#gpart bootcode -b /boot/mbr /dev/$drive


# 4 => Add a preliminary FAT32 partition for compatibility with some

# old BIOS requiring a first FAT32 partition


gpart add -t fat32 -a 512 -s 512M /dev/$drive


# 5 => Add freebsd slice

gpart add -t freebsd -a 512b /dev/$drive

gpart create -s bsd /dev/$drive"s2"

gpart bootcode -b /boot/boot /dev/$drive"s2"


# 5 => Add ROOT partition no 1

gpart add -t freebsd-ufs -a 512b -s 55G /dev/$drive"s2"


# 7 => Add swap partition no 2 approx 4 G

gpart add -t freebsd-swap -a 512b /dev/$drive"s2"


# 8 => activate by default the freebsd slice

gpart set -a active -i 2 /dev/$drive


# 10 => Initialize UFS partitions and set permanent acl

#       -N for ACL v4 Superblock

#       -j for Soft Update journaling


partition=s2a

newfs -L RSC$agent"ROOT" -U -b 4096 -f 512 /dev/$drive$partition

tunefs -N enable -j enable /dev/$drive$partition


# Set GLABEL to easily recall partitions in fstab, and manipulate further


partition=s2a

glabel label -v "RescueAgt"$agent"_ROOT" /dev/$drive$partition


partition=s2b

glabel label -v "RescueAgt"$agent"_SWAP" /dev/$drive$partition
 
I made this setup last night to learn how to partition manually because the system was in need of a reinstall. I found some YouTube guides on this and why I went with MBR over GPT is because I want to have an easier time with dualboot/bootloaders, since this system is a non-uefi anyway.
Well, UEFI really has little to do with GPT, the main advantage of this partitioning scheme is the size of the drives it can handle and the way it does so. Another aspect to consider is that all modern operating systems pretty much support GPT, though... it is definitely true that MBR can sometimes provide better compatibility.

It all depends on the operating systems involved. I noticed some traces of Linux names in your overview, and Linux definitely has no problem with GPT. Personally I'd only resort to MBR these days when Windows is involved, and even then only Windows 7 (although it can handle GPT the support isn't always top notch). But for everything else it can definitely be beneficial to stick with GPT.

Either way: I'd definitely get rid of that BSD setup, that's really ancient stuff and not very optimal.

freebsd-zfs is a nice thing but since this is a Desktop PC with a single hard drive I have read myself into believing this to be more work for less gain in this case scenario.
You're fully right. In that setup UFS is most likely a better solution. However... just be careful with the way you set it up, because if you're overdoing it this could lead up the classic problem of (for example) / having an excess of free space while /var is running out.

Hope this can help.
 
What do you want to do? Add a partition? How big is your capacity of storage? You have one or more HDD? Or SDD? Why you're using Devuan (Linux)? Why you used MBR? Why you didn't used GPT, which it's the recommended?
 
Wozzeck.Live: Thank you especially for sharing this script. It's a good one and this part is particularly interesting:
Code:
# 5 => Add freebsd slice

gpart add -t freebsd -a 512b /dev/$drive

gpart create -s bsd /dev/$drive"s2"

gpart bootcode -b /boot/boot /dev/$drive"s2"

Before going with more experimenting I can share that my current step may be the first one in this section. I'll try with the command gpart create to see if I can get a working setup on ada0s2.

Well, UEFI really has little to do with GPT, the main advantage of this partitioning scheme is the size of the drives it can handle and the way it does so.

Can't remember straightforward from where but it was related with Grub studies. I read at one part that why it's hard to dualboot a BIOS with GPT is because BIOS itself doesn't know what partition to load and therefore you'd prefer GPT on UEFI systems. This may have been directed towards a case where an operative system doesn't allow GPT on BIOS at all. But if this is a false directive GPT may be the general pick over MBR.

Also thanks for the heads up. ;)

- - - - -
What do you want to do? Add a partition? How big is your capacity of storage? You have one or more HDD? Or SDD? Why you're using Devuan (Linux)? Why you used MBR? Why you didn't used GPT, which it's the recommended?

I want to make a manual partition scheme enabling dualbooting with FreeBSD. Particularly in this case I thought of deleting one partition since I wasn't satisfied with the layout but information about creating partitions with gpart is most wanted as well. The total capacity is the one seen for ada0 in the original post.

I have one single HDD non-SSD to this computer. I am currently not using Devuan (Linux) but will want to have it as a secondary system to FreeBSD when it comes to gaming specifically. Second part is to transmit missing files from Linux to FreeBSD to make the games run on FreeBSD (libstdc++.so.6 correct version). Third part is to check on its multimedia capabilities to eventually compensate depending on how that kernel is handling the drivers. Last part is to gain knowledge about Linux, starting with a minimal install and in the same run avoiding systemd.

Why MBR has already been stated, why not GPT has also been stated, as which is, or is not the recommended.
 
michael_hackson Why SystemD? I'm using Linux and still I haven't found great problems.
Sorry, but this it's too much sophisticated to me. I just will install Qubes OS and FreeBSD.
 
SirDice actually has a terrific post in this Thread 64146:

"There are plenty of discussions related to systemd. I suggest you use the search function on the forum to find them.

I'm going to close this thread as there's been enough said about it."

And a search leads to a thread like:

Thread 63893
 
Mark this thread as solved. Thanks to Wozzeck.Live I learnt MBR partitioning following his excellent script. It helped me both understanding the terminology of gpart: how to use gpart add , gpart create and the correlation to their counterparts gpart delete , gpart destroy.

Regarding my original question on "how do I remake it", the trick was to pick the right command. Since I had only started to initialize a partition on /dev/ada0, as ada0s2 in this case, the command to simply erase it was:
gpart delete -i 2 ada0.

I also managed to set up a working BSD slice yesterday with correct partitioning, all by following the script from top to bottom. Forgot to copy output from commandline since deletion but the final looked something like what I wished for in the post above, except with correct blocksizes and locations + instead of "DebootstrappedDevuan" it was named into another BSD over ada0s2.

Cheers!
 
Also thanks goes to ShelLuser pointing out that one should consider picking GPT on most OSes since MBR itself is legacy and make sure to set proper size-limits for /, /var, /tmp, /usr to avoid having a partition run out of space.

It's been quite a while but I'm also fairly certain (not 100% sure!) that you cannot use 2 partitions of type freebsd together on a single drive. The problem is that the partition itself is already subdivided into separate filesystems, which as far as I recall, could cause problems with overlap.

Without thorough investigation this actually worked, having a separate filesystem on another partition type freebsd. What made me reconsider this was that I think the debootstrapped Devuan can't manage to find ada0s2 in its /dev directory because using BSD scheme can lead to other OSes not finding the partitions, as found in gpart(8).
 
Back
Top