These exercises give you practice using
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
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:
- List the available commands.
- Find the partition types
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.
fdisk to design the hard disk with the
- 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
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.
fdisk to perform these tasks:
- Set the bootable flag to
- 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.
parted to perform these tasks:
partedinteractive 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.
parted to perform the following tasks:
- List available units.
- Change the unit to terabytes.
Follow these solution steps to check your work.
- The developerWorks article "Learn Linux,101: Hard disk layout" (developerWorks, February 2010) describes the commands required to complete these exercises.
- At the LPIC Program site, find detailed objectives, task lists, and sample questions for the three levels of the LPI's Linux systems administration certification. In particular, look at the LPI-101 detailed objectives and the sample questions.
- Review the entire LPI exam prep series on developerWorks to learn Linux fundamentals and prepare for systems administrator certification based on LPI exam objectives prior to April 2009.
- Exam Preparation Resources for Revised LPIC Exams provides a list of other certification training resources that LPI maintains.
Dig deeper into Linux on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Keep up with the best and latest technical info to help you tackle your development challenges.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.