0% found this document useful (0 votes)
11 views17 pages

Week 08 - CLO4 - Managing Disks and Partitions

Uploaded by

Ali Alasfoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views17 pages

Week 08 - CLO4 - Managing Disks and Partitions

Uploaded by

Ali Alasfoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

CIS 2903: Operating Systems

CLO4
Managing Disks & Partitions

1
Lesson Objectives
• CLO4  Perform common workstation administration and
troubleshooting tasks which include creating directories,
users, groups, files and storage.

• After this lesson, you will be able to:


• Create, format, label, mount & unmount partitions
• Check partition usage

2
Commands to manage partitions
Following are the commands to perform different operations
on partitions in Linux:

1. Create partition (fdisk)


2. Format partition (mkfs)
3. Mount partition (mount)
4. Unmount partition (umount)

3
Partitioning
• When you partition a hard disk, you define a space that can
be formatted with the file system of your choice
• A hard disk must have at least one partition on it in order
to be useful
• To partition a hard disk, use the fdisk command

4
Disk and partition names
• Disk names
• /dev/sda (1st disk)
• /dev/sdb (2nd disk)
• Partition names
• /dev/sda3 (3rd partition on 1st disk)
• /dev/sdb1 (1st partition on 2nd disk)

Note:
In the past, “sd” meant SCSI disk and “hd” meant IDE disk.
Now, all disks (SCSI, IDE, SATA, USB, etc.) use “sd”.

5
Managing partitions using fdisk

• The fdisk command allows you to manage hard disk


partitions (only admins are allowed to use it)

 To display all disks and


partitions on the
system, we can use
fdisk command with
the switch “-l” (letter
“el”, not number 1)

# fdisk –l

6
Managing partitions using fdisk (cont’d)

• Using the menu-driven fdisk program


• Syntax: fdisk [disk]
• Example, fdisk /dev/sdb

• Common menu items:


• n create a new partition
• p print (i.e. display) current partition table
• d delete a partition
• q quit without saving changes
• w write to disk (i.e. save) & exit

7
Formatting the partition

• Formatting a partition means defining the file system to be


used on it.
• Every hard disk partition must have a file system on it before it
can be used.
• We format the partition to create a file system
• Common file systems are FAT, FAT32, NTFS, ext2, ext3, ext4,
HPFS etc.

8
‫مهم‬Linux file system types
• Common Linux file system types:
• ext3 (Third Extended File System)
• default until recently
• solved slow reboot problem in ext2
• ext4 (Fourth Extended File System)
• current default
• removed 64-bit storage limits from ext3
• swap
• a swap partition instead of a swap file

9
Formatting the partition using mkfs

• mkfs command formats a partition in Linux

• Syntax: mkfs –t fstype partition


• the fstype can be ext3, ext4, vfat, ntfs, etc.
• the partition is like /dev/sda1 or /dev/sdb2

• Examples
• mkfs –t ext4 /dev/sda1
• mkfs –t vfat /dev/sdb2

10
Mounting storage devices

• After a partition has been formatted, the system must give


you a way to access it
• Windows uses a drive letter
• Linux uses a directory (called the mount point)

11
Mounting the partition using mount
• The mount command associates a partition with a directory that
allows the user to access the data

Syntax: mount –t <fs_type> <dev> <dir>


mounts one formatted partition

• fs_type is the file system (i.e. fat, ntfs, ext, ext4 etc.)
dev is the device file (i.e. the partition to load, such as /dev/sdc2)

dir is the mount point (a directory where the partition will be loaded)

Example:

mount –t ext4 /dev/sdb1 /var/mylogs

12
Unmount a partition using umount
• The umount command removes/unloads a partition from
the file system tree
• similar to “Safely Remove” for USB sticks
• data on the unmounted partition is safe, but you cannot access it.
• You need to mount the partition to access the data
• Syntax: umount <dir>
umount <dev>
• Use the mount point or the device name.

13
Checking free space on mounted partitions
• The df (disk free) command displays info on all currently
mounted partitions
• name
• total, used & available space
• mount point
• Syntax
• df displays space in 1K-blocks
• df –h displays space in megabytes
(“human-readable”)

14
df examples

Partition
Partition Size
Size

Space
Space

Mount
Mountpoint
point

15
Practical Task – Adding Disk/Partition

• Go to VMWare
• Select your virtual machine
• Add a new hard disk (SCSI – Single File) of size 2 GB (2048 MB) to your virtual
machine.
• Boot your Linux (Fedora).

• Use fdisk command to create a partition on this disk


• Use mkfs command to format the newly created partition
• Make a directory /data
• Use mount command to mount the new partition to the folder /data
• Use df or mount command to confirm the newly created partition is mounted to
the folder /data
16
Command summary

Command Use
fdisk Create/delete a hard disk partition
mkfs Format a hard disk partition
mount Mount a formatted partition
umount Unmount a formatted partition
df Display free space on mounted partitions

17

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy