1

I'm about to automate the installation of Debian by using the preseed mechanism (preseed file added to initrd). The computers to be provisioned have multiple SATA disks.

I would like to specify in the preseed file precisely what partition to put on what disk. This is possible, of course, by specifying the associated device files (sda, sdb, sdc). However, if I understand correctly, the association between disk and device file is not a priori defined in general, and may even change after rebooting in certain situations. I am especially concerned about usb sticks or other portable hard drives. I have encountered such a situation myself, when the usb stick was /dev/sda during installation from that very stick.

So, how do I ensure, that the right partition is placed on the right disk, each time the preseeded ISO image is used for installation?

7
  • 1
    Should this work generally, in many computers? Or should it work in one single computer, where you can specify the identity of the drives? – sudodus Feb 6 '20 at 19:05
  • 2
    I think the only sane thing to do is use the disk serial numbers or controller-device paths. There should be a visible serial number on each disk, although I'm not sure that tiny SSDs have them. Or boot from thumb drive or PXE and list /dev/disk/by-id/ or /dev/disk/by-path/ to help decide what to put in the preseed file. – Mark Plotnick Feb 7 '20 at 5:14
  • 1
    I agree with Mark Plotnick, that you can use the information from /dev/disk/by-id/ or /dev/disk/by-path. An alternative that you may prefer is to use lsblk in modern linux systems: sudo lsblk -do name,size,model,serial or variations on that theme to provide input to your tool. – sudodus Feb 7 '20 at 8:57
  • 1
    This means that I can specify a disk in the preseed not only by /dev/sdx, but also by /dev/disk/by-id and /dev/disk/by-path and whatever other scheme is provided? (That would be elegant!) – Flo Feb 7 '20 at 9:21
  • 1
    I tried the /dev/disk/by-id and it worked! It's exactly what I was looking for. @MarkPlotnick I would accept your comment as an answer, if it was one. – Flo Feb 7 '20 at 17:43
0

The summarize the answer, based a comment from @MarkPlotnick: The key is to understand, that there are multiple device files representing the same drive. The most well known are /dev/sda, /dev/sdb etc. where the ordering is not well defined. However, drives can also be refered to by using the device files in /dev/disk/by-id. These device files are bound to the serial numbers of the disks and are therefore unambigously and reproducably defined. And as it turns out, I could use those device files in the preseed as a replacement for /dev/sda etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.