Results 1 to 8 of 8

Thread: auto-mount /dev/xda1 at /somemountpoint on boot

  1. #1

    auto-mount /dev/xda1 at /somemountpoint on boot

    How do I grep to find /dev/first-drive-shown-on-the-desktop-probably-an-ntfs-volume and auto-mout it rw to /somemountpoint, no matter if it's an ntfs or fatxx filesystem?

  2. #2
    Senior Member registered user
    Join Date
    Jan 2005
    Location
    UK
    Posts
    282

    Re: auto-mount /dev/xda1 at /somemountpoint on boot

    Quote Originally Posted by unclecameron
    How do I grep to find /dev/first-drive-shown-on-the-desktop-probably-an-ntfs-volume and auto-mout it rw to /somemountpoint, no matter if it's an ntfs or fatxx filesystem?

    All file systems and hard drive partitions can be mounted automatically by knoppix just by clicking on them from the default kde desktop.

    The drives will be shown in partition order so first partition will be hda1 or sda1 depending on if your HD is IDE or SATA.

    With knoppx 5.1.1 and higher open a terminal and type:

    sudo fdisk -l

    (this will list all partitions on all hard drives).

  3. #3
    I'm attempting to make a script I'm running on boot do it, so I know knoppix finds the most likely candidate and lists it on the desktop, I need to grep that, then I can mount it in the script hopefully, or possibly having something automount it.

  4. #4
    Senior Member registered user
    Join Date
    Jan 2005
    Location
    UK
    Posts
    282
    Quote Originally Posted by unclecameron
    I'm attempting to make a script I'm running on boot do it, so I know knoppix finds the most likely candidate and lists it on the desktop, I need to grep that, then I can mount it in the script hopefully, or possibly having something automount it.
    Ok, I misread your question.

    In Kde autostart programs run from ~/.kde/Autostart

    this is where you can start your script:


    For starters someting like:

    #!/bin/sh
    cd /home/knoppix/Desktop
    ls | grep sd > drivelist
    # above line creates a list of drive from icons on desktop grep sd is for sata use hd for ide
    cat drivelist | while read line;
    do
    mount /dev/${line} -t ntfs /mnt/sda1
    # above line reads each entry in drivelist and mounts it, will need some work as it will fail if more than 1 drive detected
    done


    You'll need to modify this as it will fail if multiple drives detected, however if its always one partition like a C: drive it will alsmost always
    be the first partition so you may get away with simplifying the script.
    Im not much of a bash programmer so you may need to ask on a bash forum
    Hope that helps

  5. #5
    ok great, thanks, I'll hack together something based on what you posted

    I also found that knoppix puts the drives found on the end of fstab, so a typical setup detecting one ntfs, one ext3 and one swap (this my test box, no one would ever be doing this to an ext3/swap, but possibly a FAT16/32)
    Code:
    /proc      /proc       proc   rw,nosuid,nodev,noexec 0 0
    /sys       /sys        sysfs  rw,nosuid,nodev,noexec 0 0
    /dev/shm   /dev/shm    tmpfs  rw,nosuid,nodev,noexec 0 0
    /dev/pts   /dev/pts    devpts mode=0622           0 0
    /dev/fd0   /media/fd0  auto   user,noauto,exec,umask=000    0 0
    /dev/cdrom /media/cdrom  auto   user,noauto,exec,ro 0 0
    /dev/hdc /media/hdc  auto   users,noauto,exec,ro 0 0
    # Added by KNOPPIX
    /dev/sda1 /media/sda1 ntfs noauto,users,exec,umask=000,uid=knoppix,gid=knoppix 0 0
    # Added by KNOPPIX
    /dev/sda2 /media/sda2 ext3 noauto,users,exec 0 0
    # Added by KNOPPIX
    /dev/sda3 none swap defaults 0 0
    so I have to figure out how to write a loop to grep for "# Added by KNOPPIX", then cut the 1st 9 characters off the next line and mount that, then repeat. I'm guessing I can just use mount $somevariable /mountlocation and knoppix will detect the fs type, that would make it a bit simpler. I know there are a number of ways to do this type of a loop, not sure what would be the simplest...

  6. #6
    ok, I have done this, and it ALMOST works

    Code:
    #!/bin/bash
    #find the "# Added by KNOPPIX" line
    grep -A 1 "KNOPPIX" /etc/fstab | grep dev | cut -c1-9 > drivelist
    # read a line at a time
    cat drivelist | while read line;
    do
            # increment a variable for sequential mount points
            let "a += 1"
            # make mountpoint
            mkdir -p "/scanmount/drive"$a
            # now mount that drive
            mount ${line} /scanmount/drive$a
    done
    the problem is knoppix needs a filesystem type, so now I have to get it to search the same file/line for the characters between the 2nd and 3rd blank space on the same line...

    I wonder if there's simpler way to just get Knoppix to automount them, rather than listing noauto in fstab?

  7. #7
    Senior Member registered user
    Join Date
    Jan 2005
    Location
    UK
    Posts
    282
    Quote Originally Posted by unclecameron
    ok, I have done this, and it ALMOST works

    Code:
    #!/bin/bash
    #find the "# Added by KNOPPIX" line
    grep -A 1 "KNOPPIX" /etc/fstab | grep dev | cut -c1-9 > drivelist
    # read a line at a time
    cat drivelist | while read line;
    do
            # increment a variable for sequential mount points
            let "a += 1"
            # make mountpoint
            mkdir -p "/scanmount/drive"$a
            # now mount that drive
            mount ${line} /scanmount/drive$a
    done
    the problem is knoppix needs a filesystem type, so now I have to get it to search the same file/line for the characters between the 2nd and 3rd blank space on the same line...

    I wonder if there's simpler way to just get Knoppix to automount them, rather than listing noauto in fstab?

    There probably is, this may work, automount every first and second partition, I've only shown sata drives but you'll get the idea.

    #!/bin/bash
    mkdir /mnt/winxp
    mkdir /mnt/winxp2
    mount -rw /dev/sda1 /mnt/winxp -t ntfs 2 > /dev/null
    mount -rw /dev/sda2 /mnt/winxp -t ntfs 2 > /dev/null

    You would have to install ntfs-3g to have read write permissions and extend the script
    If the partition does not exist standard error is just redirected to /dev/null

    You could even add it as a startup script to your run level and include it in
    /etc/rc5.d/ or whatever runlevel youre starting at.

  8. #8
    Ok, I got it to work
    Code:
    #!/bin/bash
    
    # find the "# Added by KNOPPIX" line
    # and pipe the output to a loop
    sed -n '/^\s*#/{N;s/^#.*\n//p}' /etc/fstab \
    | while read device mountpoint filesystem options junk
    # now we have a list of our mount information
    do
        while [ "$filesystem" = "ntfs" ]
            do
            # increment drive mount variable
            let "a += 1"
            # make the sequential mount location
            mkdir -p "/scanmount/drive"$a
            # now mount that drive at the dir we just made
            mount $device -t $filesystem "/scanmount/drive"$a
            # reset filesystem variable
            filesystem="1"
            done
        while [ "$filesystem" = "fat32" ]
            do
            # increment drive mount variable
            let "a += 1"
            # make the sequential mount location
            mkdir -p "/scanmount/drive"$a
            # now mount that drive at the dir we just made
            mount $device -t $filesystem "/scanmount/drive"$a
            # reset filesystem variable
            filesystem="1"    
            done
        while [ "$filesystem" = "fat16" ]
            do
            # increment drive mount variable
            let "a += 1"
            # make the sequential mount location
            mkdir -p "/scanmount/drive"$a
            # now mount that drive at the dir we just made
            mount $device -t $filesystem "/scanmount/drive"$a
            # reset filesystem variable
            filesystem="1"
            done
    done
    though my nested while loops could probably be improved Thanks for all the help!

Similar Threads

  1. Auto mount persistant image on boot
    By luka in forum Hardware & Booting
    Replies: 2
    Last Post: 07-23-2008, 03:48 PM
  2. basic auto mount question
    By A. Jorge Garcia in forum General Support
    Replies: 10
    Last Post: 02-28-2006, 11:13 PM
  3. Auto Mount?
    By cfish in forum Hdd Install / Debian / Apt
    Replies: 6
    Last Post: 03-26-2005, 02:04 AM
  4. Auto Mount after booting from CD
    By mahdi in forum General Support
    Replies: 3
    Last Post: 04-18-2004, 07:50 PM
  5. How do I auto mount HD partitions durring Knoppix boot?
    By audioaficionado in forum Customising & Remastering
    Replies: 0
    Last Post: 03-29-2003, 06:50 AM

Posting Permissions

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


INTEL XEON E5-2680V4 SR2N7 2.40GHZ CPU picture

INTEL XEON E5-2680V4 SR2N7 2.40GHZ CPU

$11.00



Dell EMC PowerEdge R440 Xeon silver 4215 2.5GHz 16 GB ram  2x 550W PSU No HDD picture

Dell EMC PowerEdge R440 Xeon silver 4215 2.5GHz 16 GB ram 2x 550W PSU No HDD

$275.00



Dell Precision Tower 7810 Xeon E5-2630 v3 @ 2.40GHz , 32GB Ram, NO HDD, NO OS picture

Dell Precision Tower 7810 Xeon E5-2630 v3 @ 2.40GHz , 32GB Ram, NO HDD, NO OS

$239.99



Dell PowerEdge FX2s + 8x FC430 Blades 16x E5-2630v4 160 Cores Rails No PSU/RAM picture

Dell PowerEdge FX2s + 8x FC430 Blades 16x E5-2630v4 160 Cores Rails No PSU/RAM

$699.00



Dell Precision T5820 Workstation 3.70GHz W-2135 No RAM/ GPU/ HDD/ OS picture

Dell Precision T5820 Workstation 3.70GHz W-2135 No RAM/ GPU/ HDD/ OS

$179.98



Dell Precision T7820 2x Xeon Silver 4114 2.20GHz 950W No RAM GPU HDD 4x SATA picture

Dell Precision T7820 2x Xeon Silver 4114 2.20GHz 950W No RAM GPU HDD 4x SATA

$350.48



Intel Xeon E5-2699 V4 2.20GHz 55M 22-CORES LGA2011-3 Server Processor 145W SR2JS picture

Intel Xeon E5-2699 V4 2.20GHz 55M 22-CORES LGA2011-3 Server Processor 145W SR2JS

$84.49



Matched Pair _ Intel Xeon E5-2698 V4 2.2GHz 20-Core Processor CPU LGA2011 SR2JW picture

Matched Pair _ Intel Xeon E5-2698 V4 2.2GHz 20-Core Processor CPU LGA2011 SR2JW

$94.99



DELL Precision T3420 | Xeon 1240v6 | 525GB SSD |16GB RAM |Nvidia GPU |Win11 picture

DELL Precision T3420 | Xeon 1240v6 | 525GB SSD |16GB RAM |Nvidia GPU |Win11

$149.00



Dell Precision T1700 Workstation Intel Xeon 16G Ram 256GG SSD Nvidia 600  Win 10 picture

Dell Precision T1700 Workstation Intel Xeon 16G Ram 256GG SSD Nvidia 600 Win 10

$109.99