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
  •  


OPNsense pfSense 8-Core Atom C3758 2.2GHz 8GB DDR4 64GB SSD 8x NIC QAT AES VPN picture

OPNsense pfSense 8-Core Atom C3758 2.2GHz 8GB DDR4 64GB SSD 8x NIC QAT AES VPN

$145.00



OPNsense Firewall 16-Core Atom C3958 16GB DDR4 RAM 64GB SSD 8x 1Gbe QAT AES-NI picture

OPNsense Firewall 16-Core Atom C3958 16GB DDR4 RAM 64GB SSD 8x 1Gbe QAT AES-NI

$195.00



SonicWall TZ280 Firewall 03-SSC-6933 Advanced Edition 3YR NEW SEALED picture

SonicWall TZ280 Firewall 03-SSC-6933 Advanced Edition 3YR NEW SEALED

$999.99



VMware SD-WAN Edge 640N VeloCloud Dell E42W EnterpriseFirewall 32GB picture

VMware SD-WAN Edge 640N VeloCloud Dell E42W EnterpriseFirewall 32GB

$127.50



HP 2x 10GB OPNsense Quad Core i5-8500 8GB RAM 3Port Gigabit Firewall AES-NI SSD picture

HP 2x 10GB OPNsense Quad Core i5-8500 8GB RAM 3Port Gigabit Firewall AES-NI SSD

$199.95



Firewalla Purple Firewall Preinstalled w/ Power Adapter & Ethernet Cable picture

Firewalla Purple Firewall Preinstalled w/ Power Adapter & Ethernet Cable

$150.00



OPNsense pfSense 16-Core Atom C3958 16GB ECC RAM 512GB SSD 8-Port QAT AES-NI VPN picture

OPNsense pfSense 16-Core Atom C3958 16GB ECC RAM 512GB SSD 8-Port QAT AES-NI VPN

$258.00



Fortinet FortiGate 60F FG-60F UTM UTP License Until 2027 Network Security FW VPN picture

Fortinet FortiGate 60F FG-60F UTM UTP License Until 2027 Network Security FW VPN

$219.99



Zero Trace Pen: All-in-one Tor Network Anonymous Drive + Cryptocurrency Wallet picture

Zero Trace Pen: All-in-one Tor Network Anonymous Drive + Cryptocurrency Wallet

$147.00



Barracuda NextGen CloudGen Cloud Based Firewall F280 BNGF280a w/ 8.3.1 Firmware picture

Barracuda NextGen CloudGen Cloud Based Firewall F280 BNGF280a w/ 8.3.1 Firmware

$89.99