Only use UUID, never PARTUUID.
If you use
lsblk -P -p -o NAME,FSTYPE,PARTLABEL,UUID,SIZE,MOUNTPOINT,SUBSYSTEMS
you will see that they are different.
If you want a general utility for reporting such details formatted for direct use into the fstab, here is a script that I created for that, among other things.
Script Devices__ReportDiskParts.sh:
#!/bin/sh
#23456789+123456789+123456789+123456789+123456789+123456789+123456789+123456789+123456789+123456789+
####################################################################################################
###
### $Id: Devices__ReportDiskParts.sh,v 1.7 2021/02/20 02:43:37 root Exp root $
###
### Script to report all partitions that detected by the system.
###
####################################################################################################
TMP=/tmp/`basename $0 ".sh" `.tmp
doFSTAB=0
while [ $# -gt 0 ]
do
case $1 in
"--fstab" ) doFSTAB=1 ; break ;;
"--disk" ) lsblk -l -p --output-all | awk '/[/]dev[/]sd[a-z][0-9]/ { print $0 }' | sort --key=3 | awk '{ printf("%s\n\n", $0 ) ; }' ; exit 0 ;;
"--pairs" ) lsblk -p -P --output-all | awk '/[/]dev[/]sd[a-z][0-9]/ { print $0 }' | sort --key=3 | awk '{ printf("%s\n\n", $0 ) ; }' ; exit 0 ;;
"--raw" ) lsblk -l -p --output-all | sort --key=3 | awk '{ printf("%s\n\n", $0 ) ; }' ; exit 0 ;;
* ) echo "\n\t Invalid parameter '$1' used on command line. Only options allowed: [ --raw | --disk | --fstab ]\n Bye!\n" ; exit 1 ;;
esac
done
if [ -z "${MROOT}" ]
then
MROOT="/site" ; export MROOT
fi
pROOT=`df / | grep '/dev/' | awk '{ print $1 }' `
dROOT=`echo ${pROOT} | cut -c1-8 `
# If not terminal redirect comments to stderr.
if [ -t 1 ] ; then echo "\n\t NOTE: Expected mount point parent for all partitions not on root device => '$MROOT' ..." ; fi
#if [ ! -t 1 ] ; then echo "\n\t NOTE: Expected mount point parent for all partitions not on root device => '$MROOT' ..." >&2 ; fi
###
### All available parameters for lsblk (based on lsblk from util-linux 2.31.1)
###
### In sort order reported by --output-all
###
#1 NAME
# KNAME
# MAJ:MIN
#2 FSTYPE
#5 MOUNTPOINT
#ALT3 LABEL
#4 UUID
# PARTTYPE
#3 PARTLABEL
# PARTUUID
# PARTFLAGS
# RA
# RO
# RM
# HOTPLUG
# MODEL
# SERIAL
#6 SIZE
# STATE
# OWNER
# GROUP
# MODE
# ALIGNMENT
# MIN-IO
# OPT-IO
# PHY-SEC
# LOG-SEC
# ROTA
# SCHED
# RQ-SIZE
# TYPE
# DISC-ALN
# DISC-GRAN
# DISC-MAX
# DISC-ZERO
# WSAME
# WWN
# RAND
# PKNAME
# HCTL
# TRAN
#7 SUBSYSTEMS
# REV
# VENDOR
# ZONED
#lsblk -l -p -o NAME,FSTYPE,PARTLABEL,UUID,SIZE,MOUNTPOINT,SUBSYSTEMS | grep -v 'GRUB' | awk '/[/]dev[/]sd[a-z][0-9]/ { print $0 }' | sort --key=3 > ${TMP}.lsblk
#cat ${TMP}.lsblk
#cat ${TMP}.lsblk | awk '{ print NF }'
lsblk -P -p -o NAME,FSTYPE,PARTLABEL,UUID,SIZE,MOUNTPOINT,SUBSYSTEMS | grep -v 'GRUB' | awk '/[/]dev[/]sd[a-z][0-9]/ { print $0 }' | sort --key=3 > ${TMP}.lsblk.PAIRS
#cat ${TMP}.lsblk.PAIRS
while read line
do
eval echo '${line}' | tr ' ' "\n" |
{ fTYPE=""
while read data
do
eval echo '${data}' | awk -F'"' -v ftype="${fTYPE}" '{
split($1, vars, "=" ) ;
Fname=vars[1] ;
# Fval=vars[2] ;
Fval=$2 ;
if( Fval == "" ){
Fval="null" ;
} ;
printf("%s ", Fval) ;
# printf("%s|%s ", Fname, Fval) ;
}'
# case ${data} in
# FSTYPE* ) fTYPE="USB" ;;
# * ) ;;
# esac
done
}
echo ""
done <${TMP}.lsblk.PAIRS >${TMP}.lsblk
#cat ${TMP}.lsblk
#cat ${TMP}.lsblk | awk '{ print NF }'
## WD 4 TB My Book
#----------------------------------------------------------------------------------------------------------------------
#/dev/sdb1 on /site/My Book type exfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,iocharset=utf8,namecase=0,errors=remount-ro,uhelper=udisks2)
### 1,4,9,7,5,18
#----------------------------------------------------------------------------------------------------------------------
### /dev/sdb1 exfat My Book Not_Mounted /My
#/dev/sdb1 /dev/sdb1 /dev/sdb1 8:17 3.7T 3.7T exfat 6M 0% /site/My Book My Book 40FA-E56B fc843c51-1aec-4aab-8676-9043c9e59d0d atari ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 My Book 4c1ee663-135c-4809-a61e-f38ec52d80a7 128 0 0 1 3.7T root disk brw-rw---- 0 4096 0 4096 512 1 mq-deadline 2 part 0 4K 4G 0 0B 1 /dev/sdb block:scsi:usb:pci none
#----------------------------------------------------------------------------------------------------------------------
### /dev/sde3 ext4 DB002_F1 1b4157be-79cd-472b-96d9-a4cabacaffe1 Not_Mounted /site/DB002_F1
#/dev/sde3 /dev/sde3 /dev/sde3 8:67 ext4 DB002_F1 1b4157be-79cd-472b-96d9-a4cabacaffe1 9a3649a5-cbbb-4f1b-ae0b-f3c0d9cdec21 dos c12a7328-f81f-11d2-ba4b-00a0c93ec93b DB002_F1 a9b2eda8-ec21-4999-b1f6-eab36ce3bf75 128 0 0 0 279.4G root disk brw-rw---- 0 4096 0 4096 512 1 mq-deadline 64 part 0 0B 0B 0 0B 0x50014ee263b2c636 1 /dev/sde block:scsi:pci none
#----------------------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------------------
### **** ERROR **** Not handling 'My Passport' condition correctly
###
### Reporting as follows:
### /dev/sde1 ntfs My null Mounted 1.8T /media/ericthered/My
#----------------------------------------------------------------------------------------------------------------------
if [ ${doFSTAB} -eq 0 ]
then
if [ -t 1 ] ; then echo "\n\t ALL recognized DISK partitions:\n" ; fi
#if [ ! -t 1 ] ; then echo "\n\t ALL recognized DISK partitions:\n" >&2 ; fi
cat ${TMP}.lsblk | awk -v othrPath=${MROOT} -v dROOT="${dROOT}" '{
if ( $6 == "null" ){
if ( $2 == "swap" ){
printf("%-12s %-8s %-10s %-38s %-13s %-30s %s\n", $1, $2, $3, $4, "Not_Enabled", "[SWAP_OFFLINE]", $7 ) ;
}else{
if ( index($1,dROOT) == 0 ){
thatPath=sprintf("%s/%s", othrPath, $3 ) ;
printf("%-12s %-8s %-10s %-38s %-13s %-30s %s\n", $1, $2, $3, $4, "Not_Mounted", thatPath, $7 ) ;
}else{
thatPath=sprintf("/%s", $3 ) ;
printf("%-12s %-8s %-10s %-38s %-13s %-30s %s\n", $1, $2, $3, $4, "Not_Mounted", thatPath, $7 ) ;
} ;
} ;
}else{
if ( $2 == "swap" ){
printf("%-12s %-8s %-10s %-38s %-13s %-30s %s\n", $1, $2, $3, $4, "Enabled", $6, $7 ) ;
}else{
printf("%-12s %-8s %-10s %-38s %-13s %-30s %s\n", $1, $2, $3, $4, "Mounted", $6, $7 ) ;
} ;
} ;
}'
else
if [ -t 1 ] ; then echo "\n\t ALL recognized DISK partitions reported in format required to update '/etc/fstab':\n" ; fi
#if [ ! -t 1 ] ; then echo "\n\t ALL recognized DISK partitions reported in format required to update '/etc/fstab':\n" >&2 ; fi
#/dev/sdd1 ext4 DB002_F1 0aa50783-954b-4024-99c0-77a2a54a05c2 300G /site/DB002_F1
#UUID=f56b6086-229d-4c17-8a5b-e68de1a4e73d / ext4 errors=remount-ro 0 1
#UUID=7e9a663e-ff1d-4730-8544-c37519056b6f /DB001_F2 ext4 nosuid,nodev,nofail,errors=remount-ro 0 2
#UUID=c37e53cd-5882-401c-8ba3-172531a082e9 none swap sw,pri=3 0 0
###
### FUTURES: USB options rw,suid,umask=0000,uid=1000,gid=1000
###
cat ${TMP}.lsblk | awk -v othrPath=${MROOT} -v pROOT="${pROOT}" -v dROOT="${dROOT}" '{
if( index( $0, "usb" ) != 0 ){
usbPlug="USB_EXTERNAL" ;
}else{
usbPlug="INTERNAL" ;
} ;
if ( $6 == "null" ){
if ( $2 == "swap" ){
if ( $1 == pROOT ) {
perms="sw,pri=1" ;
seq=1 ;
}else{
perms="sw,pri=2" ;
seq=2 ;
} ;
if( $4 == "null" ){
printf("### %s ### No value for UUID. No file system on this partition.\n\n", $3 ) ;
}else{
printf("# %-12s %-8s %-10s %-38s %-13s %s %s\n", $1, $2, $3, $4, $5, "[SWAP]", usbPlug ) ;
printf("UUID=%s \t%s \t%s \t%s \t%s \t%s\n\n", $4, "none", $2, perms, "0", seq ) ;
} ;
}else{
if ( $1 == pROOT ) {
perms="defaults" ;
seq=0 ;
}else{
#perms="nosuid,nodev,nofail,defaults" ;
if( usbPlug == "USB_EXTERNAL" ){
perms="defaults,nofail,noauto" ;
}else{
perms="defaults,nofail" ;
} ;
if ( $1 ~ dROOT ) { seq=1 ; }else{ seq=2 ; } ;
} ;
if( $4 == "null" ){
printf("### %s ### No value for UUID. No file system on this partition.\n\n", $3 ) ;
}else{
if ( index($1,dROOT) == 0 ){
printf("# %-12s %-8s %-10s %-38s %-13s %s/%s %s\n", $1, $2, $3, $4, $5, othrPath, $3, usbPlug ) ;
printf("UUID=%s \t%s/%s \t%s \t%s \t%s \t%s\n\n", $4, othrPath, $3, $2, perms, "0", seq ) ;
}else{
printf("# %-12s %-8s %-10s %-38s %-13s /%s %s\n", $1, $2, $3, $4, $5, $3, usbPlug ) ;
printf("UUID=%s \t/%s \t%s \t%s \t%s \t%s\n\n", $4, $3, $2, perms, "0", seq ) ;
} ;
} ;
} ;
}else{
if ( $2 == "swap" ){
if ( $1 == pROOT ) {
perms="sw,pri=1" ;
seq=1 ;
}else{
perms="sw,pri=2" ;
seq=2 ;
} ;
if( $4 == "null" ){
printf("### %s ### No value for UUID. No file system on this partition.\n\n", $3 ) ;
}else{
printf("# %-12s %-8s %-10s %-38s %-13s %s %s\n", $1, $2, $3, $4, $5, $6, usbPlug ) ;
printf("UUID=%s \t%s \t%s \t%s \t%s \t%s\n\n", $4, "none", $2, perms, "0", seq ) ;
};
}else{
if ( $1 == pROOT ) {
perms="defaults" ;
seq=0 ;
}else{
#perms="nosuid,nodev,nofail,defaults" ;
if( usbPlug == "USB_EXTERNAL" ){
perms="defaults,nofail,noauto" ;
}else{
perms="defaults,nofail" ;
} ;
if ( $1 ~ dROOT ) { seq=1 ; }else{ seq=2 ; } ;
} ;
if( $4 == "null" ){
printf("### %s ### No value for UUID. No file system on this partition.\n\n", $3 ) ;
}else{
printf("# %-12s %-8s %-10s %-38s %-13s %s %s\n", $1, $2, $3, $4, $5, $6, usbPlug ) ;
printf("UUID=%s \t%s \t%s \t%s \t%s \t%s\n\n", $4, $6, $2, perms, "0", seq ) ;
};
} ;
} ;
}'
fi
# Other command format for other properties related to partitions:
# lsblk -o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,RA,WSAME
# Other option which is not as complete:
# blkid -o list
if [ -t 1 ] ; then echo "\n\t Done. [`basename $0 `]\n" ; fi
#if [ ! -t 1 ] ; then echo "\t Done. [`basename $0 `]\n" >&2 ; fi
rm -f ${TMP}.*
exit 0
exit 0
exit 0
NOTE: I assign a non-default mountpoint using that script. That non-default mountpoint BLOCKS attempts at automounting. You can modify that (replace "/site" with "/media/userid") to suit your needs, either by tweaking the outputs, or modifying the script directly to suit your own defaults.
With no parameters, the report looks like this:
NOTE: Expected mount point parent for all partitions not on root device => '/site' ...
ALL recognized DISK partitions:
/dev/sda3 ext4 DB001_F1 5dcf1a96-fa2e-42f5-9a08-37fcce0f0878 Mounted / block:scsi:pci
/dev/sda7 ext4 DB001_F2 7e9a663e-ff1d-4730-8544-c37519056b6f Mounted /DB001_F2 block:scsi:pci
/dev/sda8 ext4 DB001_F3 4f7d4192-b136-4a94-b06b-736f76155816 Mounted /DB001_F3 block:scsi:pci
/dev/sda9 ext4 DB001_F4 7f37ffd4-779a-46c6-b440-f384fb75eb98 Mounted /DB001_F4 block:scsi:pci
/dev/sda12 ext4 DB001_F5 14e15125-6c47-499e-b1a9-734a0f928b5e Mounted /DB001_F5 block:scsi:pci
/dev/sda13 ext4 DB001_F6 0d416936-e091-49a7-9133-b8137d327ce0 Mounted /DB001_F6 block:scsi:pci
/dev/sda14 ext4 DB001_F7 c2ff9e15-b50e-4c56-9c03-918bf81e0ab5 Mounted /DB001_F7 block:scsi:pci
/dev/sda4 ext4 DB001_F8 46fcb33d-5f0d-423b-b6a7-512c58c76aba Mounted /DB001_F8 block:scsi:pci
/dev/sda2 swap DB001_S1 266efd3e-f04d-4ea3-89e6-45e6ac227fa1 Not_Enabled [SWAP_OFFLINE] block:scsi:pci
/dev/sda10 swap DB001_S2 3b9a2c7a-67d4-4de7-ae66-214937dc47f4 Enabled [SWAP] block:scsi:pci
/dev/sda11 swap DB001_S3 78b04c8c-8ace-4b46-817d-7059aa1668b7 Enabled [SWAP] block:scsi:pci
/dev/sdb1 ext4 null 02c997f5-6b98-4c0a-9179-a8b89bfeb8f3 Not_Mounted /site/null block:scsi:pci
/dev/sdb2 swap null b9aa2a71-9430-4011-a955-9451d7f2c421 Enabled [SWAP] block:scsi:pci
Done. [Devices__ReportDiskParts.sh]
With the "--fstab" parameter, it looks like this:
NOTE: Expected mount point parent for all partitions not on root device => '/site' ...
ALL recognized DISK partitions reported in format required to update '/etc/fstab':
# /dev/sda3 ext4 DB001_F1 5dcf1a96-fa2e-42f5-9a08-37fcce0f0878 195.3G / INTERNAL
UUID=5dcf1a96-fa2e-42f5-9a08-37fcce0f0878 / ext4 defaults 0 0
# /dev/sda7 ext4 DB001_F2 7e9a663e-ff1d-4730-8544-c37519056b6f 293G /DB001_F2 INTERNAL
UUID=7e9a663e-ff1d-4730-8544-c37519056b6f /DB001_F2 ext4 defaults,nofail 0 1
# /dev/sda8 ext4 DB001_F3 4f7d4192-b136-4a94-b06b-736f76155816 293G /DB001_F3 INTERNAL
UUID=4f7d4192-b136-4a94-b06b-736f76155816 /DB001_F3 ext4 defaults,nofail 0 1
# /dev/sda9 ext4 DB001_F4 7f37ffd4-779a-46c6-b440-f384fb75eb98 293G /DB001_F4 INTERNAL
UUID=7f37ffd4-779a-46c6-b440-f384fb75eb98 /DB001_F4 ext4 defaults,nofail 0 1
# /dev/sda12 ext4 DB001_F5 14e15125-6c47-499e-b1a9-734a0f928b5e 195.3G /DB001_F5 INTERNAL
UUID=14e15125-6c47-499e-b1a9-734a0f928b5e /DB001_F5 ext4 defaults,nofail 0 1
# /dev/sda13 ext4 DB001_F6 0d416936-e091-49a7-9133-b8137d327ce0 195.3G /DB001_F6 INTERNAL
UUID=0d416936-e091-49a7-9133-b8137d327ce0 /DB001_F6 ext4 defaults,nofail 0 1
# /dev/sda14 ext4 DB001_F7 c2ff9e15-b50e-4c56-9c03-918bf81e0ab5 293G /DB001_F7 INTERNAL
UUID=c2ff9e15-b50e-4c56-9c03-918bf81e0ab5 /DB001_F7 ext4 defaults,nofail 0 1
# /dev/sda4 ext4 DB001_F8 46fcb33d-5f0d-423b-b6a7-512c58c76aba 93.5G /DB001_F8 INTERNAL
UUID=46fcb33d-5f0d-423b-b6a7-512c58c76aba /DB001_F8 ext4 defaults,nofail 0 1
# /dev/sda2 swap DB001_S1 266efd3e-f04d-4ea3-89e6-45e6ac227fa1 1G [SWAP] INTERNAL
UUID=266efd3e-f04d-4ea3-89e6-45e6ac227fa1 none swap sw,pri=2 0 2
# /dev/sda10 swap DB001_S2 3b9a2c7a-67d4-4de7-ae66-214937dc47f4 996.2M [SWAP] INTERNAL
UUID=3b9a2c7a-67d4-4de7-ae66-214937dc47f4 none swap sw,pri=2 0 2
# /dev/sda11 swap DB001_S3 78b04c8c-8ace-4b46-817d-7059aa1668b7 996.2M [SWAP] INTERNAL
UUID=78b04c8c-8ace-4b46-817d-7059aa1668b7 none swap sw,pri=2 0 2
# /dev/sdb1 ext4 null 02c997f5-6b98-4c0a-9179-a8b89bfeb8f3 463.8G /site/null INTERNAL
UUID=02c997f5-6b98-4c0a-9179-a8b89bfeb8f3 /site/null ext4 defaults,nofail 0 2
# /dev/sdb2 swap null b9aa2a71-9430-4011-a955-9451d7f2c421 2G [SWAP] INTERNAL
UUID=b9aa2a71-9430-4011-a955-9451d7f2c421 none swap sw,pri=2 0 2
Done. [Devices__ReportDiskParts.sh]