0% found this document useful (0 votes)
29 views

Manual of The Experiment1.2 Linux

This document provides instructions on adding disks, partitions, and file systems to a Linux system using both command line tools and graphical user interfaces. It discusses using fdisk to view, create, resize, and delete partitions from the command line. It also covers using mkfs to format partitions, mount to access file systems, and umount to unmount partitions. GParted is introduced as a graphical tool for resizing, moving, and deleting partitions without data loss. The document concludes with instructions for managing swap spaces by creating and enabling swap files.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Manual of The Experiment1.2 Linux

This document provides instructions on adding disks, partitions, and file systems to a Linux system using both command line tools and graphical user interfaces. It discusses using fdisk to view, create, resize, and delete partitions from the command line. It also covers using mkfs to format partitions, mount to access file systems, and umount to unmount partitions. GParted is introduced as a graphical tool for resizing, moving, and deleting partitions without data loss. The document concludes with instructions for managing swap spaces by creating and enabling swap files.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Experiment-2

Manual

In this manual, we are going to learn the procedure for Adding Disks, Partitions, and File Systems to a
Linux System. In which we will learn to create, remove and resize the partitions using commands and
using GUI. So, let’s first discuss the commands that are used to manipulate the partitions in the Linux
Operating System.

a. Create, remove, and resize various types of partitions through command line using
fdisk, gdisk, mkfs, mount.

fdisk: fdisk stands (for “fixed disk or format disk“). With the help of fdisk command you can view,
create, resize, delete, change, copy and move partitions on a hard drive. 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.

1. View all Disk Partitions in Linux:


Syntax: $fdisk –l
Output:

Fig-1 View all partition using fdisk command [1]


2. View Specific Disk Partition in Linux:
Syntax: $fdisk -l /dev/sda
Output:

Fig-2 View specific disk using fdisk [1]


3. Check all Available fdisk Commands:
Syntax: $fdisk /dev/sda
Output:

Fig-3 Viewing all commands of fdisk command [1]


4. Command (m for help): In this list n is a command to create a new partition
Output:

Fig-4 Creating a new parition using n command [1]

After this you can enter the size by adding “+5000M” in last cylinder, where + means addition
and 5000M means 5000MB size of new partition.

5. How to Format a Partition in Linux:


Syntax: $mkfs.ext4 /dev/sda4
Output:

Fig-5 Making a filesystem [1]

6. Mount: Mount is to access a filesystem in Linux. You can mount a filesystem on any directory
and access content by entering to that directory. These directories are called mount points.
Syntax: $ mount [-t fstype] filesystem mountpoint
Output:

Fig-6 Accessing a File system [1]

7. Unmount: Use umount command to unmount any mounted file system on your system. Run
umount command with disk name or mount point name to unmount currently mounted disk.
Syntax: $ umount /dev/sdb

8. fsck: It stands for file system consistency check. This check can be done automatically during
boot time or run manually.
b. Create, remove, and resize various types of partitions through GUI using
Gparted

Gparted: Gparted is a free, cross platform and advanced graphical disk partition manager that
works on Linux operating systems, Mac OS X and Windows. It is used to resize, copy, move, label,
check or delete partitions without data loss, enabling you to grow or shrink root partition, create space
for new operating systems and attempt data rescue from lost partitions.

• After launching gparted tool, the default window that you should see on your screen:

Fig-7 Default Partitions [2]


• Creating Additional Primary

Fig-8 Creating New Partition

Click Add to create a partition.


• Now similar to fdisk changes will not be applied directly to the disk. To write the changes
click on the “Apply All Operations”

Fig-9 Writing Changes [2]

• It will ask you for final confirmation for applying the changes:

Fig-10 Applying Changes [2]

• Finally, Partition is created

Fig-11 Partition Created [2]


b. Swapping: Managing Swap spaces as well as swap files.
Swapping is necessary for two important reasons. First, when the system requires more memory than
is physically available, the kernel swaps out less used pages and gives memory to the current
application (process) that needs the memory immediately. Second, a significant number of the pages
used by an application during its startup phase may only be used for initialization and then never used
again.
• Creating Swap Space: It is used to create a swap file of 2-MB swap file, you can use the
command.
Example: dd if=/dev/zero of=/mnt/swapfile bs=1024 count=2097152

• As a next step, set the appropriate permissions to the file;


Example: chmod 600 /mnt/swapfile
• Format the swap area: You can do it with mkswap command.
Syntax: $mkswap -c device size
Example: mkswap -c /mnt/swapfile

Where device is the name of the swap partition or file, and size is the size of the swap area in
blocks

• Enabling the Swap Space: In order for the new swap space to be utilized, you must enable it
with the swapon command.
Syntax: $swapon /swap
Example: swapon /mnt/swapfile

• Disabling Swap Space: To disable swap space, simply use the command.
Syntax: $ swapoff device

• To verify the creation of a swapspace, -s option with swapon command can be used.
swapon -s

References:
1. https://www.tecmint.com/fdisk-commands-to-manage-linux-disk-partitions/
2. https://devconnected.com/how-to-create-disk-partitions-on-linux/

You might also like