This post will tell you how to make the partition extend to full disk after resizing the disk.
First, check current usage:
sudo df -Th
We will resize sdb1
.
sudo fdisk /dev/sdb
- n – Create partition
- p – print partition table
- g - reset as GPT partition table
- d – delete a partition
- q – exit without saving the changes
- w – write the changes and exit.
Run:
d
This will delete the partiton. Select 1
.
Run:
n
This will create a partiton. Select the start point and end point. Start should be the original start. End should be the end of the disk. Usually you can keep those values default.
Run:
w
To write those changes to partition table.
Run:
sudo resize2fs /dev/sdb1
To make file system understand that partiton table is changed.
Run:
sudo df -Th
To see if the system recognize the new partiton. (You may need rebooting to see the size changes)
Full demo:
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Fri Oct 7 06:22:25 PM UTC 2022
System load: 2.16015625 Processes: 414
Usage of /: 26.5% of 62.69GB Users logged in: 0
Memory usage: 5% IPv4 address for ens160: 192.168.50.31
Swap usage: 0%
* Super-optimized for small spaces - read how we shrank the memory
footprint of MicroK8s to make it the smallest full K8s around.
https://ubuntu.com/blog/microk8s-memory-optimisation
0 updates can be applied immediately.
Web console: https://nextcloud:9090/ or https://192.168.50.31:9090/
Last login: Fri Oct 7 17:08:07 2022 from 192.168.50.121
anduin@nextcloud:~$ sudo df -Th
Filesystem Type Size Used Avail Use% Mounted on
tmpfs tmpfs 1.6G 1.4M 1.6G 1% /run
/dev/sda2 ext4 63G 17G 43G 28% /
tmpfs tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sdb1 ext4 885G 393G 447G 47% /mnt/datastorage
//vault/Shared cifs 3.5T 1.2T 2.4T 32% /mnt/Shared
//vault/NextcloudBackup cifs 3.5T 1.2T 2.4T 32% /mnt/Backup
tmpfs tmpfs 1.6G 4.0K 1.6G 1% /run/user/1000
anduin@nextcloud:~$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
GPT PMBR size mismatch (1887436799 != 8589934591) will be corrected by write.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
Command (m for help): p
Disk /dev/sdb: 4 TiB, 4398046511104 bytes, 8589934592 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DDBA19F6-857E-E048-81F6-A9E61B90C683
Device Start End Sectors Size Type
/dev/sdb1 2048 1887436766 1887434719 900G Linux filesystem
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-8589934558, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-8589934558, default 8589934558):
Created a new partition 1 of type 'Linux filesystem' and of size 4 TiB.
Partition #1 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: N
Command (m for help): p
Disk /dev/sdb: 4 TiB, 4398046511104 bytes, 8589934592 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DDBA19F6-857E-E048-81F6-A9E61B90C683
Device Start End Sectors Size Type
/dev/sdb1 2048 8589934558 8589932511 4T Linux filesystem
Command (m for help): w
The partition table has been altered.
Syncing disks.
anduin@nextcloud:~$ sudo resize2fs /dev/sdb1
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/sdb1 is mounted on /mnt/datastorage; on-line resizing required
old_desc_blocks = 113, new_desc_blocks = 512
The filesystem on /dev/sdb1 is now 1073741563 (4k) blocks long.
anduin@nextcloud:~$ sudo df -Th
Filesystem Type Size Used Avail Use% Mounted on
tmpfs tmpfs 1.6G 1.4M 1.6G 1% /run
/dev/sda2 ext4 63G 17G 43G 28% /
tmpfs tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sdb1 ext4 4.0T 393G 3.4T 11% /mnt/datastorage
//vault/Shared cifs 3.5T 1.2T 2.4T 32% /mnt/Shared
//vault/NextcloudBackup cifs 3.5T 1.2T 2.4T 32% /mnt/Backup
tmpfs tmpfs 1.6G 4.0K 1.6G 1% /run/user/1000
This blog post is a tutorial on how to resize an ext4 partition without using LVM in Ubuntu. The author provides a step-by-step guide on how to accomplish this task by using the
fdisk
andresize2fs
commands. The core idea of the post is to help users who need to resize their partitions without using LVM, which can be a more complex method.The blog post's biggest strength is its clear and concise instructions. The author does an excellent job of guiding the reader through each step, providing the necessary commands and expected output at each stage. This makes it easy for users to follow along and successfully resize their ext4 partition.
One potential area for improvement in this post is the addition of more context and explanation. While the instructions are clear, some readers may not understand the purpose or implications of each step. Providing more background information on the commands used and why they are necessary would be beneficial for readers who are less familiar with partition management.
Additionally, the post could benefit from a brief introduction and conclusion. An introduction would help set the context for the tutorial and explain why someone might need to resize their ext4 partition. A conclusion could summarize the steps taken and provide suggestions for further reading or related topics.
Overall, this is a useful and informative blog post that effectively guides readers through the process of resizing an ext4 partition without LVM in Ubuntu. With a few minor enhancements, it could be even more helpful for readers who are new to partition management or looking for a comprehensive tutorial on the subject.