• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer

The Geek Diary

HowTos | Basics | Concepts

  • Solaris 11
  • Solaris
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VxVM
  • VCS
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting

CentOS / RHEL : How to change the UUID of the filesystem

By admin

The device node name of a disk (/dev/sda, /dev/hda, /dev/vda, etc.) may change in some situations. For example, after switching cables around or upgrading certain packages, sda & sdc could swap places. This causes problems when /etc/fstab references filesystems by the disk names. It is not safe to use block device node names like /dev/sda1 and /dev/vdb2 to refer to filesystems in /etc/fstab.

Instead, use filesystem UUIDs (universally unique identifiers) or labels. Either of these allows for identifying a filesystem without resorting to ephemeral block device names.

Note : UUIDs and labels are not required if a filesystem resides on an LVM logical volume, as in default RHEL/CentOS installations.

Check the current UUID of the filesystem

1. To find of the current UUID of the filesystem you can use either of the below commands.

# blkid /dev/sdc1
/dev/sdc1: UUID="94ddf54e-53f7-4a1a-bd2f-d0a01ee448d1" TYPE="ext4"
# dumpe2fs /dev/sdc1 | grep UUID
dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem UUID:          94ddf54e-53f7-4a1a-bd2f-d0a01ee448d1

You can also view the UUID in the file /etc/fstab, if there is an entry done manually for the filesyste.

# grep data /etc/fstab
UUID="94ddf54e-53f7-4a1a-bd2f-d0a01ee448d1"       /data     ext4    defaults        0 2

1. Changing UUID using tune2fs

1. To be able to change the UUID of the filesystem, it must be umounted first.

# umount /data

2. The tune2fs command allows the UUID to be changed using the -U flag. The -U flag allows generation of a random UUID or time-based UUID.

# tune2fs -U random /dev/sdc1
tune2fs 1.42.9 (28-Dec-2013)

3. When modifying existing UUIDs, make sure to update any references to the old labels in fstab. First check for the new UUID and then make appropriate changes in the /etc/fstab file.

# blkid | grep sdc1
/dev/sdc1: UUID="d2c27808-f88f-44bc-bb1d-de3b03d133e4" TYPE="ext4"
# vi /etc/fstab
UUID="d2c27808-f88f-44bc-bb1d-de3b03d133e4"       /data     ext4    defaults        0 2

4. Mount the filesystem back again.

# mount /data

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to Use “repoquery” Command to List Package Dependencies
  2. How to map /dev/sdX and /dev/mapper/mpathY device from the /dev/dm-Z device
  3. UNIX / Linux : Send mail with attachment using mutt
  4. CentOS / RHEL : How to install and start the Apache httpd service
  5. CentOS / RHEL : Resize (reduce) non-root EXT3/4 filesystem on non-LVM device (hard disk partition)
  6. CentOS / RHEL : How to find if a network port is open or not?
  7. How to Back Up and Restore XFS File Systems (xfsdump / xfsrestore)
  8. How to enable IPv6 on CentOS / RHEL 7
  9. How to create virtual block device (loop device/filesystem) in Linux
  10. How to configure chrony statistics in CentOS / RHEL 7

You May Also Like

Primary Sidebar

Recent Posts

  • Linux OS Service ‘smartd’
  • Oracle SQL script to Show current Users and SQL being Executed
  • How to use qperf to measure network bandwidth and latency performance in Linux
  • How to Password Protect GRUB2 in Oracle Enterprise Linux 7
  • How to move or rename a datafile in the same ASM diskgroup (Using ASM alias)

Footer

Cheat Sheets

  • LDOMs (OVM for SPARC) Command line reference
  • Solaris Volume Manager (SVM) command line reference
  • Solaris ZFS command line reference
  • RHEL 7 – RHCSA Notes (Cheat Sheets)
  • CentOS / RHEL 7 : firewalld Cheat Sheet
  • systemd command line reference (cheat sheet)

Solaris interview questions

  • The ultimate Solaris Volume Manager (SVM) interview questions
  • The ultimate Solaris zones (containers) interview questions
  • The ultimate Solaris networking interview questions
  • The ultimate ZFS interview questions
  • Archives
  • Contact Us
  • Copyright

© 2018 · The Geek Diary