How are partitions in my hard disk handled in Ubuntu? I want to draw parallels with what Windows does.
Let's say I have a HDD formatted as ext4, if I create 2 partitions and mount them at /data-part
and /movies
, have I created 2 partitions like D:/
and E:/
?
First off, let's correct a little misconception:
You don't format a hard disk to a file system like ext4 or NTFS or FAT32, you format partitions to those file systems. When people say they've formatted a hard disk to ext4, they generally mean they've created a single partition covering the entire disk, and created an ext4 file system for that partition.
In Windows, partitions are each assigned a different drive letter (
C:
,D:
, etc). This makes it easier to discover which files are placed in which partitions. A hard disk can have several partitions, and a computer can have several hard disks and other storage devices. The downside is that you can't easily put different directories in different partitions, you can't putC:\Windows
in one partition andC:\Users
in other for example, they both must be in theC:
partition.In Linux, everything is a file, and it is all found under the root directory,
/
. A partition can be mounted to any directory under/
. For example, you could mount one partition to/home
, another to/var
, and another to/
, which would contain all the other files, but not ones inhome
orvar
.In Linux, even devices and running processes are files. For example, under
/proc
, you will find all the running processes, and under/dev/
, all the connected devices. Hard disks are typically named/dev/sda
,/dev/sdb
,/dev/sbc
, etc. Partitions with hard disks are typically named/dev/sda1
:sda
represents the hard drive, and1
represents the number of the partition within that hard drive. Every partition is then mounted to a directory in your file system. For example, your CD-ROM drive/dev/cdrom0
could be mounted to/media/cdrom0
. In your file explorer, you would navigate to/media/cdrom0
to see the CD's files.While this makes conceptually more difficult than Windows' system, it is much more flexible, as you can assign any directory to a new partition.