D
D
Drno2021-11-25 10:12:45
linux
Drno, 2021-11-25 10:12:45

Why is the partition size not shrinking?

Good afternoon)
It is necessary to reduce the system partition when restarting the PC. I used this instruction (option 2), the script worked
https://newbedev.com/is-it-possible-to-on-line-shr...

df -h shows a smaller size
But when opening cfdisk /dev/sda to create a 2nd partition on free space, it shows that /dev/sda1 size has not changed
File system - etx4
What I want to get:
There is /dev/sda1 - size 15GB occupied space 6GB
I want to reduce it to 8GB, create /dev/sda2 on free space to all the remaining space

A piece from a script that changes size when the PC boots up. What to add here to fulfill my Wishlist)
# simple device example
/sbin/e2fsck -yf /dev/sda1
/sbin/resize2fs /dev/sda1 8G # see size info below
/sbin/e2fsck -yf /dev/sda1

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Melkij, 2021-11-25
@melkij

This may come as a surprise, but it is absolutely true, the size of the file system does not have to match the size of the partition.
resize2fs only resizes the file system. After that, you need to resize the partition. parted knows the resizepart command. Don't know about cfdisk.
At the same time, when reducing the partition, be extremely careful. Like many things as root, the system will allow you to make the partition smaller than the file system. With fatal consequences for the file system.
It's a good idea to first truncate the filesystem size more than expected (up to 7.5GB, for example), shrink the partition, then resize2fs again without explicitly specifying the size, which will increase the size of the FS to the size of the partition. So there will be a much lower risk that they made a mistake somewhere (for example, in units of kilobytes or kibibytes) and cut off part of the file system

A
Alexander, 2021-11-25
@Adler_lug

And what is the file system on the partitions?

D
Dmitry Shitskov, 2021-11-25
@Zarom

Google ban is the scourge of modernity
https://losst.ru/kak-izmenit-razmer-ext4#%D0%A8%D0...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question