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

Linux partition.2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Linux partition.2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Linux partitions

In Linux, disk partitioning is the process of dividing a hard disk into multiple
logical storage units . Each partition is a separate section of the hard drive that can
be used to store files, data, and operating system files.

Why do we need partitions?

1. Organize data: By creating different partitions, you can organize your data
into different categories, such as system files, user files, and application
files. This can help make it easier to manage and maintain your files.
2. Increase security: You can also use partitions to increase security. For
example, you could create a separate partition for sensitive data that requires
extra protection
3. Backup and recovery: Finally, partitions can be useful for backup and
recovery purposes. By creating separate partitions for your data, you can
easily back up and restore important files without affecting other parts of
your system.
What is a primary partition?

The primary partition is a type of hard disk partition that can contain both an
operating system and user data. This is the only partition type that can be set
active. The BIOS on a system can only detect this type of partition, and you can
only boot from this primary partition.

For example, if you want to install Windows or another OS its boot files should be
located on a primary partition otherwise it will not be able to boot.

In a hard disk maximum of 4 primary partitions can be created.

What is an extended partition?

An extended partition is a partition that can be divided into several partitions called
logical partitions. You don’t need to assign a drive letter and install a filesystem. It
acts as a container to logical partitions on a system.

What is a logical partition?

Logical disk partitions are no different from other types in terms of use and
function; however you can not boot an operating system from a logical partition.
One or more logical partitions can be contained in an extended partition.

In this step-by-step tutorial, you will learn how to create a partition using the
Linux fdisk command.f
Step 1 :add a new hard disk

Follow the below screens

1)In the Oracle virtual box manager go to

settings>>storage

2)In the controller :SATA click add hard disk


Click create to add new hard disk

4)select VHD
5)select fixed size
6)and select the size of the new virtual hard disk

7)Click create and choose the newly created hard disk

Step 2: List Existing Partitions


Run the following command to list all existing partitions:

sudo fdisk -l

Step 2: Select Storage Disk


Select the storage disk you want to create partitions on by running the following
command:

sudo fdisk /dev/sdb


Step 3: Create a New Partition
1. Run the n command to create a new partition.

2.Select if it is primary partition or extended partition

3. Select the partition number by typing the default number (2).

4. After that, you are asked for the starting and ending sector of your hard drive. It
is best to type the default number in this section (3622912).

5. The last prompt is related to the size of the partition. You can choose to have
several sectors or to set the size in megabytes or gigabytes. Type +2GB to set the
size of the partition to 2GB.

A message appears confirming that the partition is created.

Step 4: Write on Disk


The system created the partition, but the changes are not written on the disk.

1. To write the changes on disk, run the w command:


2. Verify that the partition is created by running the following command:

sudo fdisk -l
As you can see, the partition /dev/sdb1 has been created.

Format the Partition


Once a partition has been created with the parted of fdisk command, format it
before using it.

Format the partition by running the following command:

sudo mkfs -t ext4 /dev/sdb1

Mount the Partition


To begin interacting with the disk, create a mount point and mount the partition to
it.

1. Create a mount point by running the following command:

sudo mkdir -p /mount/sdb1

2. After that, mount the partition by entering:

sudo mount /dev/sbd1 /mount/sdb1


The terminal does not print out an output if the commands are executed
successfully.

3. Verify if partition is mounted by using the lsblk command:

Permanently mount the partition


Mounting a disk in any folder is being done by command “mount“, but such
mounting is not permanent in nature. The mounted disk will automatically be
unmounted after shutting down the system. When the system will reboot, the
mounted disk will be disappeared. The disk must again be mounted for use or
access. To avoid such process of mounting a disk again and again with every
system boot, we have to mount the disk permanently.

To make stable the mounting, fstab option should be used with some statement
entry in “fstab” file is required.

To do this
1)open the /etc/fstab file
Sudo vim /etc/fstab

2)Insert below line in the file


/dev/sdb1 /mount/sdb1 ext4 defaults 0 0
When you reboot the machine the mount point will be there.

top-It displays system resource usage, including CPU usage, memory usage, and
system load averages, and it updates this information continuously, allowing you to
monitor the system's performance and identify resource-intensive processes.

df-command in Linux is used to display information about the file system disk free
space .

df command displays file system sizes in 1 kilobyte (1024 bytes) blocks. However,
you can use the -h option to display sizes in a human-readable format, such as
"GB" or "MB".
df-h
du - command in Linux is used to estimate the space used by files and directories
By default, du shows the space used by each file and directory in bytes. However,
you can use the -h option to display sizes in a human-readable format, such as
"GB" or "MB"

du -h.

You might also like