Debian

Partitioning hard disks under Debian/Ubuntu and resizing partitions

Partitioning hard disks under Debian/Ubuntu and resizing partitions
A proper server installation requires a proper partitioning, in contrast with a workstation in which we usually install everything under the root partition (/). When we plan a server installation we estimate the size for different aspects of the server, dividing it for backup, security or technical purposes, we can determine a partition as ext4 or reiserfs according to the filesystem we need or limit the size. In this tutorial we will divide our hard disk both in graphical and command modes and we'll resize different partitions.

Partitioning under Debian/Ubuntu (GUI)

To start we'll install Gparted by running the following command:

apt install gparted -y

Run Gparted

gparted

Gparted GUI is very intuitive and easy to use. First select the device you want to work on, on the right side you'll see a dropdown menu saying “/dev/sda (238.47 GiB)”, there you can select a different device. If you plug the device after Gparted was launched, on the top menu click deploy GParted and click on “Refresh Devices”.

We can not manipulate partitions of a hard disk being used so I connected an external hard drive.

Right click on the partition you want to resize and select Resize.

In my case I have not too free space, so I will only reduce the partition 2 GB.

Now we have 1,95 GB unused, to expand the partition instead of reducing the process is the same if we have free space, right click on the partition you want to expand, select Resize and determine the space you want to add.

Optionally we can format the unused space and create a new partition with a different filesystem like NTFS.

Right click on the unused space and select New

Select the size and type of filesystem, in this case also determine if you want your partition to be primary.

Once we finished setting our changes click on the green V icon below the main menu to write or save all changes.

Partitioning with fdisk

Lets run fdisk to see the options it has.

Lets see the partitions of the disk sdb by running

fdisk /dev/sdb

And then press p, if you need help during the process you can always press m to get help.

Press d to remove the existing partition

Press n to create a new partition and select the table.

Select if the partition must be primary, number of partitions, starting and end point,

To write changes press w.

 

Brief comment on cfdisk

cfdisk  is a tool coming by default with Debian and Ubuntu to manage partitions with the terminal. It is a lot more friendly than fdisk. It is not useful to resize partitions keeping their content, we can remove and create new partitions assigning the size we want.

To launch cfdisk run the command and the device you want to work on.

cfdisk /dev/sdb

cfdisk is managed with the keyboard. If you have more than one partition use down-up keys to select different partitions and keys right-left to select between the different actions.

Conclusion

The best way seems to be gparted with if you have X installed and internet connection. Cfdisk and Fdisk are available tools in default installations, that's why it is important to know how to use them for an emergency without internet.

I hope you found this article useful. Keep following LinuxHint for new tips on Linux.

Control & manage mouse movement between multiple monitors in Windows 10
Dual Display Mouse Manager lets you control & configure mouse movement between multiple monitors, by slowing down its movements near the border. Windo...
WinMouse lets you customize & improve mouse pointer movement on Windows PC
If you want to improve the default functions of your mouse pointer use freeware WinMouse. It adds more features to help you get the most out of your h...
Mouse left-click button not working on Windows 10
If you are using a dedicated mouse with your laptop, or desktop computer but the mouse left-click button is not working on Windows 10/8/7 for some rea...