What are partitions?

Partitioning is a way to divide a hard disk (or any block device) install smaller block devices.

Most Windows and Macintosh computers have one big partition that contains all your operating system files and data files.

Most linux computers divide a single disk into separate block devices by partitioning the disk. Typically, different areas of your computer are assigned to separate block devices. For example, your home directory is on one block device, your operating system's space for writing temporary files is on a different one, etc.

Why partition?

  1. Wouldn't it be simpler to just use the entire disk and not worry about partitions at all?
  1. Yes, it would be simpler. But, you would miss out on some useful features that you get when you partition your hard disk.

Most computers come with large disks that contain more space than we can use immediately. By only partitioning the part of your disk that you know you will use right now, you are free to allocate the remaining space later, when you know how you want to use it.

For example, you might want to allocate space to a virtual computer. You may want to create a big partition for videos, but ensure that if you accidentally download too many videos, you want run out of disk space on the partition that holds your incoming email. You may want to copy all your important data to a new partition so you can re-install your operating system on your existing partitions.

  1. But what if I create a partition and then later decide it's too small or too big?
  1. Logical Volume Manager is a system that allows you to dynamically resize your block devices at a later time. You can grow, shrink or even delete them.

The Big Picture

First some terminology.

A block device is medium that a computer can read from and write to in randomly organized blocks of data. Hard disks, flash disks, CD-ROM drives are examples of block devices. When you partition a block device, you create a new block device. You can then (if you want) partition that resulting partition.

Hard disks and flash disks are block devices that can be partitioned into multiple block devices. A linux operating system will name block devices it recognizes in the form of sda, sdb, sdc, etc. These block devices can be further partitioned into sda1, sda2, sdb1, sdc1, sdc2, sdc3, etc.

An encrypted block device is a block device (e.g. sda2) that is configured to have all data saved to it encrypted and all data read from it de-crypted (provided the correct passphrase has been provided during boot). Encrypted block devices are typically given a new name (e.g. sda2 might become sda2_crypt). The resulting encrypted block device (sda2_crypt) appears to applications just like any other block device.

Logical Volume Manager (LVM) is software that manages disk drives and other mass storage devices. Logical Volume Manager has three important concepts:

  • Physical devices: these are un-used block devices.
  • Volume Group: Physical devices can be added to a volume group. The size of the volume group is the sum of the sizes of all the physical volumes added to it.
  • Logical Volume: A logical volume is a block device that you can create from a Volume Group. When you create a logical volume, the remaining space available in the volume group is reduced by the size of the logical volume that you created.

For a graphical description, see the logical volume manager diagram.

Partioning during a Debian installation

One of the hardest questions to answer during a Debian installation is how to partition your disk. You are presented with four options:

  • Guided - use entire disk
  • Guided - use entire disk and setup LVM
  • Guided - use entire disk and setup encrypted LVM
  • Manual

This page explains how to setup your partitions using the "Manual" option in a way that will result in something similar to "Guided - use entire disk and setup encrypted LVM," but allows you to fully understand each part.

The Goal

Our goal is to have a computer with two partitions, an encrypted disk, and logical volume manager so we can easily resize our block devices at a later time.

The disk partition diagram provides a good snapshot of what we will be doing.

Step by Step

  1. Delete any existing partitions on your disk
  2. Add a new partition, 512MB, primary, starting at the beginning of the disk, use as: Ext3 journaling filesystem, and mount point: /boot
  3. Add a second partition with the remainer of the space, primary, use as: physical volume for encryption (take all default volues).
  4. Click Configure encrypted volumes
    • agree to format existing partitions
    • Create encrypted volumes
    • Select /dev/sda2
    • Click Finish
    • Really erase data? No.
    • Enter passphrase
  5. Select sda2_crypt, Use as: physical volume for LVM
  6. Select Configure the logical volume manager
    • Create volume group, provide name (suggestion: vg_HOSTNAME0 - replace "HOSTNAME" with your actual computer name)
    • Select /dev/mapper/sda2_crypt as the device
    • Create Logical Volume (repeat for root - 5GB, var - 5GB, tmp - 1GB, home - 20GB, and swap - 1GB):
  7. For each LV that you created, modify it to use Ext3 journaling filesystem and to be mounted in the appropriate place (home in /home, var in /var, etc.)
Last modified 9 years ago Last modified on Jun 22, 2012, 6:34:03 PM

Attachments (4)

Download all attachments as: .zip