0

I've done a disk partition with fdisk /dev/sda with following options: P - primary

But when inspecting disk with df -h command I do not see the disk space available to use. But I can see it with lsblk that it is part of the /dev/sda device drive as /dev/sda3. Is my new partition ready to use now or do I need to mount it first or do something else with it to enable it?

I got this when running lsblk:

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  500G  0 disk
├─sda1            8:1    0    1G  0 part /boot
├─sda2            8:2    0   39G  0 part
│ ├─centos-root 253:0    0 35.1G  0 lvm  /
│ └─centos-swap 253:1    0  3.9G  0 lvm  [SWAP]
└─sda3            8:3    0  460G  0 part

And this when running df -h:

[root@linx ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G  308K  1.9G   1% /dev/shm
tmpfs                    1.9G  8.9M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   36G  2.7G   33G   8% /
/dev/sda1               1014M  168M  847M  17% /boot
tmpfs                    379M     0  379M   0% /run/user/1881099406
  • 1
    I don't see an sda3 anywhere – muru Nov 05 '19 at 10:36
  • @muru just added the new output update. – anonymously132526 Nov 05 '19 at 12:54
  • How do I make the disk an /def/sdb instead of an /dev/sda? – anonymously132526 Nov 05 '19 at 12:58
  • What exactly do you mean by that? The device names are generated by the Linux operating system kernel, so you can't rename a drive from, say, /dev/sda to /dev/sdb (which should hardly ever be necessary in the first place). You will need to explain in more detail what exactly you want to accomplish. – AdminBee Nov 05 '19 at 13:01
  • You could use fdisk -l first to get that missing listing. With `-l' it is no problem, very like lsblk. There you see you new partitions. –  Nov 05 '19 at 13:11
  • You are using LVM, so normally would expand LVM to include unallocated space and create new volumes. That requires use of LVM tools not standard partitioning tools. If you want partition outside of LVM then you do use standard partitioning tools. https://wiki.ubuntu.com/Lvm – oldfred Nov 05 '19 at 16:13

3 Answers3

2

If you have simply created a new partition, then it is not yet ready for use. A partition is only a logical subdivision of a large disk into smaller portions which is performed so that usage or maintenance of one part of the disk doesn't affect the other (see e.g. the discussion here).

To use the partition, you must first create a filesystem in it, in the Linux world, an ext4 file system would be a typical example. To do that, run

mke2fs <appropriate options here> /dev/sda3

as root. Then, you indeed have to mount it before you can use it. In particular, df will only display information on mounted file systems.

There are plenty of examples on the web how to do this; you could look e.g. at

AdminBee
  • 22,803
  • When mounting, do I have to add a mount point? why? Is the mountpoint just a directory that I intend to use with the new partition? – anonymously132526 Nov 05 '19 at 12:56
  • Yes, a mount point is necessary, and it is a priori simply a directory which you create, and to which you "attach" the new partition so that the operating system knowns that if the user writes to this directory, he actually wants the data to appear on the partition mounted there instead of the partition on which the directory is physically created. See here for more explanations (and the two links I provided in my answer). – AdminBee Nov 05 '19 at 13:09
1

Despite what the other answers already tell You (partition needs to be formatted to be mountable and mounter to be shown by df and to be used as file system) you may want to use this disk with LVM as the other partitiona are also LVM.

You have to do pvcreate /dev/sda3 to make the partition a physical volume for lvm, a vgextend centos /dev/sda3 to add it to the pool of volume group centos and add it's space to an existing logical volume and filesystem lvresize -r /dev/mapper/centos-root /dev/sda3 or create a new logical volume from it lvcreate -l100%FREE centos -n data and format that additional volume mkfs.xfs /dev/mapper/centos-data, add an fstab entry and mount it.

0

Remember the df command only shows mounted file systems. All unmounted filesystems will not be shown in the df command output.

In order for you to be able to see your partition on df you must mount the partition first. If you look at your pdf output you can see sda3 us not mounted and the 'MOUNTPOINT' entry is empty.

To do this do the following:

  • find a suitable directory where you want to mount the partition/device. This directory must have suitable permissions which allow you to access it and mount in it, preferably 7 or rwx permissions.

  • Once you have found the mount directory you want to use you can start to mount, use the mount command the layout for this command is: mount (file path from /dev) (mount point directory)

Remember your current directory cannot be the mount point directory.

Lastly, some extra info I can add is that a mount point is simply just allowing a devices filesystem (your HDD filesystem of ntfs) to access another main filesystem of another device or part of the current file system (your computer or laptop that is running linux's filesystem which could be ext4) in order for the device to be able to be set up and start initiate.

programmer
  • 1,017