JustToThePoint English Website Version
JustToThePoint en español

Maximize your online presence with our exclusive offer: Get a stunning hero banner, the hero you need and deserve, at an unbeatable price! Bew, 689282782, bupparchard@gmail.com

How to create, format, and manage partitions

Disk management tools are utility software that is used to manage data on disk by performing various functions on it, such as partitioning devices, manage drives, disk checking, disk formatting, etc. Image

Partition managers

Partition management software programs let you create, delete, shrink, expand, split, or merge partitions on your hard drives or other storage devices.

Create and format new partitions

  1. First, you need to download a copy of GParted. Launch your favorite browser, go to the donwload section and download it.
  2. Create a bootable GParted USB flash drive with Rufus or Ventoy.
  3. Now you need to reboot your system, go into boot selection mode (F12), and select your GParted USB flash drive.
  4. Select the GParted Live (Default settings) option and just press Enter.
  5. Select the Don’t touch keymap option and press Enter. Then, you need to select your language, too. Next, use the drop-down menu in the top-right corner to select the storage device or drive that you want to work with (e.g., /dev/sdb).
  6. If you are partitioning a new drive, before starting to create partitions, you need to create a partition table, so click on Device, Create Partition Table on the Menu bar, and select your desired partition table type, it will likely be gpt (it is an enhancement of MBR. This is because MBR can only support a partition size of less than 2 TB).
  7. To create a new partition, click on Partition, New on the Menu bar or the New button on the toolbar in the top-left corner. GParted, Create new partitions 
  8. A new window should appear. Change the File system combo box to NTFS (Windows), FAT32 (USB flash drives) or ext4 (GNU/Linux). Type a name for the drive on the Label input box, e.g., main. Click the Add and the Apply✔️ (it commits all changes) buttons. Are you sure you want to apply the pending operations? Apply.

    You can move the slider back and forth to change the size of the partition or type it directly in the New size (MiB) textbox.

    GParted, Create new partitions 
  9. Once it’s done, just click on the Close button and your new partition has already been created.

Resizing partitions

  1. In order to shrink a partition, make a right-click on the desired partition first. Then, click on Resize/Move. Image 
  2. Move the slider to the left to shrink the partition or just type its size directly on the New size (MiB) textbox. GParted, Resizing partitions
  3. Finally, click on the Resize/Move, and the Apply✔️ (it confirms the operation) buttons. As you can see in the screenshot below, the partition has been resized. Image

Deleting and merging partitions

  1. To delete a partition (e.g., /dev/sdb2), make a right-click on the partition first, then click on Delete. As always, you have to save or commit the changes and confirm your choice by clicking on the Apply✔️ button. Image
  2. To merge two partitions, you have to delete the second partition (and lose all its data, so you should back it up) as we have shown in the previous step. Next, you right-click the first partition (e.g., /dev/sdb1) and select Resize/Move.
  3. Now, you can drag the slider to the right and add all the unallocated space left behind when deleting the second partition. Finally, click on the Resize/Move button, and commit the operation by clicking on the Apply✔️ button.

To manually create and format new partitions in GNU/Linux, read our article Programming in Linux. Installing Arch from Scratch 

Add an external disk (/dev/sdb1) formatted in ext4 (GNU/Linux)

  1. sudo chown -R $USER:$USER /mnt/discoExterno.
  2. sudo vi /etc/fstab: /dev/sdb1 (it describes the file system) /mnt/discoExterno (it describes the mount point) ext4 (the file system type) defaults 0 0. C)
  3. systemctl daemon-reload -It automatically reloads systemd configuration on config files changes.
❯ lsblk -f # Output info about file systems
NAME        FSTYPE FSVER LABEL   UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda
└─sda1      ext4   1.0   mydisk1 bd753b26-a4ec-4063-8d36-5215c358ed00  692.3G    70% /media/mydisk1
sdb
└─sdb1      ext4   1.0   mydisk2 cb8ee0c2-6afe-4853-ae39-0cc1dce73ef0    1.1T    33% /media/mydisk2
sdc
├─sdc1      exfat  1.0   Ventoy  B941-1CAD
└─sdc2      vfat   FAT16 VTOYEFI 1B11-976A
nvme0n1
├─nvme0n1p1 vfat   FAT12         29E2-81C1                               702K    30% /boot/efi
├─nvme0n1p2 ext4   1.0           c5e135cd-f8b9-4226-a08c-0a0df899d656   17.4G    36% /
├─nvme0n1p3 swap   1             f581d4da-70e2-4894-8a47-d0d4f3c37e94                [SWAP]
└─nvme0n1p4 ext4   1.0           cf630845-b11e-4ef1-8a94-5771185aef30   99.3G    46% /home
# Static information about the filesystems.
# /dev/nvme0n1p2
UUID=c5e135cd-f8b9-4226-a08c-0a0df899d656	/         	ext4      	rw,relatime	0 1

