You are not logged in.
Hi,
My root was quite big at 931gb. I used a live media to resize the root to 40GB. Prior to that I had run fsck on the device and it everything went well.
After I rebooted to my distro, df -h correctly reports the new reduced size:
[root@aura-arch]: /home/aj># df -h
Filesystem Size Used Avail Use% Mounted on
dev 3.9G 0 3.9G 0% /dev
run 3.9G 884K 3.9G 1% /run
/dev/sda2 40G 3.9G 34G 11% /
tmpfs 3.9G 30M 3.9G 1% /dev/shm
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 3.9G 180K 3.9G 1% /tmp
/dev/sda1 510M 43M 468M 9% /boot
tmpfs 793M 12K 793M 1% /run/user/1000
But fdisk says:
[root@aura-arch]: /home/aj># fdisk -l
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 54E9E5FE-2CC2-4738-9F08-B1E764B23AC1
Device Start End Sectors Size Type
/dev/sda1 2048 1048576 1046529 511M EFI System
/dev/sda2 1050624 1953525134 1952474511 931G Linux filesystem
How can I fix this ?
Offline
I don't know which partition editor you use (fdisk? cfdisk? cgdisk?), but to resize the partition, you'll need to delete it, and then recreate it with the right size (note that some (grahical) partition editors might also provide an option "resize", which really just deletes and recreates the partition).
I'd suggest making the partition slightly larger than your filesystem (maybe 1 GB? just to be on the safe side). You can then grow the file system to fill up the partition.
Offline
Partitions and filesystems are different things. If you used resize2fs to shrink the filesystem, you also have to use parted resizepart to shrink the partition afterwards. Or when growing, you first have to grow the partition, then grow the filesystem. It's always 2 steps (perhaps more than 2 steps if you use additional storage layers like RAID, LUKS, LVM, ...).
You have to be very careful when shrinking partitions... if you make it smaller than the filesystem, it will break. If you used resize2fs 40G then the partition must be at least exactly 40G (GiB not GB) in size. If you used a different size then it must be different.
In parted this would be something like, for example: resizepart 2 84936703s. This way sda2 should be 40GiB in size sharp ( start 1050624s + (40[GiB]*1024[MiB]*1024[KiB]*1024[Byte]/512[Sector])s ). The size in sectors shown should be 83886080. Use 'unit s', 'print free' to verify.
Note this is just an example, you have to do your own math.
Offline
Partitions and filesystems are different things. If you used resize2fs to shrink the filesystem, you also have to use parted resizepart to shrink the partition afterwards. Or when growing, you first have to grow the partition, then grow the filesystem. It's always 2 steps (perhaps more than 2 steps if you use additional storage layers like RAID, LUKS, LVM, ...).
You have to be very careful when shrinking partitions... if you make it smaller than the filesystem, it will break. If you used resize2fs 40G then the partition must be at least exactly 40G (GiB not GB) in size. If you used a different size then it must be different.
In parted this would be something like, for example: resizepart 2 84936703s. This way sda2 should be 40GiB in size sharp ( start 1050624s + (40[GiB]*1024[MiB]*1024[KiB]*1024[Byte]/512[Sector])s ). The size in sectors shown should be 83886080. Use 'unit s', 'print free' to verify.
Note this is just an example, you have to do your own math.
Ah the hypothetical bulb on top of my head just lit
I used resize2fs like you speculated, thanks a bunch!
Offline