coreos / coreos-installer

Installer for CoreOS disk images
https://coreos.github.io/coreos-installer/
Apache License 2.0
222 stars 93 forks source link

/dev/sda device is in use in bare-metal server #261

Closed majorinche closed 4 years ago

majorinche commented 4 years ago

try to install fcos by pxe in bare-metal server, but meet the error, like

checking for exclusive access to /dev/sda caused by: couldn't reread partition table: device is in use

other information: pxelinux.cfg is: DEFAULT pxeboot TIMEOUT 20 PROMPT 0 LABEL pxeboot KERNEL fedora-coreos-31.20200505.3.0-live-kernel-x86_64 APPEND ip=dhcp rd.neednet=1 initrd=fedora-coreos-31.20200505.3.0-live-initramfs.x86_64.img coreos.inst=yes coreos.inst.ignition_url=http://10.30.0.109/example.ign coreos.inst.image_url=http://10.30.0.109/fedora-coreos-31.20200505.3.0-metal.x86_64.raw.xz coreos.inst.install_dev=/dev/sda coreos.inst.insecure=yes IPAPPEND 2

kkeng11235 commented 4 years ago

Same issue with iso boot live image. Both fedora-coreos-31.20200517.3.0-live.x86_64.iso & fedora-coreos-32.20200601.3.0-live.x86_64.iso using CLI to initiate, and kernel line args

jlebon commented 4 years ago

Can one of you print the full output from coreos-installer? Specifically, does this error happen at the end of the install or at the start?

kkeng11235 commented 4 years ago

The full output I get is this:

Error: checking for exclusive access to /dev/sda Caused by: couldn't reread partition table: device is in use Caused by: EBUSY: Device or resource busy

This comes up a few seconds after: curl -O http://X.X.X.X:8000/example.ign sudo coreos-installer install /dev/sda -i example.ign

bgilbert commented 4 years ago

Could you drop the coreos.inst=yes and coreos.inst.image_url arguments, boot to a prompt (easier with the ISO image), and check /proc/mounts and /proc/swaps for partitions on /dev/sda? The output of sgdisk -p /dev/sda would also be helpful.

kkeng11235 commented 4 years ago

Nothing to /dev/sda on /proc/mounts Nothing in /proc/swaps

Here is sudo sgdisk -p /dev/sda

Disk /dev/sda: 234441648 sectors, 111.8 GiB Model: KINGSTON SV300S3 Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): B6F22F01-F3E7-41F2-9AED-8613426CA213 Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 234441614 Partitions will be aligned on 2048-sector boundaries Total free space is 2452333 sectors (1.2 GiB)

Number Start (sector) End (sector) Size Code Name 1 2048 1230847 600.0 MiB EF00 EFI System Partition 2 1230848 3327999 1024.0 MiB 8300 3 3328000 231991295 109.0 GiB 8E00

bgilbert commented 4 years ago

3 3328000 231991295 109.0 GiB 8E00

Aha! Your disk has an LVM physical volume. What does sudo lvs say?

bgilbert commented 4 years ago

It turns out that Linux MD partitions and LVM PVs are automatically run at startup, which interferes with coreos.inst.

bgilbert commented 4 years ago

Thanks for the report. This should be fixed by https://github.com/coreos/coreos-installer/pull/276.

MarkIannucci commented 4 years ago

@bgilbert , I'm bumping up against this as well with my bare metal install on an old laptop. Are you aware of a workaround that I can use to get past this issue?

bgilbert commented 4 years ago

@MarkIannucci If you're doing a one-off install, it's easiest to work around this by hand:

  1. Boot the live image without any coreos.inst options
  2. sudo mdadm --stop /dev/mdXXX for each mdXXX listed in /proc/mdstat
  3. sudo vgchange -an XXX for each VG listed in sudo vgs
  4. curl -o config.ign <ignition_config_url>
  5. sudo coreos-installer install <target-device> -i config.ign <other-args>