How to Fix /dev/mapper Issue When Installing Linux

Sometimes we tend to use a used drive to install Linux. And sometimes installation of OS did not go through or you are seeing a problem because of the previous state of the disk which you are not aware of (i.e. it was used for raid arrays etc)

The only way to see and resolve it is to boot the machine/server to rescue mode.

Manifestation

Upon boot up on rescue, check the disk it should have something like:

-rescue# fdisk -l

Disk /dev/sda: 480.1 GB, 480103981056 bytes
255 heads, 63 sectors/track, 58369 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          14      112423+  83  Linux
/dev/sda2              15         513     4008217+  82  Linux swap / Solaris
/dev/sda3             514       58369   464728320   83  Linux

Disk /dev/mapper/ddf1_4c534920202020201000007915d9070047114711e9719c20: 479.0 GB, 478998953984 bytes
255 heads, 63 sectors/track, 58234 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

                                                             Device Boot      Start         End      Blocks   Id  System
/dev/mapper/ddf1_4c534920202020201000007915d9070047114711e9719c20p1               1          14      112423+  83  Linux
/dev/mapper/ddf1_4c534920202020201000007915d9070047114711e9719c20p2              15         513     4008217+  82  Linux swap / Solaris
/dev/mapper/ddf1_4c534920202020201000007915d9070047114711e9719c20p3             514       58369   464728320   83  Linux

Disk /dev/mapper/ddf1_4c534920202020201000007915d9070047114711e9719c20p1: 115 MB, 115121664 bytes
255 heads, 63 sectors/track, 13 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/ddf1_4c534920202020201000007915d9070047114711e9719c20p1 doesn't contain a valid partition table

Disk /dev/mapper/ddf1_4c534920202020201000007915d9070047114711e9719c20p2: 4104 MB, 4104414720 bytes
255 heads, 63 sectors/track, 499 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/ddf1_4c534920202020201000007915d9070047114711e9719c20p2 doesn't contain a valid partition table

Resolution:

1. Check the the list of /dev/mapper

-rescue# ls /dev/mapper
control
ddf1_4c534920202020201000007915d9070047114711e9719c20p0
ddf1_4c534920202020201000007915d9070047114711e9719c20p1
ddf1_4c534920202020201000007915d9070047114711e9719c20p2
ddf1_4c534920202020201000007915d9070047114711e9719c20p3

2. Clear them up:

-rescue# dmsetup remove ddf1_4c534920202020201000007915d9070047114711e9719c20p1
-rescue# dmsetup remove ddf1_4c534920202020201000007915d9070047114711e9719c20p2
-rescue# dmsetup remove ddf1_4c534920202020201000007915d9070047114711e9719c20p3

 3. Check the list again:

-rescue# ls /dev/mapper
control
ddf1_4c534920202020201000007915d9070047114711e9719c20p0

 4. Now wipe the entire disk:

-rescure# dd if=/dev/zero of=/dev/sda bs=512 seek=$(( $(blockdev --getsz /dev/sda)- 1024)) count=1024

5. Disable rescue, reinstall OS and it should be good.

Spread the love

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.