Find the answer to your Linux question:
Results 1 to 4 of 4
Please can I have some suggestions as to how one could determine (for use in a Bash or Python script) which device (eg /dev/sda1, /dev/hda1... etc) a ramfs was loaded ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! RobertF's Avatar
    Join Date
    Feb 2008
    Location
    Cape Town
    Posts
    19

    After USB boot, detect which device the ramfs was loaded from. Bash or Python


    Please can I have some suggestions as to how one could determine (for use in a Bash or Python script) which device (eg /dev/sda1, /dev/hda1... etc) a ramfs was loaded from when booting from a USB drive.

    I have a RIPLinux/Tinycore live USB disk that automatically needs to run a script that is stored on the same USB drive but not part of the RIPLinux/Tinycore image. (Please note that I do not want to put this script into the RIPLinux image.) I therefore would like to remix the RIPLinux/Tinycore ISO to automatically run this script once it has started up. After RIP linux has booted I would like to automatically mount the USB drive that RIPLinux/Tinycore was booted from. I need help detecting which device this is.

    Thanks in advance
    Last edited by RobertF; 09-22-2010 at 08:31 AM.

  2. #2
    Just Joined! RobertF's Avatar
    Join Date
    Feb 2008
    Location
    Cape Town
    Posts
    19
    So far my best solution is mounting each existing device and looking for the install script. If not found, then move on to the next device.

    Any better suggestions?

  3. #3
    Just Joined! RobertF's Avatar
    Join Date
    Feb 2008
    Location
    Cape Town
    Posts
    19
    Ok... Disk labels might work. Duh (hopefully)

  4. #4
    Just Joined! RobertF's Avatar
    Join Date
    Feb 2008
    Location
    Cape Town
    Posts
    19
    Right on gentoo, to create a labeled fat32 USB disk use sys-fs/mtools (install: #emerge mtools)

    To label the partition on the USB disk use command:
    #mlabel -i /dev/partition ::my_label

    Where partition is the partition name ie. sda1, hda1 etc that you want to label and my_label is the label you want to use for the partition.

    Now to mount the partition using the label instead of the device name use the following command:
    #mount /dev/disk/by-label/my_label /mnt/my_mountpoint

    Sorted, Problem solved. Please let me know if there is a better way of doing this.

Posting Permissions

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