10

i read about fdisk being able to creation partition / which is to break down a physical disk into several logical partitions.

If i intend to utilize the whole disk as a whole, is it still necessary for me

1) to fdisk and create a primary partition that take up the size of the whole disk or

2) i can just go ahead and mkfs.ext4 without doing any fdisk ?

3) And why ->

Edited -> After reading all the comments (of some yes and no), i am thinking that it will be good if someone could point to me on what actually does fdisk do ? so that i can understand more on why do we actually need it in comparison to if we did not.

I tried googling around but most of the sites are teaching you how to fdisk, but not why (or most of the why is to create dual boot system), but i want to know why is it needed even for a single partition.

I have also tried mkfs on a disk directly and mount it to store data and file (does not seem to have any issue) -- so this make me even more curious on what fdisk actually does to the storage disk.

4 Answers 4

5

No, you do not need it. Your disk and filesystem will work fine without partition table. Some older BSDs even did this by default if you selected dangerously dedicated.

However it is highly recommended for compatability reasons.


Somewhat more verbose:

You can run mkfs.ext4 directly on /dev/sdb. That will work. You then can mount that without problems. (mkfs.ext4 -F -F /dev/sdb).

You can setup a bootable disk this way. It will still require some code to boot. Which means you either need to skip the first bit of the disks. (e.g. the space classically used by the MBR and the traditional few sectors beyond it). That is still technically not using MBR, though you loose equivalent space.

For any modern setup however those few sectors are a tiny fraction of drive capacity. I therefor recommend using GPT (or on ancient systems MBR). But you can do without.

4
  • It appears that mkfs.ext4 takes an -F parameter to force filesystem creation even if it appears the target isn't a partition, or even if the target device appears to be mounted! I think this points out the inherent risks in doing so...
    – David W
    Commented Jun 30, 2015 at 20:10
  • Agreed. And "this option must be specified twice" is a secondary precaution.
    – Hennes
    Commented Jul 1, 2015 at 9:36
  • @Hennes i have updated my original post, hope you take a look
    – Noob
    Commented Jul 1, 2015 at 19:03
  • 1
    Compare fdisk to writing an index for a book. People do expect a index and get confused when there is none. A book without an index and with a single story/chapter wil still work.
    – Hennes
    Commented Jul 1, 2015 at 19:11
0

You need to create a partition table even if you're going to use the entire physical disk. Think of the partition table as the "table of contents" for the file systems, identifying the start and stop locations of each partition as well as the file system used for it.

9
  • even if i meant to use the storage as a raw device ? i still need fdisk it ? i read about fdisk creating partition, but i don't understand why is it needed
    – Noob
    Commented Jun 30, 2015 at 17:41
  • 1
    If I hand you a disk with just raw bytes on it, and no other information, how would you interpret it to get data out of it? You couldn't. It's an oversimplification, but that's what a partition table does. It says "Here's where the data is stored on the disk (start/stop location/cylinder/track), and here's how it's organized (file system)"
    – David W
    Commented Jun 30, 2015 at 17:45
  • Actually, you could. Take a floppy. We assume one partition/volume. We specify the filesystem used (since we have no MBR to tell us what is used we need to manually specify that or enter it in /etc/fstab) and read the information for the filesytem. Classic example: Floppies and FAT12.
    – Hennes
    Commented Jun 30, 2015 at 19:46
  • 1
    There is no information in the standard partition table that is not, or could easily made to be, already in the volume boot record of the file system. Any reliance of software on a MBR/partition table to properly recognise and/or boot from a file system is entirely artificial.
    – kreemoweet
    Commented Jun 30, 2015 at 20:16
  • 1
    No, you don’t need a partition table and no, the file system type as indicated in the partition table is ignored. Instead, well defined sequences of bytes (“magic”) are used to determine the filesystem type. If you want to boot from the disk, it’s a different thing, of course.
    – Daniel B
    Commented Jul 1, 2015 at 19:16
0

You could create a filesystem on a bare drive, but it's rarely going to work. Some pendrives are organised as that. But for the hard drive you don't want to.

If it's going to be your primary/only drive, it won't be bootable at all if you create it as such. What BIOS does is read the first sector of drive and execute it (aka jump to it's first byte). Do you really wan't to execute filesystem metadata? Fortunately you won't, as the BIOS contains failsafe - the last two bytes of that sector need to be 0x55 0xaa for BIOS to consider the drive as bootable. And you you have an UEFI system it's even worse, as UEFI requires a distinct FAT partition to work.

If it's going to be your secondary hard drive, this might work, but still is discouraged - no autodetection will work, most tools will tell you the drive is not formatted and require partitioning (which will destroy your data).

Then again it is sometimes possible to do so, but in a very hackish way, requiring intricate knowledge of several filesystems' on-disk organization. I've once seen a description of an image that could be burned to a bootable CD, to a bootable USB drive or even booted by older Mac's, but this was on the level of 'If I put the filesystem length to xxx, when it gets executed by another architecture it runs as a harmless register comparison'.

2
  • Extended info on the pendrive example: It is also used on floppies and pendrives without MBR where often called 'superfloppy format'.
    – Hennes
    Commented Jun 30, 2015 at 19:43
  • @Torinthiel, i have updated my original post, hope you take a look
    – Noob
    Commented Jul 1, 2015 at 19:03
-1

Even if you intend to use the entire disk, it will still have to be partitioned. In this case with a partition as big as the disk itself (almost, at least. The partition table takes up some space. See below for details on this).

When I introduce people to the concept of partitions and filesystems to people who normally just think of "harddrives, empty vs full" is this: The harddrive is the building, while the partition is the actual room. You format a partition with a specific filesystem, and then make it usable, and in the building-analogy, this corresponds to declaring a room type, such as kitchen vs bedroom (In other words, how to use it).

Now, to go back to your original question, you cannot put a filesystem onto an unpartitioned drive, as the partition table (the first 512 bytes of the drive) contains info about where on the physical drive the partitions can be found. For you to have a filesystem, it will have to start somewhere that the partition table can reference, and it cannot reference a filesystem that does not have a defined space, i.e. the partition.

And if we are to place the partition table in the building-analogy, I guess that would correspond to a blueprint of the building.

Update reflecting your question edit: What fdisk does is allows you to select certain aspects of a partition, such as size, type, and physical location, as I'm sure you already know. What fdisk then does is translate these into a partition table entry. Basically, it sees to it that the partition table is up to date with a "list" of all partitions on the disk, each item in the list stating which partition can be found where, and what type it is. This is so that an operating system knows where to access data on partitions.

2
  • 1
    Nope. It does not need to be. I have used without. It is still highly recommended though, but you can do without.
    – Hennes
    Commented Jun 30, 2015 at 19:44
  • @Jarmund i have updated my original post, hope you take a look
    – Noob
    Commented Jul 1, 2015 at 19:03

You must log in to answer this question.

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