You are not logged in.

#1 2020-12-24 12:21:24

Terence64w
Member
Registered: 2020-12-17
Posts: 29

[SOLVED] /etc/fstab with /dev/disk/by-id/

Reading the fstab-wiki, there is not mentioned the use of `/dev/disk/by-id/`, well on my machine are additional storage-drives, 5 of them are exactly the same manufacturer and model.
Reading (a non arch-wiki) about installing OS with ZFS on root but also short mentioned in the arch-wiki, ZFS prefer `/dev/disk/by-id/` e.g. `/dev/disk/by-id/wwn-0x0123456789abcdef-part1`.
The `/dev/disk/by-id/` will never change and refer to disk only, not to GPT-UID nor label or any other..., so I decide to read all id's and write `0001-0005` on each same disk, this what I have done:

# Make a main folder where to mount dives

ls ~/Data_Devices/
Data-0001  Data-0002  Data-0003  Data-0004  Data-0005  sa-850-evo-250

# Read all id by disk

ls -la /dev/disk/by-id/
lrwxrwxrwx 1 root root  10 Dec 24 09:11 wwn-0x0123456789abcdef-part1 -> ../../sda1

# Add disk in `/etc/fstab`

# WD-Red 4TB N. 0001
/dev/disk/by-id/wwn-0x0123456789abcdef-part1 /home/terence/Data_Devices/Data-0001/ ext4 rw,user,exec,nofail,noauto,x-systemd.automount 0 0

# Reread `/etc/fstab`

sudo systemctl daemon-reload
sudo systemctl restart local-fs.target

this works, here my questions:
1. Do arch-linux recommend the use of `/dev/disk/by-id/`?
2. If yes, can i use it also for system-partitions of my nvme?
3. How can I generalize `/home/user/` in order all users can access the storage-disks? It's `$USER`?
I know how to set the `DISK=`-variable during the installation and use it with `sgdisk` ($DISK) but...
4. How to set-up `fstab` by OS-installation using directly `/dev/disk/by-id/`? Or how to modify following command?

genfstab -U /mnt >> /mnt/etc/fstab

Thanks you all for any help

Last edited by Terence64w (2020-12-25 11:34:01)

Offline

#2 2020-12-24 12:41:33

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

