Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I am developing (in bash) a script that will install Linux from a clean system. I am using syslinux to boot a media where the script and its packages ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2010
    Location
    Brazil
    Posts
    7

    Install script must find hard disk


    Hi,

    I am developing (in bash) a script that will install Linux from a clean system. I am using syslinux to boot a media where the script and its packages are stored. The destination hard disk was hard coded as /dev/sda which worked until now.

    I am booting from a usb pendrive and don't know how to tell which /dev/sd* is the hard disk.

    So far the best idea that I have is to look in /sys/block/sd*/removable. If the value is 1, I assume that it is a pendrive.

    Does anyone know a better approach?
    Thanks in advance.

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    477
    welcome to the forum

    something like this might help

    fdisk -l | sed -n '2p' | cut -d" " -f2 | sed s/://
    the sun is new every day (heraclitus)

  3. #3
    Just Joined!
    Join Date
    Feb 2010
    Location
    Brazil
    Posts
    7
    Thanks for the welcome and for the reply.

    The solution is simpler than I thought. However, is there any guarantee that hard disks will be always the first "sd*"? Is udev responsible for this assignment?

    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •