- How To List All Partitions Of A Disk In Linux?
- List Partitions With fdisk
- List Partitions with /proc/partitions
- List Partitions with parted
- List Partitions with blkid
- List Partitions with lsblk
- Linux View Hard Drive Partitions with fdisk and parted commands
- fdisk -l command
- GNU parted command
- 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 ”
How To List All Partitions Of A Disk In Linux?
Operating systems use storage or disks to save data persistently. Disks are used with partitions to manage them easily. Generally operating system and data partitions are placed separately. Home directory of the Linux is separated because a problem in the home directory like fulling do no effect to the general system. Modern Linux system use a lot of partitions. And here is the question How can I list partitions exists in my Linux system.
List Partitions With fdisk
fdisk is number one tool used by system administrators to manage disk. fdisk provides creating, deleting, listing of partitions. We need to use sudo in order to get root privileges.
List Partitions With fdisk
- There is a lot of information from system administrator perspective.
- /dec/vda is disk to list partitions
- /dev/vda1 is the partition of the disk
List Partitions with /proc/partitions
We can get more simpler list by using kernel provided information like below
List Partitions with /proc/partitions
- /proc/partitions provides information about partitions in a simple manner
- vda1 is a partition
List Partitions with parted
Parted is popular application especially creating, deleting partitions and file systems. We can use parted to list partitions too. We will also use -l option in order to list partitions.
List Partitions with parted
Disk information like Model, Sector Size and Partition Table type is also provided.
List Partitions with blkid
blkid is a command which will list block information with the related ID or UUID. This will also print partitions too. We need to provide sudo command too.
List Partitions with blkid
List Partitions with lsblk
lsblk is generally used to get mount points of the partitions but also used to list partitions. This command will list partitions and disk in a tree form.
List Partitions with lsblk
As we can see that fedora-root and fedora-swap are partitions created in the sda . There is also information like partition and disk size, type and mount point.
Источник
Linux View Hard Drive Partitions with fdisk and parted commands
Q . I’d like to see all the partitions on my scsi hard drives. Under Windows Disk manager shows exactly how space is allocated on the disk drivers and free space etc. How do I display hard drive partitions information?
A . You can use any one of the following command:
[a] fdisk command : Partition table manipulator for Linux
[b] GNU Parted : a partition manipulation program
fdisk -l command
To list the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that exists) are used i.e. it will try to display all partitions, enter:
$ sudo fdisk -l
OR
# fdisk -l
Output
- 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 ➔
GNU parted command
Pass print option to displays the partition table, enter:
$ sudo parted /dev/sda print
Output:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
Is there any day to day Linux Admin topic that you have left 😉
I’ve been facing this problem for some time and I guess i might get some help over here.
When partition is made or altered by Linux or Windows, it can easily be read by Linux but not if the partition table is altered by Linux (i.e. by making changes in partitions by Linux), it becomes unreadable by Windows.
Take the case of installing Windows XP or something on a box containing RHEL. When one tries to boot that system with a Windows XP cd for installing it, the setup hangs after showing something like – “Windows is checking you system configuration”. This happens because XP is unable to read partition Table entries made by Linux.
Now wipe out the entire MBR along with the Partition Table, XP boots okay showing the entire hard disk space as Unallocated Space.
Now i want to know if there is any workaround available for this problem. i.e Installing Windows on a box having RHEL installed on it. I dont want to remove RHEL every time before installing Windows for making it dual bootable.
Hi,
I have installed Redhat-5 in my system….
But cdwriter not mount….
Means when i run “mount /media/cdrecorder”, it is showing path not found….
I can go up to “cd /media”, then when i give “ls” command nothing is showing
Please support
You just insert the CD or DVD then login into the root and type these commands
mount /dev/dvd /media mount /dev/cd /mnt
cd /media cd /mnt
ls /media ls /mnt
you can follow any one column..
I have a harddisk I installed ubuntu linux in it the harddisk space it 20 gb i instlled it in 10 gb with swap space now i wnat to see the remeaning space how could i see use it
please help??
i have installed ubuntu linux in 23gb partition of my laptop but after installation grub is not showing windows 7 to boot and ubuntu not showing other drives. i already have tried “boot repair”. now i dont know what to do and how to save my data?
need help.
Model: ATA WDC WD3200BEVT-6 (scsi)
Disk /dev/sda: 320GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 18.1GB 18.1GB primary ext4 boot
2 18.1GB 22.1GB 3999MB extended
5 18.1GB 22.1GB 3999MB logical linux-swap(v1)
If you had not removed windows partitions while installing Ubuntu, then your windows partitions should be intact.
Don’t panic, its easy accessing windows partitions and the files and folders within them from Ubuntu (But not the other way around ;D not at-least jeopardizing the Ubuntu installation, and let me get straight on this that it MS to blame for this, not Ubuntu).
You can easily take backup of windows partition data on any external media like External Hard Disk/Pen Drive/CD/DVD/etc if you want.
—– (You don’t even need to) ——-
To access windows partitions, just open the File Browser (A Drawer like icon on the Launcher Panel on the left of the desktop screen)
In the windows that is now opened, you can see your windows partition on the left panel.
See the image on this link to see how it should look like:
http://2.bp.blogspot.com/-omfXnS75kuM/TjK-YxLqAZI/AAAAAAAACRQ/v3-g6RFsgEY/s1600/PCMan+file+manager+in+ubuntu+11.04.png
(The “Win XP” and “Mix” shown on the left panel are windows partitions. The name will differ as per the naming on your PC)
To access files on these partitions you simply need to click on the partition.
(See HOW EASY IT WAS and you were probably tearing your hair off by now 😀 )
You can plug in an external hard disk and copy your files to it from here if you want.
And for that windows 7 Partition not showing, it is probably because of “Secure Boot” and “EFI” settings in the BIOS of your PC/Laptop. There are lots of how-to’s out there in the net. Just google it, study and take notes before doing an Installation.
A quick fix you can try at this stage is running the following commands:
$sudo su –
[enter password of your account]
#update-grub
or
#update-grub2 (***use this if available)
Now reboot your PC/Laptop to check if both Ubuntu and Windows are available now in the grub boot menu.
1st i installed windows 7 then installed RED HAT 7. after that dual booting option is not showing. Please help.
Источник
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!
Источник