1. If it works use it, this is linux, so whatever you like.
2. Yes you can, there is no harm in trying, at worse if it fails to boot you can correct your /etc/fstab booting from alternate os/boot cd etc.,
3. You may use common group for all users, and allow that group to access /home/*, or all users may use same userid/password, eitherway they don't appear to be looking for any privacy.
4. edit manually.

Offline

#3 2020-12-24 13:07:17

Terence64w
Member
Registered: 2020-12-17
Posts: 29

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Docbroke wrote:

1. If it works use it, this is linux, so whatever you like.
2. Yes you can, there is no harm in trying, at worse if it fails to boot you can correct your /etc/fstab booting from alternate os/boot cd etc.,
3. You may use common group for all users, and allow that group to access /home/*, or all users may use same userid/password, eitherway they don't appear to be looking for any privacy.
4. edit manually.

2. That don't really satifying
3. No, i don't want it (/home/), i want everyone can access only the additional disks (/home/$USER/Data_Devices/)
4. How to edit it afterward I know and don't ask for it.

Offline

#4 2020-12-24 13:34:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,556
Website

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

For #1, "arch-linux" is not sentient and cannot recommend for or against anything.  Does the community recommend it?  Well, you've already answered that quite directly: there is no recommendation of this approach in the installation guide, fstab wiki, or fstab man page.  It is also not a feature of the genfstab script.  Further I would not recommend using by-id.  Why do you want to use by-id rather than UUIDs?  UUIDs are also unique and will not change.  In fact, by-ids are not necessarily unique.  One kernel device name maps to one UUID and one LABEL, but may map to multiple by-id entries.

For #2, how is that not satisfying?  The by-id entries on my system have the same time stamp as the /dev/sdaN entries suggesting they were created at the same time and should therefore be available for systemd to mount partitions.

For #3, a device must be mounted on an actual path.  Technically you could mount each partition several times in different locations, but I'd advise strongly against it.  Instead, just mount it in one global location, then either use bind mounts or a links to that location - I like the latter: mount to /mnt/data/Data-000, /mnt/data/Data-001, etc, then just create a symlink in each user's home directory ~/Data_Devices -> /mnt/data.

For #4, you could write a script to do this.  There is no magic, "genfstab" is just a script to extract information from lsblk and print it in fstab format.  This script does not use the hardware information that you want, but you could take a similar approach to write your own script.  But see the issue in point #1: the by-id names are not unique.

Last edited by Trilby (2020-12-24 13:36:18)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2020-12-24 15:27:32

Terence64w
Member
Registered: 2020-12-17
Posts: 29

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Trilby wrote:

For #1,
For #2,
For #3,
For #4,

Thanks for your answers, this clarify a lot of things.

# 1, I don't know exactly the difference between UUID and by-id but it's recommended from ZFS and from my experience this not changed even if I format the nvme with `nvme-cli` or change the logical block size (LBS) or write the whole "disk" with zeros (dd if=dev/zero ...) or make a new GPT or  format the partitions inside. Your sentence: "In fact, by-ids are not necessarily unique." disturbing me. If so than should be used also with ZFS UUID instead of disk/by-id?

# 2, Wasn't because i want learn how to in the best/reliable way. I don't know about time-stamp but I'm pretty sure the /dev/sdaN can and will change as soon a usb-stick is inserted, but... UUID is now clear and i will use this.

# 3, Thanks for this explanation, that's satisfying and clear everything.

# 4, I don't know how to make such a script (never done one) and i don't know how to insert in the installation-image or where to store it, etc. but, that's not relevant anymore (UUID).

# For 3, I have some additional questions:
3.1 `/mnt/data/` is not present, should I create it `sudo mkdir /mnt/data`. This will remain or are some application could delete this folder (this is the case in *ubuntu-family)?
3.2  Is this the correct command for the link?

sudo ln -s ~/Data_Devices/Data-0001 /mnt/data/Data_Devices/Data-0001

 
Thanks again

Last edited by Terence64w (2020-12-24 15:29:02)

Offline

#6 2020-12-24 16:26:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,556
Website

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Terence64w wrote:

... this not changed even if I format the nvme with `nvme-cli` or change the logical block size (LBS) or write the whole "disk" with zeros (dd if=dev/zero ...) or make a new GPT or  format the partitions inside.

Ah, that is a potential advantage of by-id as the UUIDs will change when you repartition or format the disks.  But even the by-id would not be very useful if you repartition as the number of partitions might change.  Do you plan on regularly repartitioning?  Why?

Terence64w wrote:

3.1 `/mnt/data/` is not present...

sudo ln -s ~/Data_Devices/Data-0001 /mnt/data/Data_Devices/Data-0001

I just made up /mnt/data, you need to chose where you want to mount your devices, and if needed create the mount points.  You could mount them all directly under /mnt (but you'd still need to create Data-0001, Data-0002, etc mount points).  For the symlink, I'd recommend creating one symlink to the directory containing all the mounts rather than creating a symlink for each mount.  In otherwords:

# NOT this:
ln -s ~/Data_Devices/Data-0001 /mnt/data/Data_Devices/Data-0001
ln -s ~/Data_Devices/Data-0003 /mnt/data/Data_Devices/Data-0003
ln -s ~/Data_Devices/Data-0003 /mnt/data/Data_Devices/Data-0003
# Just this:
ln -s ~/Data_Devices /mnt/data/Data_Devices

Although this is starting to sound like an X-Y problem.  If you don't know what the devices are, and you want them mounted for each user, it sounds like you may prefer udisks automounting.

Last edited by Trilby (2020-12-24 16:27:27)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2020-12-25 08:44:08

Terence64w
Member
Registered: 2020-12-17
Posts: 29

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Trilby wrote:

Ah, that is a potential advantage of by-id as the UUIDs will change when you repartition or format the disks.  But even the by-id would not be very useful if you repartition as the number of partitions might change.  Do you plan on regularly repartitioning?  Why?

If a "$DISK" is for data the partition-s amount will not changes (only one per DISK) but if fails you can identify it much faster, listen... I buy each month one or two such disk for building a server, I don't yet take the final decision if it will be a Linux (Arch) on ZFS or FreeNAS (BSD), two fresh flashed LSI 9112-8i are ready as well motherboard, CPU, RAM and some other parts. I just want not get confused with all those disks and before start the real/final project I want play around with those disks on my arch-main machine. Nevertheless, moving, resizing, formatting or even reinstalling the OS is much more easy by using the by-id solution. Of course, the negative point on arch-installation is  that can't copy and paste but you/we have to type only ones. All could be changed is "-partN" e.g. `$DISK-part3`. Starting e.g. with live Manjaro, once defined DISK-variable you can use it with `nvme $DISK` or `dd if=/dev/zero bs=4096 of=$DISK status=progress` to reset all Ubuntu-->Kubuntu on ZFS-root of 2TB nvme or test speed on natively 4k BS or with `sgdisk $DISK`. By having more disks, in my case: 2*nvme, 2*SSD, 2-3* HDD and one or more USB... this is a great relief!

But this not the (my) questions, the question is, considering the fact that I want install also arch on ZFS-root (later on)... are you sure?..

Trilby wrote:

In fact, by-ids are not necessarily unique.

Or, it's by-id reliable and save to use? Or, it's  enough to ask here about this topic or... whom should I ask for it? The wiki don't tell so much, you make some sentences but later on try to deviate the discussion on other topics not asked by myself.

I think, if I want continue to use arch-linux (from where i write now and appreciate so much) as main OS, independently of fact it's installed direct on "disk" or as "data-set" on top of ZFS... this question appertain here, or, I'm wrong?

Practically, you discourage the use use of by-id and ZFS encourage it, who is right and who is wrong, do I risk to get unbootable arch with by-id yes or not? I mean that's pretty simple question or not. Naturally, the answer of Docbroke it's unsatisfying for me saying just try it. What the reason to start a thread if the answer is: "Try it!"?

Trilby wrote:
ln -s ~/Data_Devices /mnt/data/Data_Devices

Well, naturally this is most elegant and simple solution and I will use it for the moment until other circumstances force me to change, thanks, tank a lot.

Trilby wrote:

Although this is starting to sound like an X-Y problem.  If you don't know what the devices are, and you want them mounted for each user, it sounds like you may prefer udisks automounting.

Hum... I think too and i will try to explain a bit deeper. In Germany say: "Man is a creature of habit". Not knowing the individual motivation is difficult to suggest solution, I understand this and try to explain...:

My motivation to change to arch is: It's more difficult to install as an Kubuntu or Devuan or Manjaro but i can install rEFInd instead of grub2 or start it with systemd without an extra bootloader. All some small applications like `ckb-next` was difficult to install under *.deb are here very easy to install over `pamac` from AUR or GIT very simple, even firefox extension are there.

My motivation for ZFS is: It has much more features and it's superior than ext4, btrfs, xfs but not easy to handle with it, not yet. More linux people will use it, more will be enhanced or made easier to use also for newbie like me.

Linux and for all, arch-linux on ZFS is (IMHO) the future and I want to get used or study it. I don't know if "udisks" is commonly used by ZFS/BSD but one is for sure I need a certain architecture for the data-storage-disks where some folders/data-sets are open for everyone and some/one/data-set only accessible by single person/user. Until now I can dedicate a whole disk to single user, later on (on FreeNAS or similar with 8+3 or 9+3 Z3-RAID) I have to manage it over the data-sets.

Now I decided that all clients (the single machines/desktops) will get arch-linux-kde (like mine) and later on will be on top of ZFS (ZFS-root), the server should be natively ZFS (FreeNAS or similar), an OS virtualization is not planned and will not succeed. A most common, reliable and safe handle/way to bind/mount disks and data-sets is required e.g. "/dev/disk/by-id/" if it's really unique.

Last edited by Terence64w (2020-12-25 08:55:07)

Offline

#8 2020-12-25 09:48:01

loqs
Member
Registered: 2014-03-06
Posts: 17,436

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Have you considered /dev/disk/by-path for dealing with large numbers of drives where replacements of failed drives would be to fill the same role in the array?

Offline

#9 2020-12-25 11:21:20

Terence64w
Member
Registered: 2020-12-17
Posts: 29

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

loqs wrote:

Have you considered /dev/disk/by-path for dealing with large numbers of drives where replacements of failed drives would be to fill the same role in the array?

No, I considered the /dev/disk/by-id/  from Arch-Wiki with world wide name I just found confirmation. read Code

ls -la /dev/disk/by-id/

and choosing/select/take the wwn respectively for HDD/SDD and NVMe

/dev/disk/by-id/wwn-0x(16 digits)
/dev/disk/by-id/nvme-eui.(16 digits)

If I had get the two Links before, the thread would have been much shorter. But I had to find them by myself.
Thank you anyway for try supporting me.

As in the second link explained the disk/by-id with wwn is exactly tailored for linux and due the BSD recommendations (from where ZFS come) to use the same... that's perfect.

I will set the thread as Solved

Thanks to everyone helped me

Offline

#10 2020-12-25 14:18:19

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,556
Website

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Terence64w wrote:

Of course, the negative point on arch-installation is  that can't copy and paste but you/we have to type only ones.

There is no reason to type them out manually.  Just `lsblk -rno WWN,MOUNTPOINT > fstab`, then edit the fstab file to add the partition numbers and additional columns.  Potentially chang WWN to MODEL,SERIAL if that's the id you'd want instead.

Terence64w wrote:

...considering the fact that I want install also arch on ZFS-root (later on)... are you sure?

Am I sure of what?  Note that I never suggested that using by-id was a bad idea.  You asked if it was recommended: I see no reason to recommend it.  I see no reason to recommend against it either.  So if you do have good reasons to use it, then by all means use it.  It should work fine.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#11 2020-12-25 17:07:53

Terence64w
Member
Registered: 2020-12-17
Posts: 29

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Trilby wrote:

There is no reason to type them out manually.  Just `lsblk -rno WWN,MOUNTPOINT > fstab`, then edit the fstab file to add the partition numbers and additional columns.  Potentially chang WWN to MODEL,SERIAL if that's the id you'd want instead.

How to if setting of `DISK=`-variable is done?

$DISK /mnt >> /mnt/etc/fstab
$DISK /mnt/boot >> /mnt/etc/fstab

or

$DISK-part2 /mnt >> /mnt/etc/fstab
$DISK-part1 /mnt/boot >> /mnt/etc/fstab 

and how is the code for swap-partition already on on `$DISK-part3`?
The MODEL (reading wikipedia-link) if switch from e.g Motherboard-controller to HBA (Host-Bus-Adapter) e.g. LSI-9112-8i will/can change from ATA/SATA to SCSI, hence not practicable solution or the best way is WWN for HDD/SSD and `nvme-eui` for NVMe.

Trilby wrote:

Am I sure of what?  Note that I never suggested that using by-id was a bad idea.  You asked if it was recommended: I see no reason to recommend it.  I see no reason to recommend against it either.  So if you do have good reasons to use it, then by all means use it.  It should work fine.

i can answer to this with another quote:

Trilby wrote:

For #1, "arch-linux"..... In fact, by-ids are not necessarily unique. ...

during I already in the first post talked about `/dev/disk/by-id/wwn` see quote:

Terence64w wrote:

# Read all id by disk

ls -la /dev/disk/by-id/
lrwxrwxrwx 1 root root  10 Dec 24 09:11 wwn-0x0123456789abcdef-part1 -> ../../sda1

# Add disk in `/etc/fstab`

# WD-Red 4TB N. 0001
/dev/disk/by-id/wwn-0x0123456789abcdef-part1 /home/terence/Data_Devices/Data-0001/ ext4 rw,user,exec,nofail,noauto,x-systemd.automount 0 0

Thank you anyway  for trying helping me.

P.S.: Wikipedia-link describe very well circumstances and indicate best solution = WWN.

Offline

#12 2020-12-25 22:15:26

GSMiller
Member
Registered: 2020-11-23
Posts: 75

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Trilby wrote:

There is no reason to type them out manually.  Just `lsblk -rno WWN,MOUNTPOINT > fstab`, then edit the fstab file to add the partition numbers and additional columns.

A great trick, thank you so much my friend.

Terence64w wrote:

How to if setting of `DISK=`-variable is done?

I do not understand this.

$ `DISK=`-variable
bash: -variable: command not found

What is this?


A dog is a man's best friend.

Offline

#13 2020-12-26 07:34:16

Terence64w
Member
Registered: 2020-12-17
Posts: 29

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Trilbyfan wrote:

I do not understand this.

$ `DISK=`-variable
bash: -variable: command not found

What is this?

Well, that's very simple I learn by installing Ubuntu and Devuan on ZFS but works on all Linux and BSD. In big server usually use 9+3 (RAID-Z3) + some spare disks (normally 4) also 16 disk per zpool.
The (time-save) benefit of disk-variable come better by small quantity of disks otherwise is better to export and re-import the zpool.

Ones you are prepared to start with partition you can set some variable avoid to type long text/numbers each time, that's for all useful if you use ZFS requiring `/dev/disk/by-id/wwn-0x0123456789abcdef` (this is the "world wide name" and numbers) of a disk.
If you omit to create `zpool`-s with `/dev/disk/by-id/wwn` (using simply `/dev/sda` or `/dev/nvme0n1`) you must export the zpool-s and reimport again before you can use it/them because the import succeed only `by-id`.

All "Live-Installation"-media like Manjaro, *buntu, Devuan, but even BDS where you click and insert name, password, computer-name (hostname) etc. etc.. use this method
You ca set a lot of "varable" here some examples:

DISK=/dev/disk/by-id/nvme-eui.0123456789abcdef
POOL=zarchpool-0001
HOST=zarch-0001
USER=terence

how to use examples:

? wipe whole disk and/or test speed e.g. nvme with logical and physical block-size 4k
? or just test specification-speed allways given at 4k
dd if=/dev/zero of=$DISK bs=4096 status=progress

? destroy former partition table:
sgdisk --zap-all $DISK

? start partitioning
sgdisk $DISK

? or
sgdisk -n 1:2M:+1G -t 1:ef00 -c 1:EFI-0001 $DISK
sgdisk -n 2:0:+70G -t 2:8200 -c 2:swap-0001 $DISK
sgdisk -n 3:0:0 -t 3:8300 -c 3:arch-0001 $DISK

? format partitions
mkfs.vfat -F32 -s 1 -S 4096 $DISK-part1
mkswap $DISK-part2
mkfs.ext4 -F -b 4096 $DISK-part3

? mount partitions
mount $DISK-part3 /mnt
mkdir /mnt/boot
mount $DISK-part1 /mnt/boot
swapon $DISK-part2 

? setup hostname
echo $HOST /etc/hostname

The biggest advantage of "disk-variable" is, once you decide/set the variable you don't need to care about the right disk during installation, in my case I have two nvme (/dev/nvme0n1 and /dev/nvme1n1) with each three partitions (p1, p2, p3) that can be confusing for all if you have only `CLI` and cannot copy/paste.

Offline

#14 2020-12-26 08:53:01

Terence64w
Member
Registered: 2020-12-17
Posts: 29

Re: [SOLVED] /etc/fstab with /dev/disk/by-id/

Read disk/by-id Code:

ls -la /dev/disk/by-id/

`/etc/fstab` before replace

# /dev/nvme1n1p2
UUID=dfafb113-e84d-48a9-a449-4ac5b0eedbc1	/         	ext4      	rw,relatime	0 1

use in e.g. `/etc/fstab` (replace UUID) with

# /dev/nvme1n1p2
# UUID=01234567-0123-0123-0123-0123456789abc	/         	ext4      	rw,relatime	0 1
/dev/disk/by-id/nvme-eui.0123456789abcdef-part2	/         	ext4      	rw,relatime	0 1

This also preferred by `rEFInd` bootloader

Last edited by Terence64w (2020-12-26 08:54:13)

Offline

Board footer

Powered by FluxBB