I partitioned the disk but it's not showing in <df -h>

Capella

New Member
Joined
Nov 3, 2023
Messages
3
Reaction score
3
Credits
38
Hello.
I use xubuntu.

Context:

Yesterday I accidentally deleted some files by emptying the trash myself (I did not realize my photos had somehow gone to trash). As I tried to recover them using testdisk, I unmounted the home partition (sda3) and set the home partition to read only mode. I had 3 primary partitions: sda1,2,3; I created another sda4 to keep a copy of sda3 (my home directory) using the <dd> command, as it was recommended in an article I read. But the <dd> command took too long and I continued the process in the background, while using testdisk. Somehow the background process stopped, and then I decided to use photorec, but I ended up "scanning sda3 for the deleted files." , and "putting the recovery files in the same partition, ie. sda3." It said there was not enough space there.

So I tried writing, deleting and rewriting the sda3 and sda4 partition a couple times. Once I had trouble booting as well.

I got errors like "cannot connect to databus in the command line."

But then I rebooted and all my data was intact in sda3. I then deleted sda3 and redefined its the space from around 280 GB to 500 GB.
The thing that has happened is:

partiiondisk.png
dfh.png



As you can see, <df -h> shows my previous partition disk memory (229GB) for sda3 (the partition where my home is present.), but when I use fdisk, it shows that sda3 has a size of around 465GB. I have written the 500 GB size for sda3 multiple times, and synced, but doesn't show in <df -h>. My home partition remains intact.

Can someone suggest to me why this is happening? It would be much appreciated.

And those /dev/ loops that are formed? I read that they are harmless, but what are they and why are there so many?

Sorry it's so long.
 


I can tell you that the /dev/loop are mounts to your snap packages.

I don't quite understand your partitioning, you say you created a 4th, but it doesn't show up anywhere?

So I tried writing, deleting and rewriting the sda3 and sda4 partition a couple times.

Presumably overwritting what was on them - but then you say your /home is intact, in its original partition?
 
A few observations:

It sounds like you didn't lose your data, since you rebooted and found it intact on /dev/sda3.

In relation to the different outputs of df and fdisk, the fdisk command runs as root and will likely provide a more reliable measure of the filesystem size, which can be compared to the output of lsblk, for example:

Code:
[root@min ~]# lsblk -o NAME,MAJ:MIN,RM,RO,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINT,MODE,OWNER,GROUP
NAME        MAJ:MIN RM RO   SIZE TYPE FSTYPE LABEL MOUNTPOIN MODE       OWNER GROUP
sr0          11:0    1  0  1024M rom                         brw-rw---- root  cdrom
nvme0n1     259:0    0  0 465.8G disk                        brw-rw---- root  disk
├─nvme0n1p1 259:1    0  0   476M part vfat         /boot/efi brw-rw---- root  disk
├─nvme0n1p2 259:2    0  0  14.9G part swap         [SWAP]    brw-rw---- root  disk
└─nvme0n1p3 259:3    0  0 450.4G part ext4         /         brw-rw---- root  disk

and fdisk output:
Code:
Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: CT500P3PSSD8                           
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: C9FCE76E-9F30-4E86-99E4-B4BF7923D297

Device            Start       End   Sectors   Size Type
/dev/nvme0n1p1     2048    976895    974848   476M EFI System
/dev/nvme0n1p2   976896  32227327  31250432  14.9G Linux swap
/dev/nvme0n1p3 32227328 976771071 944543744 450.4G Linux filesystem