# /dev/nvme0n1p1
UUID=29E2-81C1      	/boot/efi 	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2

# /dev/nvme0n1p4
UUID=cf630845-b11e-4ef1-8a94-5771185aef30	/home     	ext4      	rw,relatime	0 2

# /dev/nvme0n1p3
UUID=f581d4da-70e2-4894-8a47-d0d4f3c37e94	none      	swap      	defaults  	0 0

sd is a mass storage driver, sda is the first registered device on the driver and sdb is the second. Finally sda1 is a block device file that corresponds to the first drive partition on the first registered device.

# /dev/disk/by-uuid/bd753b26-a4ec-4063-8d36-5215c358ed00 or /dev/sda1. 
/dev/disk/by-uuid/cb8ee0c2-6afe-4853-ae39-0cc1dce73ef0 /media/mydisk2 auto nosuid,nodev,nofail,x-gvfs-show 0 0
/dev/disk/by-uuid/bd753b26-a4ec-4063-8d36-5215c358ed00 /media/mydisk1 auto nosuid,nodev,nofail,x-gvfs-show 0 0

Partitioning and Formatting with sgdisk

Safety isn’t expensive, it’s priceless.

Partitioning is difficult and inherently dangerous. Please backup your data before this operation.

This is how you partition and format your hard drive to install Arch from Scratch.

sgdisk is a command-line utility for manipulating partition tables under Linux. Let’s start by partitioning our Virtual Machine’s drive (/dev/sda1):

user@pc:~$ sgdisk --za-all /dev/sda # Wipe out the partition table (it deletes all GPT and MBR entries and creates a new GPT -GUID Partition Table-) and any data on it! 
sgdisk -og /dev/sda # It creates a fresh GPT disk. 
sgdisk -n 1:2048:+1M -c 1:"BIOS Boot Partition" -t 1:ef02 /dev/sda # Create four partitions.
sgdisk -n 2:0:+40G -c 2:"Linux /" -t 2:8304 /dev/sda
sgdisk -n 3:0:+2G -c 3:"[SWAP]" -t 3:8200 /dev/sda
sgdisk -n 4:0:0 -c 4:"Linux /home" -t 4:8302 /dev/sda
mkfs.vfat /dev/nvme0n1p1 # Format the partitions.
mkfs.vfat /dev/sda1
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda4
mkswap /dev/sda3 # It sets up a Linux swap on the third partition.
swapon /dev/sda3 # It enables it for swapping.

Let’s work in our main machine (In GNU/Linux, the first NVMe-SSD is called /dev/nvme0n1) with a bash script.

#!/bin/bash
# The order lsblk lists all block-level devices available on your system.
disk=/dev/nvme0n1

# Wipe out the partition table (it deletes all GPT and MBR entries and creates a new GPT -GUID Partition Table-) and any data on it! 
sgdisk --zap-all $disk

# Partition the drive:
sgdisk -og $disk # Convert an MBR (Master Boot Record) or BSD disklabel disk to a GPT disk. 

We are creating four partitions: sgdisk -n,

  1. –new partition_number:starting sector:ending sector
  2. -c change the name of the partition, e.g., from 1 to BIOS Boot Partition
  3. -type code, e.g., ef02 is “BIOS boot partition”, 8304 is “Linux x86-64 root”, 8200 is “Linux swap”, and 8302 is Linux (/home)
  4. device file name ($disk)

It creates the following partitions: /boot/ -1M-, / (root) -30G-, swap -2G-, and /home -the remaining disk space.

sgdisk -n 1:2048:+1M    -c 1:"BIOS Boot Partition"  -t 1:ef02 $disk  
sgdisk -n 2:0:+30G      -c 2:"Linux /"              -t 2:8304 $disk  
sgdisk -n 3:0:+2G       -c 3:"[SWAP]"               -t 3:8200 $disk  
sgdisk -n 4:0:0         -c 4:"Linux /home"          -t 4:8302 $disk 

# Format the partitions. mkfs stands for “make file system.” 
mkfs.vfat /dev/nvme0n1p1
mkfs.ext4 /dev/nvme0n1p2
mkfs.ext4 /dev/nvme0n1p4
# mkswap sets up a Linux swap area on the third partition of our disk. 
mkswap  /dev/nvme0n1p3
# swapon enables it for swapping.
swapon  /dev/nvme0n1p3
Bitcoin donation

JustToThePoint Copyright © 2011 - 2024 Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun. Social Issues, Join us.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.