January 19, 2006

Creating and managing filesystems with Expert Partitioner

Author: Michael McCallister

The first, and perhaps only, time you have to create a new file system on your Linux computer is when you first install the operating system. If you add a second hard drive, or have set up a series of mount points that you decide to adjust in one way or another, you can use SUSE's YaST Expert Partitioner tool to handle this task for you.

This article is excerpted from the newly published bookSUSE Linux 10 Unleashed.

Until GNU Parted came along, partitioning in Unix and Linux was handled by the standard fdisk shell utility. It works a little differently from its DOS namesake, but performs the same essential tasks: creating and modifying the partition table.

The main difference between fdisk and Parted/Expert Partitioner, aside from the GUI, is that fdisk does not preserve existing data. If you tell fdisk to make the root partition 10GB smaller and create a new partition where the old one was, fdisk will do exactly that. If there was data sitting on a block in the last 10GB, it will be overwritten.

Feel free to use fdisk from the shell if you prefer, knowing its limitations.

Expert Partitioner (EP) is a GUI version of GNU Parted integrated into YaST. If you have used either of the Windows third-party partitioning products -- PartitionMagic or Partition Commander -- you will find EP familiar.

It simplifies the partitioning process and can adjust the partition table without harming existing data. You should know what you're doing before you begin, however. There is a reason it's called Expert Partitioner.

Caution - Unless you are working with new or otherwise empty drives, Expert Partitioner can ruin some data or even your entire hard drive. This is a very rare occurrence, but if you're making changes to your partition table in the middle of a thunderstorm, power surges can mess things up badly.

Always back up at least your most important files before using EP, even if you are not planning to touch that mount point! And use an Uninterruptible Power Supply (UPS) whenever you have important data of any kind on your computer. This is the minimum protection you need.

Using Expert Partitioner

Now that all the warnings are out of the way, we can begin to work with EP. It is actually a very simple tool. To open it, go to YaST, System, Partitioner. YaST will repeat the warnings you've seen in this section and make you click Yes before opening the tool.

There you will see your current partition table laid out, as shown in Figure 1.

It's a good idea to have a hard copy of all this information, so write it down in your notebook before making any changes.

You can see that two physical hard drives are on this system: /dev/hda and /dev/sda. Each drive is 74.5GB after formatting. /dev/hda has two Linux partitions, Root (/) and Swap; /dev/sda has one Windows (NTFS) partition, seen here as /windows/C. The Start and End numbers are the block numbers, showing where on the disk each partition/mount point begins and ends.

Note - DOS/Windows (and practically all BIOS programs) supports only four primary partitions on a drive. Dual-boot systems have a particular problem with this setup. To get around this limitation, use the idea of turning one primary partition into an "extended partition" that allows you to create multiple "logical partitions," making more efficient drives by making smaller sectors/blocks. There are few limitations on the number of logical partitions inside an extended partition.

You can install SUSE Linux into an extended partition; this is what YaST does by default. Linux file systems support up to 15 partitions/mount points.

Writing this information down is yet another safety valve in case of emergency, because you can reconstruct the table with the accurate start and end blocks if necessary.

At the bottom of the screen are eight action buttons that correspond to the task at hand. With EP, you can do the following:

  • Create a new partition from empty space on the disk.

  • Edit an existing drive or partition.

  • Delete an existing partition or drive (and all the data on it).

  • Resize a partition to make it larger or smaller.

  • Manage a logical volume (this is covered later in this chapter).

  • Create or manage a RAID volume structure (this is covered in Chapter 20, "Managing Data: Backup, Restoring, and Recovery").

  • Encrypt a partition.

  • Reread or delete a partition table (under the Expert button).

The following sections walk you through these tasks.

Note - When you're working with Expert Partitioner, you can do some experimentation without making changes to your system. Nothing you set up in the EP interface becomes final until you click Apply from the main window.

Creating a New Partition

Click Create to set up a new partition. Depending on your setup, you will be asked what disk to create the partition on and whether it is a primary or extended partition (see the preceding Note). EP then displays the Create Partition dialog box, shown in Figure 2.

Figure 2 shows the default settings for this dialog box. In addition to the ReiserFS, you can format the new partition as ext2, ext3, JFS, XFS, or as increased Swap. You can also create a FAT partition readable by Windows. The contents of the Options dialog box changes depending on the file system you choose.

A new partition can use only unformatted space on the physical drive. By default, EP will have this partition fill up the remaining free space, but you can choose to leave some space unformatted (and perhaps ready for another partition) by entering either a specific end cylinder or (as indicated) the size of the partition in megabytes (MB) or gigabytes (GB).

Tip - Check the Encrypt File System box to encrypt all new files created or moved into your new partition.

The Fstab Options button lets you set up Journaling mode (Ordered is the default), whether a user can mount this partition (No is the default), and whether to mount the partition automatically at startup (Yes is the default). You'll learn more about the fstab file in the "Mounting a File System" section.

The last section is the mount point definition. The default here is /usr, but you can use the drop-down menu or type in a mount point as well.

Tip - If you're adding a FAT partition, make /windows/D (or another drive letter) the mount point.

Click OK to confirm your choices.

Editing a Partition

When you select an existing partition and click Edit, the dialog box is nearly identical to the one shown in Figure
2. All the options are editable except for the size parameters. You must use the Resize tool to change that.

Why would you edit a partition? If you want to use the Logical Volume Manager (LVM), at least one partition must have the type Ox8e or Ox83. You can set that in this dialog box. You may also want to change the fstab settings for a partition without editing the file by hand. Or you may want to change the mount point for one reason or another, especially with a nonroot partition.

Deleting a Partition

There are only two reasons to delete a partition with EP: You've copied off all the data and want to recover the space for something else entirely, or you have a nonroot mount point that you don't want to treat as a separate partition anymore.

The latter situation can occur when you define a mount point for /usr or /home to get a faster response from the disk, and the results are disappointing. In that case, move all the files back to the / partition before deleting the mount point.

To use EP to delete a partition, first unmount it with the umount command at the shell prompt. Open EP. Select the partition. Click Delete. You may get a warning, especially if you haven't unmounted or if you accidentally selected the / partition. EP will then mark the partition for deletion. The delete action will not be final until you click Apply. After you do that, the partition will be gone, and the space will be available. See the section on umount later in this chapter.

Resizing a Partition

This is the trickiest part of the EP process and is the special trick of GNU Parted. The standard Linux fdisk program creates, edits, and deletes partitions. But fdisk, like its DOS/Windows counterpart, is destructive when it performs its functions. fdisk will cheerfully create a new partition where some old data is lying around, but that data will be no more when it's done.

Parted and EP will shrink an existing partition, taking care to preserve existing data and not overwrite it. You can then create new partitions on the empty space remaining.

To resize a partition, select the partition in EP and click Resize. The Resize dialog box shown in Figure

Use the slider, the spin box, or type in the size (in gigabytes) you want your new partition to be in the Unused Disk box. The second, bottom graphic will show what the disk will look like after the resizing takes place.

If you change your mind, click Do Not Resize to return the settings to where they were. If you are ready to proceed, click OK. The partition will be marked for resizing.

When you have confirmed your intention to resize the large partition, use Create as previously described to create the new partition(s) to fill the newly created space. After you've done that, click Apply to implement the new changes. You can turn back at any time before you click Apply.

Encrypting a Partition or Files

If you run a business with your computer, you probably have some files that are more sensitive and valuable than others. You want to protect this information from prying eyes. Setting permissions and other access control tools is an important method of securing these files, but some things need even more security. This is especially true with data on laptops and removable hard drives.

SUSE Linux makes it possible, and relatively easy, to set up an area where files are encrypted within that space. You can set off an entire partition or create an encrypted file system within single files.

You have the option of creating encrypted partitions during the installation process, but you can also do this within EP.

Caution - Don't use EP to encrypt a running file system! Adding encryption will destroy any data on a running partition. Always resize another partition and then create a new, encrypted partition using the preceding steps.

To create a single encrypted file to hold secure data, click Crypt File, Create Crypt File in the EP dialog box. The dialog box seen in
Figure 4 appears.

Enter the path to the file to create along with its intended size. This is set to 50MB by default. Remember that this will be just one file, holding a spreadsheet with your balance sheets, for example. You want this file to be big enough to hold a growing file, but not so big that it encroaches on your capability to store other files. A good rule is to estimate how big that spreadsheet could get over the lifetime of your computer, and then double it.

SUSE recommends accepting the proposed settings for formatting and the file system type (that is, formatting for ext3). Specify the mount point. Decide whether the crypto file system should be mounted during boot in the fstab options. Click OK to mark this file for creation. EP will put this file at the end of the current partition. Your encrypted file will not be created until you click Apply at the end of the process.

To access an encrypted partition, you must use the mount command to make the partition visible. You will be asked to supply the password. See the section on the mount command later in the chapter.

Expert Functions

Two Expert functions round out the EP tasks. If you suspect that the partition table is not showing up correctly in the EP window, click Reread Partition Table.

It's not even close to being a common occurrence, but a bad label can get attached to a disk. If you're having otherwise weird problems on your system, disposing of the label can be a last gasp. Delete Partition Table and Disk Label is the equivalent of waving the white flag and saying goodbye. Along with the bad label, everything else on that partition will disappear as well. Always back up before running this one.


  • Linux
Click Here!