0% found this document useful (0 votes)
35 views21 pages

Access Linux Files Systems

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)
35 views21 pages

Access Linux Files Systems

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/ 21

DISK MANAGEMENT

1. Adding a New Disk

a. Overview of Partitions

b. Traditional Disk and Partition Naming Conventions

2. Managing Storage Disks (partitioning, formatting, un/mounting and defragmenting)

a. Mounting and Unmounting Local Disks

b. Using fdisk, fsck and mkfs, mount and umount


• Linux disk management includes several important tasks such as

adding or removing storage devices, creating and deleting partitions,

mounting partitions on appropriate directories, and making file

systems in partitions.
INSTALLING ANEW DRIVE
• You create file systems and install disk driven When installing Linux. You might need to add a disk to a

working system. For example, you might add a new drive to expand the storage space available on a system.

• You need to take various steps to install a new drive

1. Select a drive type

2. Select a file system type

3. Physically install it in your system

4. Partition the drive

5. Mount the drive either manually or automatically at boot time


DRIVE TYPES

• Of various types of hard drives, the most common with Linux are

1. ATA,

2. SATA and

3. SCSI.
ATA/IDE DRIVE
• ATA: this is the evolution of the technology formerly called IDE. Until recently. It was the most
popular drive interface used with personal computers.

• Pc motherboards typically feature two ATA drive controllers each with two channels. You can attach
one drive to each channel. With ATA, the first drive controller is called the master and the second is
called the slave.
Primary master = /dev/had

Primary slave = /dev/hdb

Secondary master = dev/hdc

Secondary slave = dev/hdd


SERIAL ATA (SATA)

• SATA dispenses with the master/slave architecture, instead of providing a

separate controller to each drive. Under Linux, SATA drives show up as follows:

• First SATA drive = /dev/sda

• Second SATA drive = /de/sdb

• And so forth
SCSI

• Each SCSI controller supports a maximum of either 7(older SCSI system) or 15 devices, one

of which is the controller itself. Under Linux, these drives show up as follows:

• First SCSI disk = /dev/sda

• Second SCSI disk = /dev/sdb

• Third SCSI disk = /dev/sdc

• And so forth
• Disk Partitioning is the process of dividing a disk into one or more logical areas,
often known as partitions, on which the user can work separately. It is one step of
disk formatting. If a partition is created, the disk will store the information about
the location and size of partitions in the partition table. With the partition table,
each partition can appear to the operating system as a logical disk, and users can
read and write data on those disks. The main advantage of disk partitioning is
that each partition can be managed separately
PARTITIONING

Partitions are organizational units of storage. A partition is defined by the file


system it contains. For example, ext2,ext3, etc. these file systems determine how
files are organized and saved on the disk drive and how changes are recorded and
committed.

Linux requires a minimum of two partitions:

1. One mounted to the root directory known as the root partition

2. One used to hold the contents of virtual memory known as the swap partition
• Partition definitions are stored in the first sector of the hard drive in a
structure called the Master Boot Record (MBR) or Master Boot Block
(MBB).

• In Linux, device files are created to represent the partitions. These device
file names mirror the name s of the hard disk and are then numbered
sequentially. For example, the first partition on the primary master IDE
drive (/dev/hda) would be called /dev/hda1
fdisk

• The fdisk tool is the traditional Linux partition editing tool.it is a text-
mode application.

• fdisk stands (for “fixed disk or format disk“) is the most commonly used
command-line based disk manipulation utility for a Linux/Unix system.
With the help of the fdisk command, you can view, create, resize, delete,
change, copy and move partitions on a hard drive using its own user-
friendly text-based menu-driven interface.
• This tool is very useful in terms of creating space for new partitions, organizing space
for new drives, re-organizing old drives, and copying or moving data to new disks. It
allows you to create a maximum of four new primary partitions and a number of logical
(extended) partitions, based on the size of the hard disk you have in your system.