and df output (as user, not root):
Code:
[tom@min ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.7G     0  7.7G   0% /dev
tmpfs           1.6G  2.1M  1.6G   1% /run
/dev/nvme0n1p3  443G   13G  408G   3% /
tmpfs           7.7G     0  7.7G   0% /dev/shm
tmpfs           5.0M   12K  5.0M   1% /run/lock
efivarfs        192K   99K   89K  53% /sys/firmware/efi/efivars
/dev/nvme0n1p1  476M  5.9M  470M   2% /boot/efi
tmpfs           1.6G  2.5M  1.6G   1% /run/user/1000

There is a slight discrepancy between outputs, with fdisk and lsblk coinciding with each but df underestimating a little (about 7G).

I can't say what has interfered with the df command on your system to underestimate so drastically (236G). It may be a result of the various alterations you made to the partitions.

The loop devices are a consequence of the snaps installed. Snaps use that form of installation for mounting themselves into the filesystem.

In any case, it may be wise to fsck the root and home partitions to mitigate against filesystem corruption, run smartctl to check the health of the hard drive, and do proper backups which involve saving what you want to save onto another medium like another hard drive, or usb or cd/dvd, or tape etc. which is entirely separate from the computer so that if the computer fails, the data is not lost.
 
I can tell you that the /dev/loop are mounts to your snap packages.

I don't quite understand your partitioning, you say you created a 4th, but it doesn't show up anywhere?



Presumably overwritting what was on them - but then you say your /home is intact, in its original partition?
Yes, the home partition is intact even though I had extended it. I deleted the sda4 and used that space to extend sda3 (home partition). There was nothing in sda4 before: just the unused part of my 1 TB hardisk.
Thanks for reading and responding!
 
A few observations:

It sounds like you didn't lose your data, since you rebooted and found it intact on /dev/sda3.

In relation to the different outputs of df and fdisk, the fdisk command runs as root and will likely provide a more reliable measure of the filesystem size, which can be compared to the output of lsblk, for example:

Code:
[root@min ~]# lsblk -o NAME,MAJ:MIN,RM,RO,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINT,MODE,OWNER,GROUP
NAME        MAJ:MIN RM RO   SIZE TYPE FSTYPE LABEL MOUNTPOIN MODE       OWNER GROUP
sr0          11:0    1  0  1024M rom                         brw-rw---- root  cdrom
nvme0n1     259:0    0  0 465.8G disk                        brw-rw---- root  disk
├─nvme0n1p1 259:1    0  0   476M part vfat         /boot/efi brw-rw---- root  disk
├─nvme0n1p2 259:2    0  0  14.9G part swap         [SWAP]    brw-rw---- root  disk
└─nvme0n1p3 259:3    0  0 450.4G part ext4         /         brw-rw---- root  disk

and fdisk output:
Code:
Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: CT500P3PSSD8                          
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: C9FCE76E-9F30-4E86-99E4-B4BF7923D297

Device            Start       End   Sectors   Size Type
/dev/nvme0n1p1     2048    976895    974848   476M EFI System
/dev/nvme0n1p2   976896  32227327  31250432  14.9G Linux swap
/dev/nvme0n1p3 32227328 976771071 944543744 450.4G Linux filesystem

and df output (as user, not root):
Code:
[tom@min ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.7G     0  7.7G   0% /dev
tmpfs           1.6G  2.1M  1.6G   1% /run
/dev/nvme0n1p3  443G   13G  408G   3% /
tmpfs           7.7G     0  7.7G   0% /dev/shm
tmpfs           5.0M   12K  5.0M   1% /run/lock
efivarfs        192K   99K   89K  53% /sys/firmware/efi/efivars
/dev/nvme0n1p1  476M  5.9M  470M   2% /boot/efi
tmpfs           1.6G  2.5M  1.6G   1% /run/user/1000

There is a slight discrepancy between outputs, with fdisk and lsblk coinciding with each but df underestimating a little (about 7G).

I can't say what has interfered with the df command on your system to underestimate so drastically (236G). It may be a result of the various alterations you made to the partitions.

The loop devices are a consequence of the snaps installed. Snaps use that form of installation for mounting themselves into the filesystem.

In any case, it may be wise to fsck the root and home partitions to mitigate against filesystem corruption, run smartctl to check the health of the hard drive, and do proper backups which involve saving what you want to save onto another medium like another hard drive, or usb or cd/dvd, or tape etc. which is entirely separate from the computer so that if the computer fails, the data is not lost.
Yes, the <lsblk> command returns the size of home partition as <fdisk> does. Even with root privileges though the <df> command doesn't show the latest partition size of the home partition. I will use the commands you mentioned to check against corruption. Thanks for taking the time to look at my problem :)
dfhome.png
 

Members online


Top