10

I have a newly formatted ext4 1TB HDD that I intend to use only for data. This is a single user machine though the drive or folders within it may be shared out via NFS .

Is there any advantage to partitioning the drive?

  • 7
    Partitioning is only used to divide the space into (logically) separate parts; on servers I often put /tmp on a separate partition - this is because some programs output enormous amounts of data to /tmp until the filesystem is full - if /tmp was part of eg. the / filesystem, it might kill off the entire system. However, you don't have to partition at all, unless you have practical reasons to do so - you can format the whole device (eg. /dev/sda rather than /dev/sda1). – j4nd3r53n Feb 11 at 11:42
  • 2
    If the drive usage can be expected to grow with time, I would put it under LVM and make a logical volume, so that I can add more disks and extend logical volume without fiddling with mount points later on. – Gnudiff Feb 12 at 12:50
  • 2
    Partitioning data-only disks was very useful in the MS-DOS era, because FAT has a fixed size allocation table, and so "big" disks meant big chunk sizes. Not so with Linux-native filesystems. – RonJohn Feb 13 at 5:24
  • 1
    @RonJohn. So you think raw disks with no partition table? Many recommend at least one partition. If a partition table what partition table type? Does the MSDOS partition table type have this limitation you speak of? – Stephen Boston Feb 13 at 7:54
  • 1
    Stephen, my comment was sloppily written. I should have written it, "Dividing data-only disks into multiple partitions was very useful in the MS-DOS era, because ... With Linux, having just one partition is all you need". – RonJohn Feb 13 at 13:52
15

One ext4 partition will suffice. You can assign folders within it with differing rights in case you have multiple users.

12

No Partition or 1 Partition?

It is possible to format the whole disk without any partition and without any partition table.

However, it is recommended that You have at least one partition covering the whole disk. See answers to How do I add an additional hard drive? in this site for other examples of creating a single partition covering the whole drive.

I suppose you want to know the advantage of having more than one partition in this data disk. Here are some advantages:

Multiple Users

Let us suppose my wife is a telenovela fan and wants to setup a way to download 6 episodes every week. My son is a gamer and wants to save his steam game data in the extra drive.

If I have only one partition in a few weeks the partition will be full of TV episodes and my son won't be able to save his game or vice versa.

One solution is to create two partitions. Even if the Telenovela partition is full the game-data partition will have space and the other way around.

There are other ways of assigning disk quota to users: Using 'quota' for disk limits that does not require creating multiple partitions.

Second Drive as a File Server

This use-case is similar to above, but instead of having multiple local users, you have other users who use the data drive as a network drive and dump their data in this drive. Even though there are ways to manage network data storage quota in a file server, you may want different partitions for different network users.

Partitions v Quota

Using user and or group quotas for local or remote users' data needs is the "proper" way to go about it. However, setting it up may be daunting to new users especially those who are not familiar with the command line. One advantage of this approach is one can change the quotas without messing with the partitions.

On the other hand, setting up the new disk with two or more partition seems easier especially with a GUI application like Gparted. You don't have to learn and remember new commands. On the negative side, if you need a different quota assignment, you have to resize the partitions which always involves a risk of data loss resulting from mistakes or power failure etc.

Single User

It is harder to think of a situation where a single user may need two data partition, but it is not impossible.

One possibility is you are working on two different data intensive projects and one of them may generate huge amount of data filling up the whole disk. If that happens the code for that project will stop working at the same time the second project will also fail if the data from two projects are not in separate partitions.

Hope this helps

  • You don't have to have any partitions at all. You can dedicate the space of the whole device starting from LBA 0 to your filesystem. – Ruslan Feb 12 at 17:29
  • mkfs.ext4 /dev/sdb and mount /dev/sdb /mnt/mybigdrive is totally possible. Maybe not recommended, but possible :) – Doktor J Feb 12 at 20:58
  • @Ruslan Thanks for the comment. I have edited the answer and incorporated the your information. – user68186 Feb 12 at 21:50
  • @DoktorJ Thanks for the comment. I have edited the answer and incorporated the your information. – user68186 Feb 12 at 21:50
9

Seeing that the original author describes the disk as "newly formatted" and only to be used for data, not as a system disk, the question might also be interpreted as whether to create a partition table on the drive containing a single partition, as opposed to just creating the filesystem directly on the raw block device (e.g. /dev/sda).

If that is the case, I would definitely recommend creating a partition table containing a single large partition, for the following reasons:

  • If the drive gets connected to a machine running Windows, it won't recognize that the disk contains a filesystem, but rather see the drive as completely empty ("uninitialized") and offer the user to initialize it, i.e. create a partition table on it, thus overwriting the Ext4 superblock and corrupting the filesystem. On the other hand, if the drive contains a GPT/MBR partition table with a Linux partition, Windows would see the disk as being in use, just containing an unknown, inaccessible data partition.
  • If you unplug the disk, put it in a drawer and return to it in a few years time - or if somebody else might need to access the disk on your behalf - it will not be immediately apparent that the disk actually contains a filesystem rather than just being empty. Especially if it's connected to a non-Linux system. In that case, whomever accessing the disk might not realize that it contains data before it's too late, unless they take a look at its contents in binary form and identify it as Ext4 metadata.

Also, if you do decide to create the filesystem directly on the device without a partition table, make sure that the partition table is completely gone if it's a GPT partition table.

Unlike legacy MBR partition tables which only reside at the beginning of the drive, GPT keeps an additional copy of the partition table at the end, for recovery purposes in case the primary instance of the partition table gets corrupted.

If the initial partition table is missing due to it now being occupied by the filesystem superblock, partitioning tools might see the partition table as corrupted, and therefore try to repair it by overwriting the beginning of the drive with the backup kept at the end of the drive, thus corrupting the filesystem. No partitioning tool would hopefully ever do this without asking, but you never know.

A solution for the last issue would be to wipe both instances of the GPT partition table completely. This can be done using the "zap" feature of gdisk (GPT fdisk), accessible by entering the "experts mode" by pressing X in the initial menu, then Z for "zap". (Needless to say, make sure that you have selected the correct block device!)

The only apparent benefit for skipping the partition table on a physical disk, would be if every byte counts, and you have a specific purpose for the additional 2048 sectors (1 MiB) of storage at the beginning of the disk.

Another reason could be if you're using full disk encryption on the device with the LUKS header located elsewhere, so that it becomes more difficult to identify the contents as an encrypted filesystem rather than just random data. (Some people might call this security through obscurity.)

If legacy compatibility is a concern, an MBR partition table could be used rather than GPT. However, accessing a GPT disk would only cause issue on very old systems. If that is the case, it might even be worth considering using Ext3 or XFS rather than Ext4.

For virtualization purposes where disks may be moved around and resized at will, using disks containing filesystems without a partition table makes better sense, because it allows for more flexibility. For instance, the filesystem can be resized without modifying the partition table, and the data is easier accessible outside of the virtual machines, e.g. when mounting the partition on the VM hypervisor host.

2

One, sometimes, important aspects of partitioning on non random-access devices, like rotational HDDs, is localization of related data. Performance can be orders of magnitude better with proper localization. File systems tries to do good in this respect by keeping directories together in cylinder groups, but as time passes fragmentation becomes a fact. By using partitioning it is possible to keep related data together. Most people won't need this performance boost, but it is one reason for partitioning.

Also, there's the case where you want to have different filesystems on your disk, for various reasons. Then you have to partition. As much as you believe you will only ever have the need for one partition of one specific filesystem type, and one user, it may turn up wrong, and your needs six months from now might be different. 640KB of RAM wasn't enough for everyone after all.

There is also the case of security. There might be files you want to guard safe from e.g. ransomware. You don't want them mounted at all times, and then maybe only from certain virtual machines where you don't do promiscuous web browsing etc. So keep them in a separate partition.

I could tell a number of other more fringe reasons for wanting to partition. I am sure I have had over a dozen reasons during my 40 years of computing. I always give the advise: "keep some space for yet to be determined needs". One good thing is to use LVM to manage your space. Maybe just one disk won't be enough for the only "partition" (or logical volume). Then it is great to have the potential to have one volume span several disks. It comes with a performance trade-off, but the flexibility is really paying off, for a lot of us.

1

This question could be considered opinion based.

The main benefit to partitioning would be to keep your /home/ or other documents separate from your system partition. In the event that you want to wipe the partition with your operating system, the partition with your other documents could remain untouched.

However, In the matter of using the entire drive for storing non-system files, there is no benefit to partitioning that cannot be accomplished with organized folders. In fact, if you use partitioning for the purpose of organization, you actually reduce flexibility and, in effect, waste space.

1

Hard Drive Partitioning is useful when:

  • You want to have two or more operation systems on one drive (eg. Windows and Linux).
  • You want to separate operation system from your data. It allows you to have a backup of your system without creating a backup of your data or vice versa (partition backup). It also allows you to format a system partition without loosing your data.
  • Sometimes separate small partitions are created by operation systems automatically to store a bootloader or some system data (eg. OEM, restore points) separately from the main partition (Windows 10).
  • You want to restrict an amount of space for particular users or apps, so they cannot take all of the hard drive's space (and when quota is not an option).
  • Sometimes you might want a separate partition as an archive storage. So think you have drive C with all your work and you make an archive every month, put it into drive D and remove it from drive C, so every new month your drive C is empty.
  • Huge amount of files or directories (like 100k+ log files) will decreace disk performance because of huge file table. In this case you might want to separate those files by creating a special partition for that purpose. So your main partition will not loose a performace because its file table is small.

Otherwise partitioning will create complications, for example insufficient space on one partition and too much space on another.

P.S. You might think of several partitions on ONE DRIVE to have a RAID. The answer is NO. The performance will drop at least twice.

  • Partitioning is also useful when you want to follow best practice standards such as the CIS Benchmark. You might also break off /tmp or /var/log into separate partitions so that when (not if) they fill up it will not bring your system to a halt. – doneal24 Feb 12 at 17:53
  • While RAID on the same physical device has no purpose, your comment is not quite right. RAID-1 on two or more partitions will not hurt read performance and might actually help it. RAID-0 in a concatenate mode, not striped mode, should not affect either read or write performance. – doneal24 Feb 12 at 18:15
0

I "always" set up LVM. You can use the entire physical disk for a LVM partition. Then create logical volumes which can be expanded if necessary, without committing to a set volume/partition plan from the outset. Because you never know what tomorrow looks like.

Another major upside of LVM is that if you need to migrate your data to a new disk, for whatever reason, you can just add a new physical disk to the volume group and move the logical volumes to it, before removing the original disk(s) from the volume group and computer afterwards - with no additional configuration needed.

  • I tried LVM once and ran into constrictions. Things I could not do that I normally do with file systems because the file system was under different management. I may have quit too early but maybe not. Does LVM management restrict 'normal' user access? – Stephen Boston Feb 13 at 7:57
  • I'm not sure what kind of restrictions you ran into. After you've created a logical volume, you then decide what file system you put on it and where to mount it. Then any restriction would follow the file system. The only thing I can see that could be an issue, is if you place the LV's on an enterprise storage solution with underlying features, such as de-duplication, etc. which it could interfere with (although I don't see how). – OnkelJ Feb 13 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.