Mailing List Archive

Question about fstab - how to mount and umount by UUID?
This may be a little off-topic; I have a strange linux problem. Working
on a new Mythtv build, I have multiple drives installed...

Using all the Sata jacks:
Sata1: SSD for boot, 120Gig
Sata2: WD 2.0T (terra byte)
Sata3: Samsung 2.0T
Sata4: WD 1.5T
Sata5: WD 1.0T

Linux sees them as this (very strange, skips d, e, f, g)
/dev/sda
/dev/sdb
/dev/sdc
/dev/sdh
/dev/sdi

I've messed around with the bios boot order and gotten some different
results, but nothing puts them in order. I thought it might be better
to set up fstab with UUID's, but I don't see any way to manually
mount/umount each drive, individually . Google only shows "mount -a",
which I assume mounts everything in fstab. What do you suggest?

Don

Here's my fstab; the installer setup "/" and "swap"; I added the
remaining four.

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=4304d002-94ab-4fa6-b4d1-ac3801f86116 / ext4
errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=32f2a427-823c-485f-b88b-b38aa1842d27 none swap
sw 0 0

# Western Digital 2.0 T-byte drive
/dev/sdb1 /mnt/WD2.0T ext4 defaults 0 2
#UUID=7bbb6198-7ad6-4e2c-b167-a397672b7683 /mnt/WD2.0T ext4
defaults 0 2

# Samsung 2.0 T-byte drive
/dev/sdc1 /mnt/SS2.0T ext4 defaults 0 2
#UUID=b6177864-8e26-42b1-ad03-e8d742a05184 /mnt/SS2.0T ext4
defaults 0 2

# Western Digital 1.5 T-byte drive
/dev/sdh1 /mnt/WD1.5T ext4 defaults 0 2
#UUID=3fcecf66-e5c8-4525-aae1-430c72ad60cc /mnt/WD1.5T ext4
defaults 0 2

# Western Digital 1.0 T-byte drive
/dev/sdi1 /mnt/WD1.0T ext4 defaults 0 2
#UUID=15269600-3b39-43de-a846-f8c075481b12 /mnt/WD1.0T ext4
defaults 0 2



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Question about fstab - how to mount and umount by UUID? [ In reply to ]
Well, assuming the UUIDs in fstab are correct, you could uncomment the
UUID lines, then comment out the /dev lines, then reboot the system.

Calvin Dodge

On Thu, Jun 1, 2017 at 6:37 PM, Don Brett <dlbrett@zoominternet.net> wrote:
> This may be a little off-topic; I have a strange linux problem. Working on a
> new Mythtv build, I have multiple drives installed...
>
> Using all the Sata jacks:
> Sata1: SSD for boot, 120Gig
> Sata2: WD 2.0T (terra byte)
> Sata3: Samsung 2.0T
> Sata4: WD 1.5T
> Sata5: WD 1.0T
>
> Linux sees them as this (very strange, skips d, e, f, g)
> /dev/sda
> /dev/sdb
> /dev/sdc
> /dev/sdh
> /dev/sdi
>
> I've messed around with the bios boot order and gotten some different
> results, but nothing puts them in order. I thought it might be better to
> set up fstab with UUID's, but I don't see any way to manually mount/umount
> each drive, individually . Google only shows "mount -a", which I assume
> mounts everything in fstab. What do you suggest?
>
> Don
>
> Here's my fstab; the installer setup "/" and "swap"; I added the remaining
> four.
>
> # /etc/fstab: static file system information.
> #
> # Use 'blkid' to print the universally unique identifier for a
> # device; this may be used with UUID= as a more robust way to name devices
> # that works even if disks are added and removed. See fstab(5).
> #
> # <file system> <mount point> <type> <options> <dump> <pass>
> # / was on /dev/sda1 during installation
> UUID=4304d002-94ab-4fa6-b4d1-ac3801f86116 / ext4
> errors=remount-ro 0 1
> # swap was on /dev/sda5 during installation
> UUID=32f2a427-823c-485f-b88b-b38aa1842d27 none swap sw
> 0 0
>
> # Western Digital 2.0 T-byte drive
> /dev/sdb1 /mnt/WD2.0T ext4 defaults 0 2
> #UUID=7bbb6198-7ad6-4e2c-b167-a397672b7683 /mnt/WD2.0T ext4 defaults
> 0 2
>
> # Samsung 2.0 T-byte drive
> /dev/sdc1 /mnt/SS2.0T ext4 defaults 0 2
> #UUID=b6177864-8e26-42b1-ad03-e8d742a05184 /mnt/SS2.0T ext4 defaults
> 0 2
>
> # Western Digital 1.5 T-byte drive
> /dev/sdh1 /mnt/WD1.5T ext4 defaults 0 2
> #UUID=3fcecf66-e5c8-4525-aae1-430c72ad60cc /mnt/WD1.5T ext4 defaults
> 0 2
>
> # Western Digital 1.0 T-byte drive
> /dev/sdi1 /mnt/WD1.0T ext4 defaults 0 2
> #UUID=15269600-3b39-43de-a846-f8c075481b12 /mnt/WD1.0T ext4 defaults
> 0 2
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://lists.mythtv.org/mailman/listinfo/mythtv-users
> http://wiki.mythtv.org/Mailing_List_etiquette
> MythTV Forums: https://forum.mythtv.org
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Question about fstab - how to mount and umount by UUID? [ In reply to ]
On Thu, Jun 1, 2017 at 4:37 PM, Don Brett <dlbrett@zoominternet.net> wrote:

