I have an automated installation script (preseed file) for Ubuntu 18.04 which automatically partitions /dev/sda and /dev/sdb. I run this by booting from a USB drive, in "legacy BIOS" mode (so MBR is used). This worked fine on several machines so far - the hard drives are detected as sda and sdb, while the USB drive is sdc. However, on one particular server sda refers to the installation USB drive and the hard disks are sdb and sdc, so the automated partitioning fails.

Is there any way I can control this and make sure sda and sdb always refer to internal disks? Or is there any way I can force the installation USB drive to be "sdz" or something, which should have the same effect? Most of the advice I've found says "use UUIDs", but that won't help for an automated installation intended to work on many machines.

The boot order in the BIOS is set to boot from an internal hard disk first, but of course for the installation I have to override that (by pressing F11) to boot from the USB drive.

  • 1
    You can find fitting udev environment variables for the USB device by looking through the output of udevadm info -e, then edit your udev rule to use SUBSYSTEMS=="usb" and advise a specified device name. This is something you should look at: weininger.net/how-to-write-udev-rules-for-usb-devices.html – eblock Feb 1 at 11:46
  • redesign your script. add some code intelligence to it. have it try mounting all possible disks as seen in /proc/partitions. for those that succeed, look for a file that you know the USB has. format the other disks. – Skaperen Aug 2 at 5:01
  • How can I do that in a preseed script that says d-i partman-auto/disk string /dev/sda /dev/sdb? There is no possibility to inject code there AFAIK. – EM0 Aug 2 at 7:17

Your Answer

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

Browse other questions tagged or ask your own question.