Score:0

Preseed - Install OS on smallest disk

za flag

I'm trying to create a preseed file for my systems with 2 HDD's. I want to install the OS on the smallest disk, but on some systems, this disk is labeled as sdb and others sda. Is there a way to select the smallest disk?

d-i partman/early_command string \
  PRIMARYDISK=/dev/$(lsblk -Sn -o NAME --sort SIZE --include 8 | head -n 1) ; \
  debconf-set partman-auto/disk "$PRIMARYDISK" ;

I've seen people doing the above command, but I just get lsblk not found. Any ideas?

cn flag
Something to try: add the directory in front of `lsblk`?
Pierre ALBARÈDE avatar
sc flag
Try `which -a lsblk` to see if the binary exists and is in the path.
C.S.Cameron avatar
cn flag
Open Gnome Disks, it will show you visually which disk is which and how big, etc.
Score:0
jp flag

This worked using the 20.04 Ubuntu Server legacy installer

d-i partman/early_command string \
  PRIMARYDISK=/dev/$( X=$(cat /sys/block/sd?/size|sort -n|head -1); for i in /sys/block/sd?; do [ $X -eq $(cat $i/size) ] && echo $i | sed -e s#.*/## ; done ) ; \
  debconf-set partman-auto/disk "$PRIMARYDISK"

It uses the /sys filesystem to find the smallest disk. lsblk is not available in the installer environment.

I'm pretty sure you are using a command from an answer of mine that was based on the assumption that lsblk is available. That is because the comments referred to a blog post where lsblk was used in a similar way. It may be that lsblk used to be available in older releases, is available in Debian, or the blog is wrong.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.