0

I have partially overwritten my system disk with a copy of CentOS-7-x86_64-DVD-1708.iso (wrong /dev/sdX in the dd command). I since recovered from this and I notice that in Ubuntu 16.04 /dev/sdb1 (which is in fact a swap partition and should not have a name) is given the name "CentOS 7 x86_64":

$ ls -l /dev/disk/by-label/              
total 0
lrwxrwxrwx 1 root root 10 May  4 12:29 Backup -> ../../sda2
lrwxrwxrwx 1 root root 10 May  4 12:29 centos7 -> ../../sdb2
lrwxrwxrwx 1 root root 10 May  4 12:29 CentOS\x207\x20x86_64 -> ../../sdb1   <===== ? swap partition
lrwxrwxrwx 1 root root 10 May  4 12:29 data -> ../../sdb5
lrwxrwxrwx 1 root root 10 May  4 12:29 Data -> ../../sda1
lrwxrwxrwx 1 root root 10 May  4 12:29 ubuntu -> ../../sdb3

I have an Ubuntu 14.04 on another drive which also assigns this name to a partition on drive /dev/sdb :

$ ls -l /dev/disk/by-label/
total 0
lrwxrwxrwx 1 root root 10 May  4 14:16 Backup -> ../../sda2
lrwxrwxrwx 1 root root 10 May  4 14:16 centos7 -> ../../sdb2
lrwxrwxrwx 1 root root 10 May  4 14:16 CentOS\x207\x20x86_64 -> ../../sdb4 <=== ? extended partition
lrwxrwxrwx 1 root root 10 May  4 14:16 data -> ../../sdb5
lrwxrwxrwx 1 root root 10 May  4 14:16 Data -> ../../sda1
lrwxrwxrwx 1 root root 10 May  4 14:16 ubuntu -> ../../sdb3

This time it is /dev/sdb4 which the extended partition container and hence should not have any name either.

Search as I may I did not find where this names comes from and how to get rid of it.

The trouble is that when I try to install a CentOS 7 (from a USB key) the installer scripts looks for a disk labeled "CentOS 7 x86_64" and picks a partition on /dev/sdb rather than the USB key (which is at /dev/sdc in my system).

Come someone help me to solve this issue ? Thanks.

0

If /dev/sdb1 is a swap parition, then you can update the label using mkswap. This will re-format the swap partition; there may be other options to avoid that:

# swapoff /dev/sdb1
# mkswap -L swap_part /dev/sdb1
# swapof /dev/sdb1

Here, 'swap_part' is the new label:

$ ls -l /dev/disk/by-label
...
lrwxrwxrwx 1 root root 9 May 8 09:32 swap_part -> ../../sdb1
...

If you want to remove the label all together, you can set it to the empty string:

# mkswap -L "" /dev/sdb1
  • I also had to change the mounting of the swap partition in /etc/fstab as the UUID of the partition was modified. HOWEVER this has not changed anything : after a reboot ls /dev/disk/by-label/ still shows "CentOS 7 x86_64" as pointing to /dev/sdb1 ... – Frederic May 9 '18 at 7:03
  • I had used an empty label but I have now also tried with a non-empty label: it does not make a difference. – Frederic May 9 '18 at 7:11
  • @Frederic When I run those commands, the content of /dev/disk/by-label updates dynamically. I see the changes immediately. Is sdb4 the partition that you want to have that label? – Andy Dalton May 9 '18 at 17:07
  • no, I don't want /dev/sdb4 to have this label it just happened and I only see this label on /dev/sdb4 when I boot the Ubuntu 14.04 on /dev/sda3. /dev/sdb4 is the MBR extended partion container which contains /dev/sdb5 with an ext4 file system labeled "data". – Frederic May 9 '18 at 21: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.