Understand Partitions

General support questions
shahar91
Posts: 7
Joined: 2018/03/26 19:01:30

Understand Partitions

Post by shahar91 » 2018/03/26 19:20:15

Hi, I trying to understand which partition I have on the hard disk when I install CentOS7. So I installed CentOS 7 on a VM and I run lsblk command.

What is sda2?

sda 8:0 0 60G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 58.8G 0 part
├─centos-root 253:0 0 38.2G 0 lvm /
├─centos-swap 253:1 0 2G 0 lvm [SWAP]
└─centos-home 253:2 0 18.6G 0 lvm /home

I know that
sda1 its the efi partition that contain the boot loader, kernel images....
sda3 is managed by LVM and contain OS-Root partition, swap partition for the RAM and home partition for the users.

please correct me if I am wrong

desertcat
Posts: 843
Joined: 2014/08/07 02:17:29
Location: Tucson, AZ

Re: Understand Partitions

Post by desertcat » 2018/03/26 21:32:29

shahar91 wrote:Hi, I trying to understand which partition I have on the hard disk when I install CentOS7. So I installed CentOS 7 on a VM and I run lsblk command.

What is sda2?

sda 8:0 0 60G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 58.8G 0 part
├─centos-root 253:0 0 38.2G 0 lvm /
├─centos-swap 253:1 0 2G 0 lvm [SWAP]
└─centos-home 253:2 0 18.6G 0 lvm /home

I know that
sda1 its the efi partition that contain the boot loader, kernel images....
sda3 is managed by LVM and contain OS-Root partition, swap partition for the RAM and home partition for the users.

please correct me if I am wrong
OK I'll *attempt* to answer this question though I'm *probably* WRONG!! ...Especially since you are running CentOS 7 as a VM which I have not done.

A little background is in order: I run CentOS 7.4 as my primary OS, and I have set up it up using a Classical Partitioning Scheme.

Onward!! The /boot/efi partition is only necessary IF you are using a machine that has UEFI, and has no classical BIOS to refer to. UEFI, as I understand it -- which could be WRONG -- is basically a small FAT32 partition that replaces the MBR on a standard HDD, and this is the substitute for the BIOS. The /boot partition OTOH -- sda2 in your case -- is the the partition that holds GRUB2 that boots the OS, the sda2 /boot partition can be formated in ext4, xfc, etc. .... whereas the /boot/efi partition *must* be FAT32.

Now comes the interesting question: Given that you have installed CentOS 7 as a VM , which can not access the BIOS since it is installed in volatile RAM I'm not sure you need the /boot/efi partition, but you DO need the /boot partition because that loads the OS. I am sure someone will correct if I am WRONG. Me?? As my primary OS with a MB that supports both UEFI and Legacy (Classical) BIOS, I have set it up to use a Classical MBR BIOS, as I have had nothing but bad luck trying to use UEFI, hence I have set it up as such:

/boot
/
/usr
/home
/tmp
/var
/vm4
/backup
SWAP

User avatar
TrevorH
Site Admin
Posts: 33221
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Understand Partitions

Post by TrevorH » 2018/03/26 22:31:22

sda 8:0 0 60G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 58.8G 0 part
├─centos-root 253:0 0 38.2G 0 lvm /
├─centos-swap 253:1 0 2G 0 lvm [SWAP]
└─centos-home 253:2 0 18.6G 0 lvm /home
You've obviously installed on a UEFI capable VM as you have a separate /boot/efi. You also have a separate /boot partition - your sda2 - which contains the necessary files required to boot your system to the point where it becomes useful. Your /dev/sda3 is an LVM Physical Volume (PV) and that PV belongs to an LVM Volume Group called 'centos'. In that centos VG, you have 3 LVM Logical Volumes - LVs - called 'root', 'swap' and 'home'.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

shahar91
Posts: 7
Joined: 2018/03/26 19:01:30

Re: Understand Partitions

Post by shahar91 » 2018/03/27 05:49:33

Thanks for the answers.
I know that I need EFI partition because I installed this machine on UEFI but I thought that GRUB2 located in EFI partition. Wikipedia site confused me.

User avatar
jlehtone
Posts: 4532
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Understand Partitions

Post by jlehtone » 2018/03/27 08:42:42

One can always ask "What is in there?"

The sda1 is mounted on /boot/efi, so lets list all files in there:

Code: Select all

sudo find /boot/efi
The sda2 is mounted on /boot, so we could just do find, but we don't want the content of /boot/efi in the list:

Code: Select all

sudo find /boot -path /boot/efi -prune -o -print

User avatar
TrevorH
Site Admin
Posts: 33221
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Understand Partitions

Post by TrevorH » 2018/03/27 09:50:50

-xdev might be easier to type :-)
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

shahar91
Posts: 7
Joined: 2018/03/26 19:01:30

Re: Understand Partitions

Post by shahar91 » 2018/03/27 18:22:18

jlehtone wrote:One can always ask "What is in there?"

The sda1 is mounted on /boot/efi, so lets list all files in there:

Code: Select all

sudo find /boot/efi
The sda2 is mounted on /boot, so we could just do find, but we don't want the content of /boot/efi in the list:

Code: Select all

sudo find /boot -path /boot/efi -prune -o -print
Are they not separate partitions? sda1, sda2 and sda3?

User avatar
jlehtone
Posts: 4532
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Understand Partitions

Post by jlehtone » 2018/03/28 20:39:10

Yes, the disk "sda" has three partitions: sda1, sda2, sda3.

shahar91
Posts: 7
Joined: 2018/03/26 19:01:30

Re: Understand Partitions

Post by shahar91 » 2018/03/29 05:36:37

jlehtone wrote:Yes, the disk "sda" has three partitions: sda1, sda2, sda3.
/boot and /boot/efi make me confused, those two start with /boot. How?

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: Understand Partitions

Post by MartinR » 2018/03/29 13:00:52

You are confusing partitions and mount points. A partition is a chuck of space somewhere. Most commonly it is part of some spinning rust, but could be space on another system, in memory or a map to space elsewhere. It doesn't matter, provided the kernel can load the appropriate driver the driver handles all the nasty physical stuff.

A directory is an index file telling the filesystem where to find files. When you mount a partition the kernel hijacks its internal understanding of the directory and stores information allowing it to invoke the appropriate driver. The top level directory of the partition then appears as if it were the original directory.

In the present case:
  • /boot is a directory on the root partition which is copied into Linux's internal cache.
  • sda2 is a partition somewhere on the first disk.
  • # mount /dev/sda2 /boot changes the internal version to be pointers that the kernel uses to find sda2
  • /boot now transparently vectors you to the top level directory of sda2.
  • Within sda2's top level directory there is a directory called efi. Due to the mount above it appears to be at /boot/efi
That may appear a bit like laboured revision, but the same thing happens again:
  • We have already found the directory /boot/efi which is copied into Linux's internal cache.
  • sda1 is a partition somewhere on the first disk.
  • # mount /dev/sda1 /boot/efi changes the internal version to be pointers that the kernel uses to find sda1
  • /boot/efi now transparently vectors you to the top level directory of sda1.
  • Within sda1's top level directory there is a directory called EFI (at least on my machine). Due to the mount above it appears to be at /boot/efi/EFI
One thing I haven't mentioned; if the directories which are used as mountpoints contain files, then those files will be hidden by the mount. This can occasionally be useful to provide a fallback position in case a mount fails, but more commonly is just a trap for the unwary.

Post Reply