Drive Partitioning: Difference between revisions

From The Brainwrecked Wiki
Jump to navigation Jump to search
m 1 revision
(No difference)

Revision as of 21:52, 5 January 2014

File:Under construction icon-blue.svg

UNDER CONSTRUCTION

The author walked away without completing this article.
Most likely, it was beginning to drive them up the wall.

Most people don't know about hard drive partitioning. With the way most OEM computers and external storage medium is shipped, the only time a person would come face-to-face with partitions is when buying an internal hard drive or installing Linux. While this certainly makes things easier to set up, it can make things more difficult in the long run. Chiefly, when operating system data gets borked by a virus, bad system setting, or hardware failure. By using partitions to separate data, that data becomes easier to maintain.

Limitations of Partitions

While newer PCs are beginning to utilize UEFI and GPT, most computers still utilize BIOS and MBR introduced all the way back in 1980. MBR carries some serious limitations.

  • Limit of 4 primary partitions
    • 1 primary partition can be designated as an extended partition
    • The extended partition can contain any number of logical partitions
    • Windows will not allow you to install it to a logical partition
      • This includes recovery tools based on Windows.
  • Limit of 232-1 (4,294,967,295) addressable sectors
    • 512B sectors makes for 2TB
    • 4K sectors would make for 16TB
    • Manufactures are still falsely reporting 512B sectors to maintain compatibility.

If you are able to use GPT, by all means use it as it simplifies matters greatly.

Recovery Partition(s)

If you bought a pre-made computer and you did not receive any recovery discs, chances are that your OEM has created a partition at the beginning of the hard disk for use as a recovery partition. Worse yet, OEMs are starting to use more than one parition -- one that contains the Windows Pre-Installation Environment only and another with the files actually needed to perform the recovery. The partition(s) is/are usually marked as hidden but can be accessed during the BIOS boot process.

It's best just to get rid of the partition(s) all together.

  1. Find the OEM's recovery disc creation program in the installed OS and run it.
  2. Make ISO backups of the recovery discs to an external drive or network share.
  3. Re-partition the drive to suit your needs.
  4. Boot from the recovery discs to re-install your operating system.
  5. Select the recovery option that leaves the partition table as-is.

NB: Some recovery tools will state that they will delete the partition that they are going to install Windows on. This is technically incorrect. They are going to delete all data on that partition by formatting it. The partition itself will remain in tact.

Notes

KB, MB, GB, and TB will be the binary definition of KB, MB, GB, and TB.

AF = Advance Format (4K internal sectors)
NF = Normal Format (512B internal sectors)

In preparation for AF drives, all space allocations recommendations will be in 4KB chunks.

Linux's fdisk forces partitions to be aligned to 1MB boundaries.
GNU's parted will let you to start at sector 1 if you want.
If using an AF drive, you'll want to start at sector 8.
If using GRUB2, you'll want to start at sector 63/64.

Single OS Solutions

Use A Single Partition

WARNING: If you place all your data in a single partition, you can kiss it goodbye if the fliesystem becomes horribly corrupted. Even if you make backups, say hello to the aggravation of restoring from backups.

This is the default setup for Windows and Mac OS. However, both of these operating systems create a swap file within the main file system by default, whereas Linux does not. While Linux really doesn't care if you have swap space or not, it will also be more than happy to just freeze on you when you run out of memory.

Still want the swap space in Linux but don't want the added partition? The trick is to create the partition, format it, mount it, and then issue the following commands. Note that count=1024 will give you 1GB.

dd if=/dev/zero of=/mnt/swapfile bs=1M count=1024
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile

You can mount the swap file immediately by using:

swapon /mnt/swapfile

You can mount the swap file at boot time by editing /etc/fstab to include this line:

 /mnt/swapfile none swap sw 0 0

Use Two Partitions

This is a much better compromise between partition consolidation and data retention.

Size Usage FS Mnt
3GB
7GB
25GB
Linux Server
Linux Desktop
Windows Vista/7
any
any
NTFS
/
/
C:
Where the operating system and programs will reside.
free space Linux
Windows 2000/XP
Windows Vista/7
any
NTFS
NTFS
/home
C:\Documents and Settings
C:\Users
Kept separate so that it's easier to upgrade the OS without worrying about the data.

While Windows does not have the same filesystem mounting concept as Linux, Windows has had junctions (hard links) since Windows 2000. You can use this to craftily move C:\Users (C:\Documents and Settings in 2000 and XP) to another partition/drive.

Using More Partitions

Of course the choices are limitless. Some common things that you may want to partition off are:

Boot Loader
Needed only if using Linux with a root partition that is encrypted or RAIDed.
Games
Putting your games onto a separate partition usually makes it easier to backup and share games between OSes. Steam is a perfect candidate for this.
"Local" Share
Useful as a places to transfer files between OSes or for when network storage/transfer would really bog things down (Virtual Machines, DVD/Bluray ripping).
Swap
Creating a separate partition for this is normal for Linux but not for Windows. The only problem with Windows is that there will be file system overhead space-wise. (Example: An 8GB partition loses 10.5MB to the file system.)


Dual-OS Solutions

Windows requires installation to a primary partition and should be installed to the first partition on the hard drive. The Windows NT lineage (NT 4.0, 2000, XP, 2003, Vista, 7, 8) is extremely goofy with its boot loader in that it points to specific point on the disk relative to the whole disk instead of its own partition. This means that if you move the Windows partition Windows will fail to boot.

If you are not encrypting, RAIDing, or LVMing your hard drive(s), /boot does not need its own partition. This should free up one partition.

You can also use LVM to split one physical partition into two logical ones. In this event, join the values for swap and / (root), use the space for a single LVM group, and define the logical volumes accordingly.

Linux, with NFS, can have the /home directory hosted on a file server.

If all else fails, Linux will be happy to exist on Extended Partitions, unlike Windows.