Week 08 - CLO4 - Managing Disks and Partitions
Week 08 - CLO4 - Managing Disks and Partitions
CLO4
Managing Disks & Partitions
1
Lesson Objectives
• CLO4 Perform common workstation administration and
troubleshooting tasks which include creating directories,
users, groups, files and storage.
2
Commands to manage partitions
Following are the commands to perform different operations
on partitions in Linux:
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
# fdisk –l
6
Managing partitions using fdisk (cont’d)
7
Formatting the partition
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
• Examples
• mkfs –t ext4 /dev/sda1
• mkfs –t vfat /dev/sdb2
10
Mounting storage devices
11
Mounting the partition using mount
• The mount command associates a partition with a directory that
allows the user to access the data
• 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:
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).
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