Practice: Hard disk layout

Exercises for setting up your Linux system and software

If you're designing or otherwise working with partition tables, understanding how to navigate both fdisk and parted can help you plan hard disk layout with confidence. The exercises and solutions in this article give you practice in designing and working with a hard disk layout for a Linux computer.

Share:

Tracy Bost, Consultant and Trainer, Freelance

Author photo - Tracy BostTracy Bost is a seasoned software developer and systems engineer. He is also a lecturer and trainer for the Linux operating system. Tracy has been certified as both a Red Hat Certified Engineer (RHCE) and a Microsoft Certified Systems Engineer (MCSE), along with being an active member of the Linux Foundation. He has worked in several industries, including mortgage, real estate, and the nonprofit sector.



21 June 2011

Also available in Chinese

About this article

These exercises and solutions supplement the developerWorks article "Learn Linux, 101: Hard disk layout," which is part of the developerWorks knowledge path "Basics of Linux system administration: Setting up your system and software." You may want to read the "Hard disk layout" article before working through these exercises.

Overview

These exercises give you practice using fdisk and parted. Specifically, you'll practice:

  • Learning available commands in interactive mode
  • Creating partitions
  • Toggling a bootable flag
  • Finding information about existing partitions
  • Changing the unit of partition size display

Prerequisites

Develop skills on this topic

This content is part of a progressive knowledge path for advancing your skills. See Basics of Linux system administration: Setting up your system and software

To get the most from practice exercises in this series, you should have a basic knowledge of Linux and a working Linux system on which you can practice the exercises covered in this article. In addition, you should have a spare hard disk or an available flash drive for practice.

Important: To prevent possible loss of data, use an already formatted or otherwise empty hard disk. Alternatively, you could use an empty flash drive to complete these exercises.


Exercise 1. Work with fdisk commands

Assume that you are working as a Linux consultant for a new organization and have been hired to design the hard disk layout for the company's first Linux file server. Once you have mounted the drive, perform these steps:

  1. Enter fdisk interactive mode.
  2. List the available commands.
  3. Find the partition types Linux and Linux swap.

Exercise 2. Use fdisk to create partitions

For this exercise, assume a 4GB hard disk; you can adjust partition sizes accordingly if you are using a larger or smaller hard disk.

Use fdisk to design the hard disk with the following partitions:

  • Partition 1: 100MB (to be used as /boot )
  • Partition 2: 2GB
  • Partition 3: 1GB
  • Partition 4: 500MB
  • Change the partition 4 file system type to Linux swap

Exercise 3. Use fdisk to toggle bootable flag

The master boot record (MBR) should understand which partition in the table it will use to boot.

Use fdisk to perform these tasks:

  • Set the bootable flag to partition 1.
  • Use the command to save the changes and exit interactive mode.

Exercise 4. Work with parted commands

Say you are working as a Linux consultant for a large organization and you have been hired to design the hard disk layout for the company's complex, multi-terabyte hard disks. Although considered a bit more complex to use, parted has the ability to copy hard disks and re-size the partitions, if needed.

Use parted to perform these tasks:

  • Enter parted interactive mode using your practice hard disk's device location.
  • List the available commands.
  • Print the partition table.

Exercise 5. Use parted to change the mode of unit display

Depending upon the size of your hard disk, instructing parted to display partition sizes in a unit other than the default megabytes could provide for easier reading.

Use parted to perform the following tasks:

  • List available units.
  • Change the unit to terabytes.

Exercise solutions

Follow these solution steps to check your work.

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Linux on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=681825
ArticleTitle=Practice: Hard disk layout
publish-date=06212011