Linux Partitions
A guide for how to show, create and resize partitions
Create Partition [^1]
This tutorial is copied from the tutorial from Satish Tiwary slashroot.in. Don't give me any credit.
We will use the program fdisk
for the following steps.
Show Partitions
This following command will show all partition and the disk (with information about the size).
Create new partition
Select the disk you want to use, here we are using /dev/sda
Then hit
n
for creating a new partition.Select the partition number (just hit enter for the default)
Select the first sector, just hit enter
Then select the last sector. Here you can set the size of the partition. We are going to
+100G
which is 100 Gigabyte.Then use insert
w
to write the changes, save them and exit
Use partprobe to update the changes of the partition table without restart.
Adding a file system for the partition
We will create the file system ext4
for the partition /dev/sda5
Mount the partition to a directory
Create a new partition
Mount the parition (/dev/sda5
) to the new directory.
To check if it's mounted you can use df -h
Make the file system permanent
Append to the file /etc/fstab
Resize Partitions [^2]
This tutorial is copied from the tutorial from Søren Løvborg askubuntu.com. Don't give me any credit.
This is only to enlarge the parition, shrinking won't work
Delete the to resized partition
We first delete the partition you want to resize.
We select the device, where the partition is located, in this example it is /dev/sda
.
Please copy the sector information about the parition. Then you can start the new created parition where the deleted one started. This means no data will be lost.
Type
p
to show the partitionsType
d
to delete a partitionSelect the partition number you want to resize (for example the last one)
Then we are going to create the partition again
Type
n
to create a new partitionType select the partition number (for us we just hit enter)
Select the first sector (hit enter for default)
Select the last sector (here you can increase or decrease the partition)
remove the ext signature
Type
w
to save the changes
Use partprobe to update the changes
Resize the file system
Resize the file system, for this example we use the resized partition /dev/sda3
List of resources
[^1]: slashroot.in - Satish Tiwary - https://www.slashroot.in/how-create-new-partition-linux-0
Last updated
Was this helpful?