Partition Table, not bootable hard disk

vince66

Well-Known Member

Thanks: 10
Messages: 397

#1
I apologize with you for the following question not strictly related with FreeBSD.
Again, I apologize in advance if I'm a little bit confusing.

I'd like to use an hard disk like an old magnetic tape to store files.
I'm not interested (and I don't want) that the hard disk is bootable, so I don't want create on it the Master Boor Record or the GPT.

First question:
Is it possible realize this only creating the partition table (fat, exfat, ntfs, hfs,...) so to identify files and directory on it ?
In other words, I only want that the hard disk has a filesystem, but it has not to be bootable.
That is, is it valid this expression: make partition table = make a filesystem ?

Second question:
If so, in which a way can I do this with gpart ?

Thanks in advance.

Best Regards.
 

Beastie

Daemon

Thanks: 458
Messages: 2,153

#2
An MBR contains 1) the MBR boot loader code that makes the disk bootable 2) a partition table with 4 entries that describe the partition(s) stored on the disk. The entire MBR is just 512 bytes.
FreeBSD used to have something called "dangerously dedicated" mode where the bsdlabel was placed where a regular MBR would've been (instead of being stored inside the partition), but as far as I know it's not supported anymore.

To be bootable, a disk must have an active partition (set in the partition table in the MBR) as well as a chain of bootloaders (first stage in the MBR, second stage in the slice, etc.)

If you don't need those, it's very simple: you just don't install them.

Let's say your disk is /dev/ada1.

Create an MBR scheme, then create a FreeBSD slice that covers the entire disk:
gpart create -s mbr ada1
gpart add -t freebsd ada1

Create a bsdlabel for that slice:
gpart create -s bsd ada1s1

Create a UFS partition:
gpart add -t freebsd-ufs -a 4k ada1s1

Create the file system:
newfs -U /dev/ada1s1a
 
OP
OP
vince66

vince66

Well-Known Member

Thanks: 10
Messages: 397

#3
Beastie, I appreciate your reply, but my question was another. I did not express myself correctly.

The dangerously dedicated mode is for exclusive use of FreeBSD O.S. and disk utilities may not recognize and damage the disk.

Think of a DVD. Is it possible formatting an hard disk "like" a DVD to store data on it ? As you know not necessary a DVD has to be bootable.

Theorically speaking, filesystem and MBR are indipendent or depend each other ?
Can exist a filesystem without MBR ?

Thanks in advance.

Regards.
 

Beastie

Daemon

Thanks: 458
Messages: 2,153

#4
The difference between bootable media and non-bootable media is the bootloader chain, starting in the MBR (roughly the first 446 bytes out of the total 512 bytes that make up a sector).

So at the risk of repeating myself, I'll just restate the essential: if you don't need the chain, then don't install any of its components.

The only reason you need an MBR (or a more modern equivalent) is because the next 64 bytes constitute the partition table that describes the actual partitions (type, starting address, size).

Let's say a disk was bootable but you don't have an OS on it anymore, you could clear the first 446 bytes and you should still be able to store files. But you'd just be wasting your time clearing the code: the code part of the MBR does nothing on its own without a second stage bootloader in the boot slice and a third one in the boot partition and the loader and the kernel and at least a functioning basic OS.

Think of a DVD. Is it possible formatting an hard disk "like" a DVD to store data on it ? As you know not necessary a DVD has to be bootable.
Sure, with the commands I wrote above, that's exactly what you'd be doing. Try to boot such a disk and the BIOS will stop you in a matter of milliseconds with a "device is not bootable" error, or it happens there's actual code in the MBR but it's unable to find and load the rest of the chain so again, it stops right there.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,618
Messages: 28,165

#5
Why do you think that creating a partition table implies making the disk bootable? They have nothing to do with each other. Well, sort of, you need to create some space for the boot sector, but that's about the only thing. It's perfectly fine to create a partition table and not write the boot sector (or partition).

"Dangerously" dedicated refers to a disk without a partition table (only BSD labels).
 
Top