Article 6QNJM FDISK, partition and format from regular files

FDISK, partition and format from regular files

by
banderas20
from LinuxQuestions.org on (#6QNJM)
Hi.

I'm trying to create regular files and set them up to be used as disks.
I'm using fdiskutility, and AFAIK, we must first create partitions and then format them.

Here are my steps:

Creation of the file


Code:dd if=/dev/random of=file2GB bs=1MB count 2000
Create new partition and its partition table


Code:fdisk file2GB
n (new partition with the entire size)
p (show partitions)
(the new partition is shown)
w (write changes)
Format the ipartition?


Code:mkfs.ext4 file2GBWith the above command, I'm formatting the entire disk. Not the partition. Which should give me an error, but it works. In addition to that, If I run mkfs.ext4 against the partition name, it fails. But if I run fdisk -l file2GB the partition shows there.

If I try to mount the disk (not the partition), it works.

I shouldn't be able to format an entire drive, and I should be able to format the partition. But it works the other way round.

iHow is that so? iAm I missing something?

Thanks!
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments