By Peter Tesar
With the increasing storage capacity of hard drives, the dividing or partitioning of the drive makes it easier to manage its use.
Windows users will be familiar with the c: drive (for Windows) and a d: drive (for data). These are just two partitions on one hard drive.
Linux will label the drive/partitions as:
/dev/sda1 and /dev/sda2
The last character, the number, is the partition number.
A second hard drive will be labeled: /dev/sdb.
It is possible for one drive to have separate partitions for one or more versions of Windows, one or more versions of Linux and data. A system with two or more operating systems is called a dual boot system.
Below are a few Linux CLI applications that will partition a drive. Each has its own strengths and weaknesses.
The simplest method is to let the Linux installer use the entire disk. This single partition will contain both the root directory (boot and application files) and the home directory (personal data).
A more advanced layout is to create a second partition for the home directory. This home partition will not need to be reformatted every time a new version of Linux is installed.
In the more advanced Dual Boot system, partitions should be created manually.
If Windows and Linux are desired, here is a suggested division of the drive:
partition1: Windows - NTFS file system partition2: Windows - NTFS file system partition3: Linux root - extended file system partition4: Linux home - extended file system
Note: only four primary partitions can be created on a single hard drive. For more partitions, make the fourth extended and then, create logical partitions. A Swap partition is not always necessary and it is placed at the end of the drive. 2GB should be adequate.
In this document only a few of the partition editor features will be mentioned. At the time of writing, some of the application versions will not support newer file types. E.g. parted v2.3 does not recognize NTFS.
A single drive system will be assumed: /dev/sda.
Older drives and other versions of Linux might label it /dev/hda.
For a list of drive and their partitions type:
$ sudo fdisk -l - display all
$ sudo fdisk /dev/sda - one drive only
A Window’s partition is formatted as NTFS-HPFS (NT or high performance). The older DOS used the FAT file system.
Linux uses the Extended (ext) file system, ext4 is the latest.
On its own, Windows does not recognize the extended file system while Linux recognizes ntfs. Third party applications can be used to allow Windows users to view the Linux partitions. E.G. ext2fsd.
Both Windows and Linux recognize the FAT file system. The USB Pen drives are formatted with FAT16 or FAT32.
For simplicity, a new partition will be created as Primary. Logical and Extended types will not be discussed here.
Note: 'gparted' is the GUI application.
Start parted with:
$ sudo parted /dev/sda
At the (parted) prompt, type one of these commands:
print - partition table
rm - remove a partition
mkpart - create a new partition
mkfs - make the file system
rescue - search a deleted area for a partition
select device - change to another drive
toggle - type ‘boot’ to change the boot flag
E.g. use mkpart to make a partition, these are the prompts:
Partition type? > type ‘primary’
File System? > type ‘ext2'
Start? > type ‘300gb’
End? > type '320gb’
Note: in earlier versions of parted, some file system types are not supported,
Cfdisk works best with Speakup. Turn on Speakup’s highlight tracking (numpad star).
From the console (ctrl+alt+F1), type:
$ sudo cfdisk /dev/sda
A table displays: name, flag, part-type, FS and size.
Arrow up and down to highlight an existing partition or the free space.
Arrow left and right to highlight the option.
Option explanation appears on the last line.
E.g. to create a new partition, highlight ‘free space’ and select the ’new’ option.
For each prompt, press ENTER to accept the first (default):
Size (maximum space in MB)
note: backspace and enter '100gb'
Beginning/End (if using less than the entire free space)
You will need to select a file system with the ‘type’ option.
A list appears showing many file system types (preceded by two characters).
Press enter for raw Linux or type ‘07’ for NTFS.
Review the table entry for accuracy before selecting the ‘write’ option.
Respond to the warning by typing ‘yes’.
Finally, choose the ‘quit’ option.
Testdisk works best with Speakup. Turn on the Speakup’s highlight tracking (numpad star).
Testdisk has limited use for the beginner. Here is a simple walk-through.
From the console (ctrl+alt+F1), type:
$ sudo testdisk
From the first list, arrow down and select ‘no log’.
From the next list, select a disk drive.
From the partition table, select ‘Intel’ (top of list).
From the next list, select ‘Analyse’ (top of list).
The current partition structure table displays:
Partition, flag, Start, End, Size in sectors.
Flags denote: '*' boot, 'P' Primary, 'E' Extended …
Use ctrl+c (control break) to quit.
!!End of Article