So in my case I have a box with 2 drives 1 SSD small , usually 120 Gb and the rest bigger 500 or bigger, I need the OS always to be installed in the smallest drive and the second one to be left for data side.

Is there a way to detect the smallest drive and then do all there ?


  • While install process Question is asked to you to choose partitions, so you might use SSD as system drive (/) & bigger one to (/app or /opt or /home) depending or your needs. If you wiish to automate the installation you just do the same partition plan in the files. You identify disks & capacity from device informations sda/sdb/etc....
    – francois P
    Jan 19 at 10:58
  • Well that was the idea, to have all automated , so far it takes the biggest drive as OS and left one is left empty, so I needed to be separate drives separate partitions. while li found this d-i partman/early_command string \ PRIMARYDISK=$(lsblk -lbn --output SIZE,NAME | sort -n | tail -n 1 | cut -d" " -f2);\ debconf-set partman-auto/disk "$PRIMARYDISK"; as option this selects the biggest drive so opposite to what I need , then how do I get the smallest one ?
    – Aurelian
    Jan 19 at 11:02
  • I think it is about using partman-base templates: Template: partman/early_command it is Type: string the Description: for internal use; can be preseeded with a Shell command or commands to run immediately before partitioning
    – francois P
    Jan 19 at 13:15
  • I'm not sure I'm getting your comment, I know what that does, the issue is how to select the smallest drive, that's all rest all is taken care of . thanks
    – Aurelian
    Jan 19 at 14:46

To select the smallest drive you can use a preseed snippet like

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" ;

The command lsblk -Sn -o NAME --sort SIZE --include 8 | head -n 1 should select the smallest SCSI disk, but may need to be modified depending on the hardware.


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.