0

It is common to create a partition in order to create a filesystem.
Modern Linux fdisk will do block alignment automatically, starting the partition at sector 2048.
In this case the filesystem will also start at sector 2048. Below is just an example.

fdisk -l /dev/nvme1n1
Disk /dev/nvme1n1: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc14701c1

Device         Boot Start      End  Sectors Size Id Type
/dev/nvme1n1p1       2048 10485759 10483712   5G 83 Linux

But it is also possible to create a filesystem directly on device, without any partition.
In tis situation, in which block the filesystem will start?
Will it start at sector 0? If so, does it mean it is aligned by default?

Azize
  • 128
  • 5
  • I would say that in the case of iSCSI/FC, it is common to create a filesystem directly on the device - the reason to use a remote volume like that is reserved usage for a single application. But it is entirely feasible to create a LVM physical volume on the same device and then use LVM to divide it up in smallar parts (like a system's system disk - separate swap,root and so on) – Stefan Skoglund Mar 25 '20 at 17:44
  • Thanks @StefanSkoglund, LVM also does block alignment on modern Linux. When we use tools like `fdisk`, `lvm` or `mdadm` it is very clear to me how it works, my doubt is when we use `raw` device. – Azize Mar 25 '20 at 18:03

1 Answers1

0

Yes, it will be aligned to block 0 as it always happen when you create filesystem on /dev/nvme1n1p1 and it starts from block 0 of nvme1n1p1 device. Partitions here are just the way to create nvme1n1p1 device pointing to limited space on device nvme1n1.

In your example you have two devices - nvme1n1 (10485760 sectors) and nvme1n1p1 (10483712 sectors) and no utility will even think about nvme1n1p1 as a part of nvme1n1.

Anyway - this is quite bad practice to create partition on entire drive. Parition tables are good not only for splitting drives, but also for marking them. In worst scenario the one may need to recover filesystem and you will not even know what was there. Is that partition table was erased? Or maybe that was entire drive containing filesystem? Was it Linux or BSD or Windows? Parition table can give a little clue.

As Stefan said its common to make filesystems directly on disk array slices or iSCSI nodes. This is usually done because they have their own identification and one may have too much of them, so creating partitions become pointless.

kab00m
  • 398
  • 1
  • 9