Partition your hard drives on Debian with fdisk

HDD

One of the essential tools to work by commands in Linux it's the fdisk program, a powerful program that will allow you to touch everything related to your hard drives, creating partitions, deleting them and verifying them.

Fdisk it comes installed by default on the Debian operating system and in many more distributions. Today we are going to teach you everything you need to know to partition your hard drives with fdisk.

The first step we must take is to see the partitions that we have available. For this we are going to use these two commands, the first to have root user access and the second to connect to the fdisk program and show us the list of disks we have.

su
fdisk -l

Once we have done this, We will get a list of partitions with their respective details, that is, its size, its name and the name of the hard disk where the partition is located (sda, sdb ...).

Once we have done this, we can now connect to the hard drive that we want to modify. We will do this with the fdisk command, followed by the path where our hard drive is, leaving something similar to this if we want to connect to sda.

fdisk /dev/sda

Now that we are inside fdisk, it is the turn to play with the options that we have available. The first thing we will do is to introduce this command to show us the help of all available options.

m

Now we are going to introduce this command to see the partition table of the disk.

debian-fdisk

p

And this one to create a new partition

n

From here it is all very intuitive, since we just have to follow the instructions that come out. We can choose between primary and extended partition, choose the size of the partition (in kilobytes, megabytes or gigabytes) or the beginning and end sector of the same.

debian-fdisk-2

For the changes to be saved, we must write this command, so that we exit the program with the changes recorded, since otherwise it will not recognize it.

w

If we look closely, it has created the partition for us, but we have not formatted it yet. To be able to do this, we will need the mkfs command to format and the mount command to mount it in the archive file and make it functional.

mkfs.ext4 /dev/sda3

Once it's formatted, it's time to mount the partition to work with the mount command, which is very simple syntax. This is an example of the command to mount the partition in the / home / user / disk3 folder, in which I also explain how to create the directory by command line.

mkdir /home/user/disco3
mount /dev/sda3 /home/user/disco3

And that's it We can enter our hard drive by accessing the disk 3 folder on our computer, as it appears below.

Fdisk

As well we have the option to mount the disk directly in / dev / sda3However, on too large hard drives you will get an error and you will not be able to do it correctly.


Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.