- How To Find Out Hard Disk Specs / Details on Linux
- Using lsblk command to find out hard disk information
- Linux show block device such as hard disk drive attributes
- hdparm Command
- lshw Command
- Finding Out Linux Disks Names Only
- Linux GUI Disk Utility
- The smartctl command
- A Note About RAID and SCSI Disks
- Conclusion
- 10 Commands to Check Disk Partitions and Disk Space on Linux
- 1. fdisk
- 2. sfdisk
- 3. cfdisk
- 4. parted
- 6. pydf
- 7. lsblk
- 8. blkid
- 9. hwinfo
- 10. Inxi
- Summary
- 47 thoughts on “ 10 Commands to Check Disk Partitions and Disk Space on Linux ”
- 6 Different Ways to List Hard Drives in Linux
- Listing Hard Drives in Linux
- 2. fdisk
- 3. lsblk
- 4. cfdisk
- 5. parted
- 6. sfdisk
- Смотрим список дисков Linux
- Как посмотреть список дисков в Linux
- Посмотреть список дисков в GUI
- Выводы
How To Find Out Hard Disk Specs / Details on Linux
Using lsblk command to find out hard disk information
Run the lsblk command as follows to lists information about all available or the specified block devices:
# lsblk
# lsblk /dev/DISK
# lsblk /dev/sda
So I have two NVMe SSD in RAID-1 mode with encrypted partitions:
Another option is to run the following command to list all disks and their names:
# ls -lF /dev/disk/by-id/
Linux show block device such as hard disk drive attributes
Open the terminal app and then type the blkid command:
# blkid
hdparm Command
Open the terminal and type the following command to find information about /dev/sda:
# hdparm -I /dev/sda
OR
$ sudo hdparm -I /dev/sda
Sample outputs:
lshw Command
You need to install lshw command using apt-get or yum command. To display all disks and storage controllers in the system, enter:
# lshw -class disk -class storage
Sample outputs:
Finding Out Linux Disks Names Only
The following lshw command will quickly list installed disks including CD/DVD/BD drivers:
# lshw -short -C disk
Sample outputs:
Another option so to run the fdisk command as follows:
# fdisk -l
Use the grep command/egrep command to filter out loopback and other unwanted devices:
# fdisk -l | grep ‘^Disk /dev/’
# fdisk -l | grep ‘^Disk /dev/’ | egrep -v ‘/dev/(loop|mapper|md)’
Linux GUI Disk Utility
Gnome users can use the gnome-disk-utility/gnome-disks for the following purposes:
- Get information about installed disks and its current health.
- Manage and configure disk drives.
- Configure media.
- Set up software RAID devices and more.
Type the following command or start Disk utility by visiting Applications > System Tools > Disk Utility :
$ palimpsest
OR
$ gnome-disks
Sample outputs:
Fig.01: Linux List Hard Drives GUI Tool & Command — Click to enlarge
Fig.02: Samrtdata about hard disk
The smartctl command
The smartctl command act as a control and monitor Utility for SMART disks under Linux and Unix like operating systems. Type the following command to get information about /dev/sda (SATA disk):
# smartctl -d ata -a -i /dev/sda
Sample outputs:
A Note About RAID and SCSI Disks
Try the following commands for SCSI and hardware RAID based devices:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
- sdparm Command – fetch SCSI / SATA device information.
- scsi_id Command – queries a SCSI device via the SCSI INQUIRY vital product data (VPD).
- Use smartctl To Check Disk Behind Adaptec RAID Controllers
- Use smartctl Check Hard Disk Behind 3Ware RAID Card
Conclusion
You learned about finding hard disk drive infromation on Linux. To get more information about your hard disk, refer to our other articles and tutorials:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
10 Commands to Check Disk Partitions and Disk Space on Linux
In this post we are taking a look at some commands that can be used to check up the partitions on your system.
The commands would check what partitions there are on each disk and other details like the total size, used up space and file system etc.
Commands like fdisk, sfdisk and cfdisk are general partitioning tools that can not only display the partition information, but also modify them.
1. fdisk
Fdisk is the most commonly used command to check the partitions on a disk. The fdisk command can display the partitions and details like file system type. However it does not report the size of each partitions.
Each device is reported separately with details about size, seconds, id and individual partitions.
2. sfdisk
Sfdisk is another utility with a purpose similar to fdisk, but with more features. It can display the size of each partition in MB.
3. cfdisk
Cfdisk is a linux partition editor with an interactive user interface based on ncurses. It can be used to list out the existing partitions as well as create or modify them.
Here is an example of how to use cfdisk to list the partitions.
Cfdisk works with one partition at a time. So if you need to see the details of a particular disk, then pass the device name to cfdisk.
4. parted
Parted is yet another command line utility to list out partitions and modify them if needed.
Here is an example that lists out the partition details.
Df is not a partitioning utility, but prints out details about only mounted file systems. The list generated by df even includes file systems that are not real disk partitions.
Here is a simple example
Only the file systems that start with a /dev are actual devices or partitions.
Use grep to filter out real hard disk partitions/file systems.
To display only real disk partitions along with partition type, use df like this
Note that df shows only the mounted file systems or partitions and not all.
6. pydf
Improved version of df, written in python. Prints out all the hard disk partitions in a easy to read manner.
Again, pydf is limited to showing only the mounted file systems.
7. lsblk
Lists out all the storage blocks, which includes disk partitions and optical drives. Details include the total size of the partition/block and the mount point if any.
Does not report the used/free disk space on the partitions.
If there is no MOUNTPOINT, then it means that the file system is not yet mounted. For cd/dvd this means that there is no disk.
Lsblk is capbale of displaying more information about each device like the label and model. Check out the man page for more information
Display UUID and Model of device
The «-o» option can be used to specify the columns to display. The following example shows the UUID and model name column along with other columns.
The above output has all the necessary information about all the storage devices present on the system or connected via usb. You can see the device name, size, mount point, uuid, model name etc.
This is the best command to see all information about storage devices together in one place.
8. blkid
Prints the block device (partitions and storage media) attributes like uuid and file system type. Does not report the space on the partitions.
9. hwinfo
The hwinfo is a general purpose hardware information tool and can be used to print out the disk and partition list.
The output however does not print details about each partition like the above commands.
To learn more about the Hwinfo command check this post:
Check hardware information on Linux with hwinfo command
10. Inxi
Inxi is a very useful command line program that can display information about various hardware components present on the system. To display information about the disk drives and storage devices use the «-D» option with inxi.
The «-x» option prints extra available information.
The output from inxi does not contains details like UUID and mount directory.
To learn more about the inxi command check out this post:
Inxi is an amazing tool to check hardware information on Linux
Summary
The output of parted is concise and complete to get an overview of different partitions, file system on them and the total space. Pydf and df are limited to showing only mounted file systems and the same on them.
Fdisk and Sfdisk show a whole lot of information that can take sometime to interpret whereas, Cfdisk is an interactive partitioning tool that display a single device at a time.
So try them out, and do not forget to comment below.
A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected] .
47 thoughts on “ 10 Commands to Check Disk Partitions and Disk Space on Linux ”
Thank you for this great summary of relevant commands and also showing whether SU privileges are needed or not.
Good article. Thanks for writing this .
I’d also suggest including “ncdu” (stands for ncurses du) – https://dev.yorhel.nl/ncdu – in this as it’s quite useful in knowing the disk usage on the terminal in a graphical way
pydf hands down the best alternative if you want a quick glance at disk usage!
Very useful, thank you!
very useful,
How about GUI tools?
Hardinfo is a GUI tool that shows hardware information including disk drives and partitions..
On ubuntu it can be installed with the following command
sudo apt-get install hardinfo
Another tool is gparted.
It is a partition management tool, but can also be used to list the disk drives and partitions
Well done — I learned something!
glad to know that.
thanks for the comment.
Very useful. Thank you for your effort.
Detailed and to the point post. Thanks A Ton!
Источник
6 Different Ways to List Hard Drives in Linux
There are several ways to list all the hard drives present in a system through Linux command lines.
Keep in mind a hard drive could be physically connected, virtually connected or even emulated (for example: when you use storage devices such as EMC, Sun or IBM).
Here are some different commands which can list the hard drives, keep in mind there are others but these are probably the most commonly used and easy to get the job done.
Listing Hard Drives in Linux
Please note that some of these commands are actually disk partitioning tools and listing disk partition is one of their features.
Let’s see what commands you can use to show disk info in Linux.
The df command in Linux is probably one of the most commonly used. It lists the actual “disk space usage” and it can give you information about what hard disks (or current disk space) is being used in the entire system.
The most common way to use it is with the -h argument which means “human readable” (because we are not machines, right?):
As you can see, the first column is the current logic name (or the name you can find it within your system), the second column is how big is each of them, the third column is how much is currently used (in bytes), the fourth column is how much is currently available in each for usage (in bytes), the fifth column is how much is used (in %) and the sixth and last column is where is it physically mounted in your Linux system.
2. fdisk
fdisk is another common option among sysops. It currently lists the different partitions (which is related to hard drives as a hard drive can be divided into several partitions) in your system.
This will return the entire amount of space (in GB or MB), the entire amount of bytes and the entire amount of sectors per each partition and as a summary, it also gives you the start and end sectors, the amount of disk space (in Bytes) and the type of partition.
Tip: Usually a SATA disk is labelled with sd.
3. lsblk
This one is a little more sophisticated but gets the job done as it lists all block devices. It will give you a very simple list of all devices:
It is probably more visual than the others as it even shows the partitions per each disk in a visual way (like the sda in the example above). It also gives information about the total size per each partition and disk and the physical location for each. This is very commonly used when you need to mount things to be used (like a USB stick or similar) so you can know where is it in order to proceed to mount it.
4. cfdisk
cfdisk is probably the most advanced one in GUI (Graphical User Interface), as it is absolutely visual and interactive. It allows at first to list all disks/partitions in your system but it also allows you to manage them by selecting them and then applying actions such as “Delete”, “Resize”, “Type” (to change partition Type) and “Write” changes done to partitions.
cfdisk example
It also gives you very friendly information about each partition and disk as it gives you where does each partition cylinders start and ends, amount of sectors used by each one and the full size of each one with its type. It won’t give you for example how much is used or free to use.
5. parted
This one is similar to previous ones mentioned, it lists all partitions and allows to manage them. Its main difference is that it also informs you the brand and model of your hard disks and even the type of connectivity used in it (scsi, sata, etc) and total disk size.
6. sfdisk
This is very similar to fdisk, however sfdisk allows you to see both physical and logical volumes and also gives you a “summary” of the actual physical volumes’ partitions with the cylinders (start and end), sectors, size and type.
Probably the “s” is for “super”, as it is a fdisk with super powers:
These commands should allow you to at least see what logical volumes, partitions and hard drives you have in your system and make use of this information for whatever reason you need it, being this just to know more or manipulate any of these.
Most of these commands also give you managing capabilities to modify and manipulate partitions at your will, so make sure to use them with responsibility.
If you like checking system information, do read the article about getting processor information in Linux command line.
If you have any questions or suggestions, do let me know in the comment section.
Источник
Смотрим список дисков Linux
Linux отображает подключённые жёсткие диски иначе, чем Windows. В операционной системе от Microsoft мы привыкли к тому, что у нас есть диск C, D, E, и нам не нужно задумываться о реальных именах разделов и жёстких дисков. Все диски размещены в проводнике и очень просто доступны.
В Linux такой возможности нет, как и нет такой абстракции. Диски и разделы именуются как есть, и вы будете иметь дело именно с этими именами. В этой статье мы разберём, как посмотреть список дисков Linux.
Как посмотреть список дисков в Linux
В Linux все отображается в файловом виде, в том числе и устройства. Все подключённые к операционной системе Linux устройства размещаются в каталоге /dev/ здесь вы найдете микрофоны, камеры, жёсткие диски, флешки, одним словом, все внешние и внутренние устройства.
Жёсткие диски имеют особенные названия. В зависимости от интерфейса, через который подключён жёсткий диск, название может начинаться на:
- sd — устройство, подключённое по SCSI;
- hd — устройство ATA;
- vd — виртуальное устройство;
- mmcblk — обозначаются флешки, подключённые через картридер;
В наше время большинство блочных устройств Linux подключаются через интерфейс SCSI. Сюда входят жёсткие диски, USB-флешки, даже ATA-диски теперь тоже подключаются к SCSI через специальный переходник. Поэтому в большинстве случаев вы будете иметь дело именно с дисками sd.
Третья буква в имени диска означает его порядковый номер в системе. Используется алфавитная система. Например sda — первый диск, sdb — второй диск, sdc — третий и так далее. Дальше следует цифра — это номер раздела на диске — sda1, sda2.
Самый простой способ увидеть все подключённые диски — это посмотреть содержимое каталога /dev/ и отфильтровать устройства sd:
Как видите, в моей системе сейчас есть только один диск и два раздела. Дальше мы можем посмотреть, куда примонтирован каждый из разделов:
Здесь, кроме дисков, будут отображаться различные специальные файловые системы: procfs, sysfs, tmpfs, cgroup и так далее. Однако все эти команды не помогут нам получить доступ к информации о дисках. Поэтому нам понадобится кое-что другое. Посмотреть подключённые диски с выводом информации о размере и свободном пространстве можно с помощью утилиты df:
Здесь отображается уже подробная информация. Но вы можете узнать ещё больше с помощью команды lsblk:
В этом случае список примонтированных дисков Linux включает ещё и информацию о точке монтирования, типе раздела (диск, раздел, привод) и его мажорном и минорном номере, по которым можно понять, что это за устройство. Если вам нужна информация о размере, то лучше использовать fdisk:
Это все утилиты, которыми вы можете воспользоваться, чтобы просмотреть список дисков Linux. Но есть ещё и графические утилиты.
Посмотреть список дисков в GUI
Во-первых, если к компьютеру подключено несколько дисков, то вы сможете их увидеть на левой панели файлового менеджера Nautilus или Dolphin. Там будет отображаться список подключенных устройств Linux, их метки и размер:
В Gnome есть программа Disks, которая позволяет настраивать поведение дисков, она же может отображать список подключенных устройств к системе. Вы можете найти её в главном меню:
Утилита отображает всю доступную информацию о дисках и разделах на них, вы можете даже посмотреть информацию о состоянии smart. Список дисков находится на панели слева, а справа разделы на этом диске:
Ещё одна утилита, которую вы можете использовать, чтобы посмотреть список жёстких дисков Linux — это Gparted. Это редактор разделов для Linux, но вы можете посмотреть подключнёные диски и структуру каждого из них. Раскрывающийся список вы найдёте в верхнем правом углу:
А в основной части окна программы отображается список разделов.
Выводы
В этой статье мы разобрали несколько способов посмотреть список примонтированных дисков Linux. Каждый из них может понадобиться в различных ситуациях. Если у вас остались вопросы, спрашивайте в комментариях!
Источник