Partitioning hard disks under Debian/Ubuntu and resizing partitions

29/12/2020
Chưa phân loại
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.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

0 A.D. Alpha 22 Venustas Released – Install 0 AD on Ubuntu 17.04

0 A.D. Alpha 22 Venustas recently released, is the twenty-second alpha version of 0 A.D, a free, open-source real-time strategy...
28/12/2020

Hướng dẫn add host để checkmk giám sát

Sau khi cài đặt xong check_mk thì tất nhiên chúng ta sẽ phải thêm host vào để chúng ta giám sát chúng....
30/12/2020

Hướng dẫn tạo Usb boot Proxmox VE và cài đặt Proxmox VE bằng hình ảnh mới nhất

Proxmox VE (Virtualization Environment) là một nền tảng ảo hóa doanh nghiệp mã nguồn mở. Nó có một...
03/10/2021
Bài Viết

Bài Viết Mới Cập Nhật

Dịch Vụ Xây Dựng Hệ Thống Peering Với Internet Exchange (IXP)
04/04/2025

Dịch Vụ Triển Khai VPN Site-to-Site & Remote Access
04/04/2025

Dịch Vụ Thiết Lập Hệ Thống Tường Lửa (Firewall)
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ảo Hóa & Cloud
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ceph
04/04/2025