> This may be a little off-topic; I have a strange linux problem. Working on
> a new Mythtv build, I have multiple drives installed...
>
> Using all the Sata jacks:
> Sata1: SSD for boot, 120Gig
> Sata2: WD 2.0T (terra byte)
> Sata3: Samsung 2.0T
> Sata4: WD 1.5T
> Sata5: WD 1.0T
>
> Linux sees them as this (very strange, skips d, e, f, g)
> /dev/sda
> /dev/sdb
> /dev/sdc
> /dev/sdh
> /dev/sdi
>
> I've messed around with the bios boot order and gotten some different
> results, but nothing puts them in order. I thought it might be better to
> set up fstab with UUID's, but I don't see any way to manually mount/umount
> each drive, individually . Google only shows "mount -a", which I assume
> mounts everything in fstab. What do you suggest?
>
> Don
>
> Here's my fstab; the installer setup "/" and "swap"; I added the remaining
> four.
>
> # /etc/fstab: static file system information.
> #
> # Use 'blkid' to print the universally unique identifier for a
> # device; this may be used with UUID= as a more robust way to name devices
> # that works even if disks are added and removed. See fstab(5).
> #
> # <file system> <mount point> <type> <options> <dump> <pass>
> # / was on /dev/sda1 during installation
> UUID=4304d002-94ab-4fa6-b4d1-ac3801f86116 / ext4
> errors=remount-ro 0 1
> # swap was on /dev/sda5 during installation
> UUID=32f2a427-823c-485f-b88b-b38aa1842d27 none swap sw
> 0 0
>
> # Western Digital 2.0 T-byte drive
> /dev/sdb1 /mnt/WD2.0T ext4 defaults 0 2
> #UUID=7bbb6198-7ad6-4e2c-b167-a397672b7683 /mnt/WD2.0T ext4
> defaults 0 2
>
> # Samsung 2.0 T-byte drive
> /dev/sdc1 /mnt/SS2.0T ext4 defaults 0 2
> #UUID=b6177864-8e26-42b1-ad03-e8d742a05184 /mnt/SS2.0T ext4
> defaults 0 2
>
> # Western Digital 1.5 T-byte drive
> /dev/sdh1 /mnt/WD1.5T ext4 defaults 0 2
> #UUID=3fcecf66-e5c8-4525-aae1-430c72ad60cc /mnt/WD1.5T ext4
> defaults 0 2
>
> # Western Digital 1.0 T-byte drive
> /dev/sdi1 /mnt/WD1.0T ext4 defaults 0 2
> #UUID=15269600-3b39-43de-a846-f8c075481b12 /mnt/WD1.0T ext4
> defaults 0 2
>

It looks like you're almost there. Maybe try just one at a time, but swap
the uncommented lines (/dev/sd*) for the commented ones (UUID), and then
you can pass the mount point as an option to mount or unmount individual
drives. e.g., `mount /mnt/WD2.0T`. I believe with "defaults" as the option,
it will automatically mount the drive. You can add "noauto" if you don't
want that.

Karl
Re: Question about fstab - how to mount and umount by UUID? [ In reply to ]
To identify the UUIDs on your system, use this command:

ls -l /dev/disk/by-uuid/

I've been using UUID in /etc/fstab for a long time and it works well.
I've also needed to use the value in /dev/disk/by-id/ for Grub.

HTH,

- Nate

--

"The optimist proclaims that we live in the best of all
possible worlds. The pessimist fears this is true."

Ham radio, Linux, bikes, and more: http://www.n0nb.us
Re: Question about fstab - how to mount and umount by UUID? [ In reply to ]
On Thu, 1 Jun 2017 19:37:24 -0400, you wrote:

>This may be a little off-topic; I have a strange linux problem. Working
>on a new Mythtv build, I have multiple drives installed...
>
>Using all the Sata jacks:
>Sata1: SSD for boot, 120Gig
>Sata2: WD 2.0T (terra byte)
>Sata3: Samsung 2.0T
>Sata4: WD 1.5T
>Sata5: WD 1.0T
>
>Linux sees them as this (very strange, skips d, e, f, g)
>/dev/sda
>/dev/sdb
>/dev/sdc
>/dev/sdh
>/dev/sdi
>
>I've messed around with the bios boot order and gotten some different
>results, but nothing puts them in order. I thought it might be better
>to set up fstab with UUID's, but I don't see any way to manually
>mount/umount each drive, individually . Google only shows "mount -a",
>which I assume mounts everything in fstab. What do you suggest?

The order the kernel puts drives in seems to be determined by the
order it loads its drivers, and then by the order each driver
enumerates the hardware it operates. The gap in your drive lettering
is likely caused by there being another SATA controller in your
chipset that is not connected to any physical ports, or maybe it is
connected to one or two eSATA ports on your back panel. Smaller
motherboards often use the same chipsets as larger motherboards, and
then have hardware in the chipset that is not connected to anything
due to lack of space for connectors.

There is no way I have found to control how the kernel assigns the
drive letters. So it is best to simply not use the drive letters
unless forced to, so using UUIDs or partition labels is the right way
to mount things. UUIDs have been around for this purpose for a long
time, but now partition labels are also available and I find I prefer
to use them. To assign a label to a partition, I prefer to use
gparted (you may need to install it if it is not already available).
It is a GUI version of the parted partitioning program and can assign
a drive label to any unmounted partition for you. Here is an example
from my fstab:

### Disk 8: ST8000AS0002-1NA17Z_Z540HZMD 8 Tbytes (SMR) (vid3)
LABEL=vid3 /mnt/vid3 jfs relatime,errors=remount-ro,nofail 0 2

The advantage I find for using labels is that they can be meaningful -
UUIDs are very hard to remember!

Take a look at the /dev/disk subdirectories for all the different ways
a modern Linux allows you to refer to drives and partitions:

root@mypvr:/mnt# ll /dev/disk
total 0
drwxr-xr-x 8 root root 160 May 27 01:14 ./
drwxr-xr-x 22 root root 6000 May 27 01:15 ../
drwxr-xr-x 2 root root 1360 May 27 01:14 by-id/
drwxr-xr-x 2 root root 400 May 27 01:14 by-label/
drwxr-xr-x 2 root root 160 May 27 01:14 by-partlabel/
drwxr-xr-x 2 root root 480 May 27 01:14 by-partuuid/
drwxr-xr-x 2 root root 580 May 27 01:14 by-path/
drwxr-xr-x 2 root root 440 May 27 01:14 by-uuid/

