LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-26-2013, 11:14 AM   #1
chriswade007
LQ Newbie
 
Registered: Jan 2013
Posts: 11

Rep: Reputation: Disabled
Remount readonly ntfs drive


Hi there,
I have a broken NTFS drive that i am trying to rescue using ddrescue.
In order for ddrescue to work i need to mount the drive as 'read only'

The drive has 1 partition and is /dev/sdg/
and i have created a mount point /mnt/windows

Could somebody tell me the syntax to remount this drive as read only?

Thanks for your help

Chris
 
Old 01-26-2013, 01:11 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Depends on whats wrong. It may not be possible to mount one read/write safely - it may require mounting and repair from a windows system.

If a windows system isn't available then your best bet may be to do a dd copy of the partition into a file, then mount the file by a loopback.
 
Old 01-26-2013, 01:38 PM   #3
chriswade007
LQ Newbie
 
Registered: Jan 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Hi there jpollard,
That dd copy idea sounds good to me
How would I do that?
 
Old 01-26-2013, 02:57 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
The simple way is "dd if=<device partition> of=<file on a disk large enough to hold the data> bs=<any reasonable size, even 1M is useful>"

Once the file is created you can try to mount it with "mount -t ntfs-ng <partition image file> /mnt". current mount versions should automatically create a loopback mount for the file.

The reason I put <device partition> and <partition image file> is that if you get an entire disk (rather than just the partition the filesystem is on), and that includes the partition table. At that point mounts get harder because you have to specify offsets into the file to get to the beginning of the filesystem (and that is a pain to figure out).

Once the partition image is mounted (or even before) you can work on it. I know the linux native filesystems mostly have a "fsck" that will work on image files - I'm not sure of them for NTFS, there is one, but I don't know how well it works. The nice thing about working with the file is that even if something goes badly wrong, you still have the original to work with. And if things go well and the filesystem gets repaired - you can do the same repair on the real parition.

It is just a way of CYA when things get nasty. It does mean that you have to have a filesystem that is large enough to hold the damaged data. This is the major downside- If you are trying to repair a 2 TB partition, you need one that is slightly larger than 2TB to hold all the data (reason is that copying a partition requires the data space the same size as the partition + any metadata needed for the filesystem containing the copy).

Last edited by jpollard; 01-26-2013 at 02:58 PM.
 
Old 01-26-2013, 03:29 PM   #5
chriswade007
LQ Newbie
 
Registered: Jan 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Thanks jpollard,
Firstly i must tell you that i dont fully understand what you've written.. i'm sorry.
From what i gather is it this:

1. We're going to copy the whole partition on to a drive that is bigger.
2. Then we're going to try to access the copied file and recover from that

My broken drive is 1tb and is /dev/sdg
My folder to put the copied partition is on a 2tb drive and is /media/MOVIES/recover

So for your first paragraph i would enter the syntax?:

sudo dd if=/dev/sdg 0f=/media/MOVIES/recover bs=1M

Is this correct ?

Thanks for again for the help..
 
Old 01-26-2013, 03:32 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
That looks right.

1TB is awfully large for a good NTFS filesystem. Does a windows boot ever access it?

Just noticed - you have a "0f" for the output file instead of "of".
 
Old 01-26-2013, 03:38 PM   #7
chriswade007
LQ Newbie
 
Registered: Jan 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
The drive is an external that was preformatted to NTFS, i just plugged it in started putting stuff there..

Now when you plug it in it recognises that the drive is there and gives you the first few folders.. but when you go in to the folders theres nothing in there. Where previously (before it broke) there was.
 
Old 01-26-2013, 03:42 PM   #8
chriswade007
LQ Newbie
 
Registered: Jan 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
OK ive put that syntax in:
sudo dd if=/dev/sdg 0f=/media/MOVIES/recover bs=1M

and it sais:'/media/MOVIES/recover': Is a directory

i dont think its done it as there isnt a file in the recover folder
 
Old 01-26-2013, 03:47 PM   #9
chriswade007
LQ Newbie
 
Registered: Jan 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
changed the syntax to of instead of 0f
 
Old 01-26-2013, 03:50 PM   #10
chriswade007
LQ Newbie
 
Registered: Jan 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
now reads:
sudo dd if=/dev/sdg of=/media/MOVIES/recover bs=1M

still sais: '/media/MOVIES/recover': Is a directory

Do i need to put the file name that it is recovering to or will it do that automatically?
 
Old 01-26-2013, 04:10 PM   #11
chriswade007
LQ Newbie
 
Registered: Jan 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
I've now added the rec.img to the syntax

sudo dd if=/dev/sdg of=/media/MOVIES/recover/rec.img bs=1M

on doing this i got

'/dev/sdg' : Input/output error

Thanks again for your help on this. These forums are fantastic for getting info to us newbies
 
Old 01-26-2013, 05:01 PM   #12
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
That looks like a dead drive.

Sorry about that.
 
Old 01-26-2013, 05:29 PM   #13
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Your original approach with using ddrescue was the better way for a broken disk. But you don't need to mount the partition at all for ddrescue, it will, like dd, work on the device descriptor.

Try it with
Code:
ddrescue /dev/sdg1 of=/media/MOVIES/recover/rec.img
 
Old 01-26-2013, 06:26 PM   #14
chriswade007
LQ Newbie
 
Registered: Jan 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
Hi there TobiSGD,
Just tried
ddrescue /dev/sdg1 of=/media/MOVIES/recover/rec.img

and it said Cant open output file "no such file or directory"

Then i removed the "of=" and now its doing stuff... (what does "of=" tell it to do?)

i'd best leave that for a few hours
 
Old 01-26-2013, 07:16 PM   #15
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Sorry, the of= was a mistake when copying/pasting your filenames, it does not work with ddrescue, only with dd.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how can i remount root filesystem as read/write after modify readonly-root file jcwkyl Linux - Newbie 3 12-21-2010 10:40 PM
Having to remount an external drive every day Zeno McDohl Linux - Hardware 10 09-01-2009 01:00 PM
NTFS (2.6.22.6) it says readonly file format. ganeshamutha@gmail.c Linux - Newbie 1 11-27-2007 01:29 AM
perm mount LAN ntfs share, have to remount on reboot daTerminehtor Linux - Newbie 8 07-12-2007 03:30 AM
Remount flash drive sutho1 Linux - Newbie 1 09-25-2003 09:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration