Tutorials

How to know on which partition ubuntu is installed

Table of contents:

Anonim

It is very likely that your computer's hard drive is divided into multiple partitions, since this allows you to access it independently. There are also several different reasons as to why you should partition your disk.

Do you want to know the partition where you have installed your Ubuntu operating system? Don't miss our guide!

Index of contents

How to know on which partition Ubuntu is installed

Many times you will want to list disk partitions on the system on all devices. This could be before you decide on a new partition format or maybe after you've made one. It may also be that you just want to list the partitions so you can see the disk usage or partition format on each of them.

All the commands listed below should be executed as superuser. You can log in as root or superuser before executing them, or use "sudo", otherwise you will get a "command not found" error. Also, you can specify a specific device, like / dev / sda or / dev / hdb as a command line argument to print partitions on the specified device.

In this article we show various basic commands to manage a partition table on Linux based systems.

The fdisk command

fdisk is a command line based disk manipulation utility, most commonly used for Linux / Unix systems. With the help of the fdisk command, you can view, create, resize, delete, change, copy and move partitions on a hard drive using its own user-friendly menu-based interface.

This tool is very useful in terms of creating space for new partitions, organizing space for new drives, rearranging an old drive, and copying or moving data to new disks. It allows you to create a maximum of four new primary partitions and a number of logical (extended) partitions, depending on the size of the hard disk you have on your system.

How to view all partitions in Linux with fdisk

fdisk is a user interface based Linux command to manipulate the disk partition table. It can also be used to list the partition table.

The following basic command lists all the existing disk partitions on your system. The argument "-l" (listing of all partitions) is used with the fdisk command to view all available partitions on Linux.

To list disk partitions on all devices, you must not specify a device.

Partitions are shown by the names of your devices. For example: / dev / sda, / dev / sdb or / dev / sdc.

# fdisk -l

How to view a specific partition in Linux with fdisk

To view all partitions on a specific hard drive, use the "-l" option with the device name. For example, the following command will display all disk partitions on the / dev / sda device. If you have different device names, just type the device name like / dev / sdb or / dev / sdc.

# fdisk -l / dev / sda

How to print entire partition table in Linux with fdisk

To print the entire hard drive partition table, you must be in the command mode of the specific hard drive, for example, / dev / sda.

# fdisk / dev / sda

From command mode, type "p". By entering “p”, you will print the specific partition table / dev / sda.

Other commands to list partitions from the command line

Parted

This is a command line utility to manipulate disk partitions. In addition to the ability to create, delete, and modify partitions, it can also be used to list the current partition table. As with most of the commands in this list, the -list or -l command line option will list disk partitions.

bash # parted -l

Isblk

lsblk is the Linux command that lists all the block devices on the system. You can list information about all available partitions or only specified devices. Prints information on a tree that is easy to read. Also, with this command you can specify the fields you want to display.

bash # lsblk

The above command will display a list of all available devices and partitions. If you want to list only certain information on a specific device, use the command format shown below.

bash # lsblk -o NAME, FSTYPE, SIZE / dev / sdb

Sfdisk

Sfdisk is similar to fdisk in listing partitions. The default output is slightly different than the fdisk command, but it practically prints similar information. You can use the command line option -l just like the fdisk command.

bash # sfdisk -l cat / proc / partitions

Another option for listing disk partitions is to print the partition device file in the / proc / directory. It contains limited information than other commands print, but is a good option when other commands and utilities are not available.

bash # cat / proc / partitions

mount

Mount is another Linux utility that can also be used. Actually mount will only show the disks and partitions that are currently mounted. Assuming all of your partitions are mounted, it will list disk partitions but will not show the unmounted ones.

bash # mount

gparted

If you prefer to have a graphical interface opposed to a command line utility, then gparted is a good option. Running gparted with no arguments will show all partitions that are on the devices. You can also change devices from the graphical user interface to view partitions on different disks.

All the above mentioned commands and utilities are not only used to list all disk partitions, but can also be used to create and modify them.

cfdisk

Cfdisk is a Linux partition editor with an interactive ncurses-based user interface. It can be used to list existing partitions, as well as create or modify them.

Cfdisk works with one partition at a time. So if you need to see the details of a particular disk, use the device name with cfdisk.

$ sudo cfdisk / dev / sdb

df

Df is not a partitioning utility, but prints details about mounted file systems. The list generated by df even includes filesystems that are not real disk partitions.

Only the file systems that start with / dev are real devices or partitions.

Use 'grep' to filter real hard drive files / partitions.

Please note that df only shows mounted file systems or partitions and not all.

pydf

It is an improved version of the df command, written in python. Prints all partitions on the hard drive in an easy to read way.

Again, pydf limits itself to displaying only mounted file systems.

blkid

Prints the attributes of the block device (storage partitions) such as uuid and file system type. Does not report space on partitions.

$ sudo blkid

hwinfo

Hwinfo is a general-purpose hardware information tool and can be used to print the list of disks and partitions. However, the output does not print details on each partition like the previous commands.

conclusion

Listing the partitions is useful to get an overview of the different partitions, the file system on them and the total space. Pydf and df are limited to displaying only mounted file systems.

Fdisk and Sfdisk display a large amount of information that may take some time to interpret, while Cfdisk is an interactive partitioning tool that displays only one device at a time.

Tutorials

Editor's choice

Back to top button