root@mypvr:/mnt# ll /dev/disk/by-label/
total 0
drwxr-xr-x 2 root root 400 May 27 01:14 ./
drwxr-xr-x 8 root root 160 May 27 01:14 ../
lrwxrwxrwx 1 root root 10 May 27 01:14 rec1 -> ../../sdb3
lrwxrwxrwx 1 root root 10 May 27 01:14 rec1boot -> ../../sdb1
lrwxrwxrwx 1 root root 10 May 27 01:14 rec2 -> ../../sdd2
lrwxrwxrwx 1 root root 10 May 27 01:14 rec2boot -> ../../sdd1
lrwxrwxrwx 1 root root 10 May 27 01:14 rec3 -> ../../sda5
lrwxrwxrwx 1 root root 10 May 27 01:14 rec3boot1 -> ../../sda2
lrwxrwxrwx 1 root root 10 May 27 01:14 rec3boot2 -> ../../sda3
lrwxrwxrwx 1 root root 10 May 27 01:14 rec3boot3 -> ../../sda4
lrwxrwxrwx 1 root root 10 May 27 01:14 rec4 -> ../../sdc1
lrwxrwxrwx 1 root root 10 May 27 01:14 rec5 -> ../../sdn1
lrwxrwxrwx 1 root root 10 May 27 01:14 rec6 -> ../../sdm1
lrwxrwxrwx 1 root root 10 May 27 01:14 rec7 -> ../../sdi1
lrwxrwxrwx 1 root root 15 May 27 01:14 ssd1 -> ../../nvme0n1p3
lrwxrwxrwx 1 root root 15 May 27 01:14 ssd2 -> ../../nvme0n1p4
lrwxrwxrwx 1 root root 10 May 27 01:14 vid1 -> ../../sdj2
lrwxrwxrwx 1 root root 10 May 27 01:14 vid1boot -> ../../sdj1
lrwxrwxrwx 1 root root 10 May 27 01:14 vid2 -> ../../sdk1
lrwxrwxrwx 1 root root 10 May 27 01:14 vid3 -> ../../sdl1

You can use those /dev/disk names in any place you normally use
/dev/sd?? names. So, for example, to do a check on my rec1boot
partition, I can do:

umount /dev/disk/by-label/rec1boot
fsck -C -f /dev/disk/by-label/rec1boot
mount /dev/disk/by-label/rec1boot

Note that the full support of partition labels is fairly new - it will
not work or some things will not work on older kernels from a couple
of years ago.

It is also possible to use a bit of scripting to find out the
/dev/sd?? name for a mounted device. This is what I use (gleaned from
the Internet):

root@mypvr:/mnt# cat /usr/local/bin/dev-mounted
#!/bin/bash

# Return the device that is mounted on the mount point $1

mountp=$1

if ! [[ "$mountp" == *\/* ]]; then
mountp="/mnt/$mountp"
fi

df | grep -w $mountp | awk {'print $1'}

And here is my script that uses dev-mounted to unmount and put to
sleep any of my archive drives that I currently have mounted:

root@mypvr:/mnt# cat /usr/local/bin/uarc.sh
#!/bin/bash

set -x

# Unmount and put to sleep all the archive drives.

arc1dev=$(dev-mounted arc1)
arc2dev=$(dev-mounted arc2)
arc3dev=$(dev-mounted arc3)

if [ ${#arc1dev} -ne 0 ]; then
umount /mnt/arc1
fi

if [ ${#arc2dev} -ne 0 ]; then
umount /mnt/arc2
fi

if [ ${#arc3dev} -ne 0 ]; then
umount /mnt/arc3
fi

sleep 20

if [ ${#arc1dev} -ne 0 ]; then
hdparm -Y $arc1dev
fi

if [ ${#arc2dev} -ne 0 ]; then
hdparm -Y $arc2dev
fi

if [ ${#arc3dev} -ne 0 ]; then
hdparm -Y $arc3dev
fi
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org