• Enter the following command to use fdisk

• Sudo fdisk /dev/hdb

• Where /dev/hdb is the device name of the hard drive you want to manage.
• You can use the fdisk –l command to view a list of drives and
partitions on your compute, as shown below
GPARTED

• The GNOME partition Editor (GParted)is a graphical partition editor. With it, you
can perform all of the same actions you could with fdisk. Many users find Gparted
easier to use. Instead of entering commands, you select from the menu, click buttons
and fill the dialog boxes.

• Gparted is included with many Linux distributions. You can download it from
http://gparted.sourceforge.net you can download a live CD version which you can
put on a CD OR USB drive and then boot from. Doing so enables you to use Gparted
to modify disks used by operating systems such as windows.
FORMATTING A DISK
• While Gparted formats a new partition for you automatically, at the command line you
must perform this step yourself. Once you create a partition with fdisk you must make the
file system with mkfs.

• Mkfs

• The mkfs (make file system) command creates file systems, in other words, it formats your
partition. In general, you use the command like this

• Mkfs –t filesystem_type /dev/hdx

• You must run mkfs as root or via sudo


Switch from home directory to root directory Sudo su
Press fdisk -l To list the partition
Press fdisk /dev/sda To manage your hard drive with fdisk
Follow the command options
Enter m To get a list of fdisk commands

Enter l To view the list of supported partition type

Enter n To begin creating a new partition. You will create a


partition that uses about half the space on the drive

Enter p To create a primary partition

Enter w To write your changes and quit

Enter sudo fdisk -l To view the list of partition again. This time your
second drive has a valid partition
Fsck and e2fsck

Linux offers various commands for checking and repairing file systems which
are necessary steps after formatting a new partition. The traditional fsck (file
system check) command checks most file system types including ext2, and ext3.
it works as a front end to file system-specific checking program.

Use the following command to check and repair a specific file system
automatically.

Fsck –a /dev/hdx
• Creating disk partitions enables you to split your hard drive into
multiple sections that act independently.

• In Linux, users must structure storage devices (USB and hard drives)
before using them. Partitioning is also useful when you are installing
multiple operating systems on a single machine.

• In this step-by-step tutorial, you will learn how to create a partition


using the Linux parted or fdisk command.
View all Disk Partitions in Linux The following basic command list all existing disk
partition on your system. The ‘-l‘ argument stand for
(listing all partitions) is used with fdisk command to
view all available partitions on Linux. The partitions are
displayed by their device’s names. For example:
/dev/sda, /dev/sdb or /dev/sdc.
View Specific Disk Partition in Linux To view all partitions of specific hard disk use the
option ‘-l‘ with device name. For example, the
following command will display all disk partitions of
device /dev/sda. If you’ve different device names,
simple write device name as /dev/sdb or /dev/sdc.
Check all Available fdisk Commands If you would like to view all commands which are
available for fdisk. Simply use the following command
by mentioning the hard disk name such as /dev/sda as
shown below.
fdisk /dev/sda
Print all Partition Table in Linux To print all partition table of hard disk, you must be on
command mode of specific hard disk say /dev/sda.

[root@tecmint ~]# fdisk /dev/sda


How to Delete a Partition in Linux If you would like to delete a specific partition (i.e
/dev/sda9) from the specific hard disk such as
/dev/sda. You must be in fdisk command mode to do
this.

fdisk /dev/sda

Next, enter ‘d‘ to delete any given partition name from


the system. As I enter ‘d‘, it will prompt me to enter
partition number that I want to delete from /dev/sda
hard disk. Suppose I enter number ‘4‘ here, then it will
delete partition number ‘4‘ (i.e. /dev/sda4) disk and
shows free space in partition table. Enter ‘w‘ to write
table to disk and exit after making new alterations to
partition table. The new changes would only take
place after next reboot of system. This can be easily
understood from the below output.

You might also like