How to handle different hard drive sizes returned by the fdisk and df commands?

Event Description

Recently, the external hard drive on my Lightsail VPS reached its limit. I created a larger hard drive using a snapshot backup and connected it to the VPS, but it still shows as full. Checking the hard drive size using the commands `fdisk -l` and `df -Th` yielded different values: one for the new hard drive and the other for the original hard drive, both showing as full.

analyze

The reason is likely that the new hard drive was created using a snapshot, which contained information about the old hard drive partitions. Therefore, only the old part was used, and the remaining space was not used, requiring partitioning.

In simple terms, when you get a new hard drive, it is formatted in the same way as before. So only the original part is formatted, and the remaining part is a blank space that is not used or recognized. You can create a new hard drive in this space, such as drive D, or you can expand the original partition to use all the space.

Solution

Note: My mount point is /dev/sda3. Please modify it according to your own situation. The following operations will not corrupt your data, but it is recommended to back up your data before proceeding.

umount /dev/sda3 fsck -n /dev/sda3 //检查硬盘,输出应该是:/dev/sda3: clean, > tune2fs -O ^has_journal /dev/sda3 //删除journal e2fsck -f /dev/sda3 resize2fs /dev/sda3 //重新partition fsck -n /dev/sda3 //检查是否已经扩容 tune2fs -j /dev/sda3 // 加上journal reboot or mount /dev/sda3

This siteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)Please retain the following annotations when sharing or adapting:

Original author:Jake Tao,source:How to handle situations where the fdisk and df commands return different hard drive sizes?

672
0 0 672

Further Reading

Post a reply

Log inYou can only comment after that.
Share this page
Back to top