Ubuntu automount NTFS partition

Posted on 2010-01-06
Last Modified: 2013-12-26
I am trying to get to write a bash script which will find the ntfs partition and it will put it on fstab without intervention. I need help with my script, I get the following errors:

./ line 7: syntax error near unexpected token `;'
./ line 7: `cat /tmp/ntfs| while read line;do; '

Thanx for your help


fdisk -l | grep NTFS | awk '{print $1}' >> /tmp/ntfs

cat /tmp/ntfs| while read line;do; 

echo `$line    /mnt/ntfs	ntfs-3g defaults,locale=en_US.utf8 0 0` >> ntfs.fstab;


Open in new window

Question by:dpoper1
    LVL 3

    Expert Comment

    you dont need the ; after the do - just remove it
    LVL 23

    Accepted Solution

    Shorter version, without additional while loop:
    fdisk -l | awk '/NTFS/ {printf "%s\t/mnt/ntfs\tntfs-3g defaults,locale=en_US.utf8 0 0\n", $1}' >> ntfs.fstab

    Open in new window


    Author Closing Comment


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now