2

I'm running the CentOS 7.6 installer from a USB thumb drive using a kickstart file. I'm installing to a system that has only one disk.

In the bash shell of the installer, my system's hard drive shows up as /dev/sdb. The installer sees the USB drive it booted from as /dev/sda. Should I be telling Anaconda to use /dev/sdb? Seems like a bad idea.

mr.zog
  • 923
  • 3
  • 20
  • 39
  • 1
    Use one of the paths on /dev/disk/by-* or just don't tell it any drive at all. IIRC you could also say "use all drives" which would leave removable devices out. – Andreas Rogge May 04 '19 at 20:22
  • I won't know anything about the target disk until the kickstart is run. I'm creating an installer that will be used by field techs at customer data centers. Maybe kickstart understands blkid output. Perhaps I shud use UUIDs. – mr.zog May 04 '19 at 20:36
  • So that's probably where either the field tech needs to decide or you'll just end up with "I don't care, just use anything you find"-mode – Andreas Rogge May 04 '19 at 20:44
  • They need to preserve the /home logical volume. That's all that matters. – mr.zog May 04 '19 at 20:58
  • if you don't know the status of the system beforehand: good luck. You could implement a %pre script that generates your drive/filesystem configuration. But that's not going to be a simple task. – Andreas Rogge May 04 '19 at 21:00
  • I do not know the state of the systems; that's the problem. All I really know is the name of the volume group and that the system disk is needlessly big, something like 100GB. – mr.zog May 04 '19 at 22:09
  • So I am using %pre to back up /etc but it turns out I cannot get any of the variables I have declared in %pre to be understood by Anaconda. Example: `ROOTVOL=$(lvdisplay |grep root | grep Path | awk '{print $3}')` – mr.zog May 06 '19 at 02:41
  • @asktyagi Your comment is completely irrelevant. – mr.zog May 06 '19 at 03:33
  • Sorry was pasted on wrong thread. – asktyagi May 06 '19 at 03:38
  • That's correct, %pre runs in another context so it cannot leak variables. It can write files though and anaconda could then use these. The usual mode of operation is that %pre writes the disk partitioning information and this is then included later. I just cannot remember how this was done exactly, sorry. There docs on that here https://projects.theforeman.org/projects/foreman/wiki/Dynamic_disk_partitioning and you should be able to find out how to do it by digging somewhat deeper into the foreman kickstart templates. – Andreas Rogge May 06 '19 at 05:24
  • The disk is already partitioned. – mr.zog May 06 '19 at 11:23

1 Answers1

0

You cannot use /dev/sda /dev/sdb in there because you have no idea what your kernel is going to identify your disks as. same machine booted twice could show the same disk with a different dev name.

The only efficient current way to install linux that way would be to specify either a UUID or a LABEL for the disk that you are installing (or customize the installation)

The solution is somewhat described at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-anaconda-boot-options#list-boot-options-sources

basically with either UUID=(uuid of your USB drive) or LABEL=(the label of your usb drive) You're gonna need to refer to your stage2/repo and where to find the ks file this way(you didn't ask info about your cmd append line, so I skip this)

In your kickstart you call it this way

    install
    harddrive --partition=LABEL=YOURUSBLABEL --dir=/

assuming your USB is labelled as YOURUSBLABEL and your repo is in /

Additionally FYI:

IF you're installing this via USB always, in your kickstart add:

    ignoredisk --drives=/dev/disk/by-path/*usb*

so you avoid wiping your usb drive by accident. But this will throw an error with anaconda if you don't have any USB inserted, there's going to be a --nonfatal that's going to be added soon into it, but I'm not sure of when... so until then only use it IF you're installing only via USB or if you have other possible USB in the machine that you don't want wiped.

MatteoBee
  • 116
  • 4