--- xml/htdocs/doc/en/handbook/hb-install-x86+amd64-disk.xml 2009/01/26 08:04:26 1.13 +++ xml/htdocs/doc/en/handbook/hb-install-x86+amd64-disk.xml 2012/10/06 19:54:14 1.20 @@ -4,7 +4,7 @@ - + @@ -13,8 +13,8 @@ This chapter describes how to partition a disk for future usage. -6.2 -2009-01-09 +13 +2012-10-06
Introduction to Block Devices @@ -67,10 +67,10 @@

-The Installation CDs provide support for EVMS and LVM2. -EVMS and LVM2 increase the flexibility offered by your partitioning setup. +The Installation CDs provide support for LVM2. +LVM2 increases the flexibility offered by your partitioning setup. During the installation instructions, we will focus on "regular" partitions, -but it is still good to know EVMS and LVM2 are supported as well. +but it is still good to know LVM2 is supported as well.

@@ -118,7 +118,10 @@ If you are interested in knowing how big a partition should be, or even how many partitions you need, read on. Otherwise continue now with partitioning your disk by reading Using fdisk to Partition your -Disk. +Disk or Using parted to Partition your Disk +(both are partitioning tools, fdisk is well known and stable, +parted is a bit more recent but supports partitions larger than +2TB).

@@ -166,10 +169,18 @@

-However, multiple partitions have one big disadvantage: if not configured -properly, you might result in having a system with lots of free space on one -partition and none on another. There is also a 15-partition limit for SCSI and -SATA. +However, multiple partitions have disadvantages as well. If not configured +properly, you will have a system with lots of free space on one partition and +none on another. Another nuisance is that separate partitions - especially +for important mountpoints like /usr or /var - often +require the administrator to boot with an initramfs to mount the partition +before other boot scripts start. This isn't always the case though, so your +results may vary. +

+ +

+There is also a 15-partition limit for SCSI and SATA unless you use GPT +labels.

@@ -197,8 +208,8 @@ seem excessive, remember that Portage uses this partition by default for compiling packages. If you want to keep /var at a more reasonable size, such as 1GB, you will need to alter your PORTAGE_TMPDIR variable -in /etc/make.conf to point to the partition with enough free space -for compiling extremely large packages such as OpenOffice. +in /etc/portage/make.conf to point to the partition with enough +free space for compiling extremely large packages such as OpenOffice.

@@ -209,9 +220,16 @@ + +If your environment will deal with partitions larger than 2 TB, please +use the Using parted to Partition your Disk +instructions instead. fdisk is not able to deal with larger +partitions. + +

The following parts explain how to create the example partition layout -described previously, namely: +using fdisk. The example partition layout was mentioned earlier:

@@ -466,6 +484,204 @@ +
+Using parted to Partition your Disk + + + +

+In this chapter, we guide you through the creation of the example partition +layout mentioned earlier in the instructions. Unlike the previous chapter, we +describe the method using the parted application instead. Both +parted and fdisk offer the same functions, so if you partitioned +your system using fdisk already, you can skip this section and continue +with Creating Filesystems. +

+ +

+The example partition layout we use is shown in the next table: +

+ +
+ + + + + + /dev/sda1 + Boot partition + + + /dev/sda2 + Swap partition + + + /dev/sda3 + Root partition + +
PartitionDescription
+ +

+Change your partition layout according to your own preference. +

+ + +
+ +Viewing the Current Partition Layout + + +

+The parted application is a somewhat more modern variant of +fdisk. It offers a simpler interface for partitioning your disks and +supports very large partitions (more than 2 TB). Fire up parted on your +disk (in our example, we use /dev/sda): +

+ +
+# parted /dev/sda
+GNU Parted 2.3
+Using /dev/vda
+Welcome to GNU Parted! Type 'help' to view a list of commands.
+
+ +

+To find out about all options supported by parted, type help and +press return. For now, we just continue by asking parted to show the +partitions currently in use on the selected disk. The print command can +be used for that. +

+ +
+(parted) print
+Model: SCSI Block Device
+Disk /dev/sda: 21.5GB
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+
+Number  Start   End     Size    Type     File system     Flags
+ 1      512B    2148MB  2148MB  primary  ext4
+ 2      2148MB  3222MB  1074MB  primary  linux-swap(v1)
+ 3      3222MB  21.5GB  18.3GB  primary                  lvm
+
+ + +
+ +Optional: Setting the GPT Label + + +

+Most disks on x86/amd64 are prepared using an msdos label. However, if +you plan on creating huge partitions (2 TB and more), you must use a gpt +label (the GUID Partition Type) for your disk. Using parted, this +can be accomplished with mklabel gpt: +

+ + +Changing the partition type will remove all partitions from your disk. All data +on the disk will be lost. + + +
+(parted) mklabel gpt
+
+ + +
+ +Removing all Partitions + + +

+If this isn't done yet (for instance through the mklabel operation +earlier, or because the disk is a freshly formatted one), we will first +remove all existing partitions from the disk. Type rm <number> +where <number> is the partition you want to remove. +

+ +
+(parted) rm 2
+
+ +

+Do the same for all other partitions that you don't need. However, make sure you +do not make any mistakes here - parted executes the changes immediate +(unlike fdisk which stages them, allowing a user to "undo" his changes +before saving or exiting fdisk). +

+ + +
+ +Creating the Partitions + + +

+Now let's create the partitions we mentioned earlier. Creating partitions with +parted isn't very difficult - all we need to do is inform parted +about the following settings: +

+ +
    +
  • + The partition type to use. This usually is primary in case you + are not going to have more than 4 partitions (with the msdos + partition label). Otherwise, you will need to make your fourth partition an + extended one which hosts the rest of the disk, and create + logical partitions inside it. If you use a gpt-labeled + partition, then there is no limit on the number of primary partitions. +
  • +
  • + The file system type to use. The parted application supports + most common file systems and knows which kind of partition ID it needs to + use for these partitions. This does not mean that parted will + create a file system on the partition (you can with the mkpartfs + command, but we'll use the regular mkfs.* commands later for this + purpose). The partition ID is often used by auto-detection tools to know + what to do with a particular partition. +
  • +
  • + The start location of a partition (which can be expressed in MB or GB) +
  • +
  • + The end location of the partition (which can be expressed in MB or GB) +
  • +
+ +

+One advantage of parted is that you can easily just use the partition +sizes to automatically find the correct start and end location as you will see +in the next example. +

+ +
+# Create a 32 mbyte /boot partition
+(parted) mkpart primary ext2 0 32mb
+Warning: The resulting partition is not properly aligned for best performance.
+Ignore/Cancel? i
+
+# Create a 512 mbyte swap partition
+(parted) mkpart primary linux-swap 32mb 542mb
+
+# Create a partition that spans the remaining disk.
+# -1s (minus one s) means the end of the disk
+(parted) mkpart primary ext4 542mb -1s
+Warning: You requested a partition from 542MB to 21.5GB.
+The closest location we can manage is 542MB to 21.5GB.
+Is this still acceptable to you?
+Yes/No? y
+
+ +

+You can now print the partition layout again to validate if everything is +as expected. When you are satisfied, use the quit command to exit +parted. +

+ + +
+
Creating Filesystems @@ -503,11 +719,15 @@ ext2 - mke2fs + mkfs.ext2 ext3 - mke2fs -j + mkfs.ext3 + + + ext4 + mkfs.ext4 reiserfs @@ -530,8 +750,8 @@

-# mke2fs /dev/sda1
-# mke2fs -j /dev/sda3
+# mkfs.ext2 /dev/sda1
+# mkfs.ext3 /dev/sda3