User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive
 

This article will show how to use persistent naming with UUID.

Adding disk controller or new hard disk may result on a different device mapping on next reboot, for example /dev/sda can switch with /dev/sdb.
In order to avoid theses issues, we will use persistent naming.

In this article, you'll need ...
... Oracle Linux 7 installed (see oel7 installation here)
... root access is needed

Create disk partitions

On the new disk /dev/vdc, we will create one partition.

#Create disk partition
[root]$ fdisk /dev/vdc
    Welcome to fdisk (util-linux 2.23.2).

    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.

    Device does not contain a recognized partition table
    Building a new DOS disklabel with disk identifier 0xef23ac51.

Command (m for help): n
    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
Select (default p):
    Using default response p
Partition number (1-4, default 1):
First sector (2048-16777215, default 2048):
    Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215):
    Using default value 16777215
    Partition 1 of type Linux and of size 8 GiB is set

Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.

#Check partition
[root]$ fdisk -l /dev/vdc

    Disk /dev/vdc: 8589 MB, 8589934592 bytes, 16777216 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 label type: dos
    Disk identifier: 0xef23ac51

       Device Boot      Start         End      Blocks   Id  System
    /dev/vdc1            2048    16777215     8387584   83  Linux

Identify UUID

UUID are usually generated when create a filesystem on the disk partition.

As root, extract id as follow:

# Get UUID before mkfs (none)
[root]$ lsblk -f /dev/vdc
    NAME   FSTYPE LABEL UUID MOUNTPOINT
    vdc                      
    └─vdc1                   

# Create filesystem on partition
[root]$ mkfs -t xfs /dev/vdc1
    meta-data=/dev/vdc1              isize=256    agcount=4, agsize=524224 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=0        finobt=0
    data     =                       bsize=4096   blocks=2096896, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
    log      =internal log           bsize=4096   blocks=2560, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0

# Get UUID after mkfs
[root]$ lsblk -f /dev/vdc
    NAME   FSTYPE LABEL UUID MOUNTPOINT
    vdc                                                      
    └─vdc1 xfs          c739f00f-434f-478a-b80e-d761cbacac81 

# Another command to get UUID
[root]$ blkid /dev/vdc1
    /dev/vdc1: UUID="c739f00f-434f-478a-b80e-d761cbacac81" TYPE="xfs" 

Add to /etc/fstab

Next, you just need to add or modify the existing line in /etc/fstab as below:

UUID=c739f00f-434f-478a-b80e-d761cbacac81       /u02    xfs     defaults        1 2

 

HTH.
Please leave comments and suggestions,
Michel.

Reference
Persistent block device naming (wiki.archlinux.org)

Enjoyed this article? Please like it or share it.

Add comment

Please connect with one of social login below (or fill up name and email)

     


Security code
Refresh