fdisk - do i need it or can i make a filesystem directly?

7,760

Solution 1

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.

Solution 2

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.

Share:
7,760

Related videos on Youtube

Noob
Author by

Noob

Updated on September 18, 2022

Comments

  • Noob
    Noob over 1 year

    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.

  • Noob
    Noob almost 9 years
    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
  • David W
    David W almost 9 years
    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)"
  • ganesh
    ganesh almost 9 years
    Extended info on the pendrive example: It is also used on floppies and pendrives without MBR where often called 'superfloppy format'.
  • ganesh
    ganesh almost 9 years
    Nope. It does not need to be. I have used without. It is still highly recommended though, but you can do without.
  • ganesh
    ganesh almost 9 years
    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.
  • David W
    David W almost 9 years
    @Hennes, Very well-taken, but I think that exception proves the rule - You either assume the file system/structure going in (like an old floppy), or specify it elsewhere in something like fstab..no matter what, though, ya still gotta know how the bytes are lined up to make sense of them when you pull them off!! Great illustration
  • David W
    David W almost 9 years
    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
    David W almost 9 years
    @kreemoweet "volume boot record of the file system." Doesn't that phrase imply the knowledge of the file system? Or are you referring to a metadata record held on the device (esp. if it isn't a bootable device). If so, then, yes, you could technically get away without a partition table. But those records are serving the same purpose: You either infer how to interpret the bytes, or something tells you how explicitly. I guess it's a matter of how fine a semantic hair the OP desires to split :)
  • AntoineL
    AntoineL almost 9 years
    @kreemoweet: yes there is: the system id hints to the generic format used by the file system, which will then allow to correctly interpret the location and content of the volume boot record or the superblock, as some prefer to name it. Also for MBR, the indication of which partition is active is usually not stored anywhere else.
  • ganesh
    ganesh almost 9 years
    Agreed. And "this option must be specified twice" is a secondary precaution.
  • Noob
    Noob almost 9 years
    @DavidW i have updated my original post, hope you take a look
  • Noob
    Noob almost 9 years
    @Hennes i have updated my original post, hope you take a look
  • Noob
    Noob almost 9 years
    @Torinthiel, i have updated my original post, hope you take a look
  • Noob
    Noob almost 9 years
    @Jarmund i have updated my original post, hope you take a look
  • ganesh
    ganesh almost 9 years
    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.
  • Daniel B
    Daniel B almost 9 years
    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.