23

After installing CentOS, I see several lines like /dev/mapper/centos_jackpc--11-swap and /dev/mapper/centos_jackpc--11-root when I issue fdisk -l.

What is the purpose of these? And why do they not show up for Ubuntu?

The full fdisk -l is shown here:

Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders, total 488281250 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e3a37

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   287754239   143364096   8e  Linux LVM
/dev/sda3       287756286   434180095    73211905    5  Extended
/dev/sda5       287756288   434180095    73211904   83  Linux

Disk /dev/sdb: 4000.8 GB, 4000787030016 bytes
255 heads, 63 sectors/track, 486401 cylinders, total 7814037168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x6c03e282

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63  2147504935  1073752436+  83  Linux
Partition 1 does not start on physical sector boundary.

Disk /dev/mapper/rhel_jackpc-root: 104.9 GB, 104857600000 bytes
255 heads, 63 sectors/track, 12748 cylinders, total 204800000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/rhel_jackpc-root doesn't contain a valid partition table

Disk /dev/mapper/rhel_jackpc-swap: 41.9 GB, 41943040000 bytes
255 heads, 63 sectors/track, 5099 cylinders, total 81920000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/rhel_jackpc-swap doesn't contain a valid partition table
30

The entries in /dev/mapper are LVM logical volumes. You can think of these as Linux's native partition type. Linux can also use other partition types, such as PC (MBR or GPT) partitions.

Your disk is divided in MBR partitions, one of which (/dev/sda2) is an LVM physical volume. The LVM physical volume is the single constituent of the volume group rhel_jackpc, which contains two logical volumes: root (which is your CentOS system partition) and swap (which is your CentOS swap partition).

Ubuntu is installed directly on an MBR partition, presumably /dev/sda5.

fdisk -l lists information about all the block devices that could contain MBR partitions (or GPT partitions in recent versions of fdisk). It's technically possible, albeit highly unusual and rather pointless, to have PC partitions inside an LVM logical volume, so fdisk -l looks there and reports that it doesn't find a partition table. This is normal.

On Ubuntu, you wouldn't see anything about the LVM logical volume if the volume group is not activated. Since Ubuntu isn't using any of the volumes, it wouldn't activate the volume group.

Whether to use PC partitions or LVM volumes for a Linux installation is often merely a matter of convenience. There are things you can't do with PC partitions, such as spread them on multiple disks, or simply resize them and move them around easily, or create snapshots with them, so an installation over LVM is a lot more flexible. But if you don't need this flexibility, you can install directly onto PC partitions.

  • 9
    Note that the Linux device mapper is used for other things besides LVM (such as dm-crypt disk encryption), so files in /dev/mapper aren't necessarily LVM logical volumes. But these ones look like they are. (They follow the naming convention that LVM uses.) – Wyzard May 20 '15 at 2:06
  • 1
    Wyzard, okay - so then, is there a way to make sure the two logical volumes root and swap are indeed from /dev/sda2 (and not just by looking at how they are named)? – Tosh May 20 '15 at 7:24
  • 2
    @Tosh By “PC” I mean PC, not Windows. MBR and GPT partitions are what the boot firmware (BIOS and UEFI) understand respectively. Windows sticks with PC partition types because it only runs on PC (and a few ARM platforms but they don't have “native” partition types). Some unix systems (e.g. *BSD) use their own partition scheme on PC hardware, others (e.g. Linux) don't care. – Gilles May 20 '15 at 11:50
  • 5
    @Tosh You can run lsblk to view the storage tree, or vgs and lvs to list volume groups and logical volumes. – Gilles May 20 '15 at 11:51
  • 1
    @Gilles How did you figure out the partition /dev/sda2 is associated with the rhel_jackpc volume group? From the naming convention, perhaps? I guess lsblk would confirm this, but you didn't have the lsblk output to work with. – flow2k Feb 26 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.