I’m doing an unattended installation of Ubuntu-14.04-server with a USB drive and a preseed file on different type of servers (HP Proliant ML110, ML310, ML350).
- On the ML110 and ML310, the hard drive is in
/dev/sda
and the USB drive takes/dev/sdb
.- While on the servers ML350, the USB drive takes the
/dev/sda
and the hard drive shows up in/dev/sdb
.As this should be a completely unattended installation, regardless of the server type, I need to find a way to give the correct device path to
d-i partman-auto/disk
.My first idea was to force the hard drive to show up before the USB drive, allowing it to take
/dev/sda
on the ML350 servers ; but I didn’t find a way do that.Therefore, I made a small script that detects the device name just before
partman
executes, and record that in a variable$INSTALL_DEV
:d-i partman/early_command string \ for DEV in `ls /sys/block | grep sd`; do \ if [ -n "`ls -l /sys/block/$DEV | grep /usb`" ]; then \ USB_DEV=/dev/${DEV}; \ echo "USB_DEV is $USB_DEV" >> /var/log/syslog; \ else \ INSTALL_DEV=/dev/${DEV}; \ echo "INSTALL_DEV = $INSTALL_DEV" >> /var/log/syslog; \ break; \ fi; \ done; \
Since then, I’m struggeling to find a way to give that variable to
d-i partman-auto/disk
. I thought of different alternatives but I couldn’t find a way to implement one of them:
- Make the
partma-auto/disk
interpret a variable. But unfortunately it only takes a string as a value.- Modify the
debian-installer
database where I hope the preseeded values are stored. But I didn’t find the database file (neither the way to alter it).- Make a script that includes a tiny preseed file with the correct device. But I can only include files from
preseed/include
, before the hard drive shows in/dev
.
Answer
Here is a simple partman/early_command
that does the exactly what I wanted
d-i partman/early_command \
string debconf-set partman-auto/disk "$(echo /dev/`ls -l /sys/block/[hs]d* | grep -v "usb" | head -n1 | sed 's/^.*\([hs]d[a-z]\+\).*$/\1/'`)"
This early-command
is executed just before partman
executes. It dynamically sets the value of partman-auto/disk
configuration of the debian-installer
.
The command between $(
and )
outputs the first hard drive found that is not an USB drive.
Attribution
Source : Link , Question Author : Jav , Answer Author : Jav