1

My computer contains an SSD of 250GB and a HDD of 1 TB. When I run fdisk -l I get the following output for said HDD:

Disk /dev/sda: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST1000LM035-1RK1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

This shows, it has 1 TB of space on it. Yet when I run

df /dev/sda -H
Filesystem      Size  Used Avail Use% Mounted on
udev            8.3G     0  8.3G   0% /dev

it only displays a capacity of 8.3 GB. How do I go about accessing the remaining 990 GB of said HDD? Thank you for the help in advance!

4
  • Strange that the "fdisk -l" doesn't show any partitions against which, when mounted, you could run df. Perhaps you forgot to partition the disk? Commented Apr 6, 2020 at 18:59
  • I believe you're correct. Is partioning the disk neccesary in order to access it? (Very new to Linux, sorry :))
    – user404496
    Commented Apr 6, 2020 at 19:20
  • partitioning is necessary for any operating system, not just linux
    – jsotola
    Commented Apr 6, 2020 at 19:37
  • For the OS disk, partitioning is often necessary to provide the kind of data structures that the firmware and/or bootloader expects. Technically, a data-only disk can be used in Linux without partitioning: you could just create a filesystem on the whole-disk device and mount it. But it is not generally recommended, as other OSs would not recognize the disk as containing data, and might offer an easy one-click method for partitioning & creating a new filesystem on it - which would cause existing data on that disk to be overwritten.
    – telcoM
    Commented Apr 7, 2020 at 9:30

4 Answers 4

3

You are using df incorrectly. See the man page:

If an argument is the absolute file name of a disk device node containing
a mounted file system, df shows the space available on that file system
rather than on the file system containing the node.

The filesystem being shown is udev which is mounted on /dev and the node you're access is located on /dev.

Are you having issues accessing data on the HDD i.e. reading or writing?

Try running: sudo fdisk -l /dev/sda. This will show you the entire HDD including all its partitions.

0

You need to specify the partition number inside the disk to display the free space:

df -h /dev/sda1
2
  • This shows no such file found. I assume this means I didn't partition the HDD. Is this neccesary for me to access it? (Sorry, very new to Linux :))
    – user404496
    Commented Apr 6, 2020 at 19:19
  • @NicolasSchapeler, yes, you must partition the HDD. Try running "fdisk /dev/sda" as root. then "p" to see current partitions
    – dariox
    Commented Apr 6, 2020 at 19:40
0

From the discussion in various comments, it looks like you're probably not using the HDD at all yet. See the output of lsblk to verify that sda has no partitions, encrypted devices or LVM volumes associated with it, i.e. there is only one line mentioning sda and it has a TYPE value of disk.

First, it is recommended to partition the disk. Even if you use the whole disk as a single partition, having a valid partition table on the disk indicates to other operating systems that the disk is in use. This is helpful if you need to move the disk to another system e.g. for migration or recovery purposes.

Second, once the disk is partitioned, you will need to actually create a filesystem on the partition(s) you created. (In Windows, this would be called "formatting" instead.) In Linux, there are multiple possible filesystem types: ext4 is probably the most well-known, but XFS might be preferred for multi-terabyte filesystems.

If you use a GUI tool like gparted, it can perform both steps for you. On the command line, you might use fdisk /dev/sda or cfdisk /dev/sda to create the partition, and e.g. mkfs.ext4 /dev/sda1 or mkfs.xfs /dev/sda1 to create a filesystem on it.

Once the filesystem has been created, you'll need to create a mount point for it in a location of your choosing. A mount point is just an empty directory. For example: mkdir /bigdata.

After that, you should probably create a line in /etc/fstab to have the filesystem mounted automatically. Assuming you used xfs, the line could be:

/dev/sda1 /bigdata xfs defaults 0 0

For ext4, the line could be:

/dev/sda1 /bigdata ext4 defaults 0 2

(The last field on the line determines whether the filesystem will be automatically checked at boot time. ext4 requires such a routine check, while xfs handles routine integrity checks in the background while the filesystem is active, not as a separate boot-time step.)

Now you can finally mount the filesystem:

mount /bigdata

Once you've successfully mounted the filesystem, the first thing you should do is to set its ownership and permissions to values that make sense to you. For example, if that's your personal computer, you might assign access to your regular user account:

chown <your_username>: /bigdata

Now you'll have the added disk space available at /bigdata.

-1

When you buy a disk, it may already be partitioned for Windows, but yours isn't. fdisk will allow you to create partitions, but is perhaps not the most modern of fdisk-utilities. There are also partition editors, commandline or with a GUI (parted, gparted). You can pick your choice.

3
  • The issue here is with their df command, which shows the disk usage of wherever /dev is located.
    – Kusalananda
    Commented Apr 7, 2020 at 9:20
  • @Kusalananda, the "issue" is with an unpartioned disk. Commented Apr 7, 2020 at 10:14
  • Not only that, even if it was partitioned, it would unlikely be mounted on /dev/sda.
    – Kusalananda
    Commented Apr 7, 2020 at 10:16

You must log in to answer this question.