LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to mount read-only file system (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-mount-read-only-file-system-878134/)

eugeneg 05-01-2011 10:08 AM

How to mount read-only file system
 
I have a disk that came from an external drive which was dropped and doesn't mount when connected via USB. I removed the drive and connected it to a Windows PC which reports a GPT protected partition that can not be mounted. I therefore assume it was formatted in another OS.

I mounted it on a Linux Mint system and the disk is now readable. Some files/folders can be copied off the disk but most not. Some files can be opened on the original disk but still not copied to another device.

When I open a folder I see a cross in the bottom right corner of the folders I want to copy. I can then right click on and open as administrator and a new windows appears (with a red background). From there I can open a document - to read a .PDF for example, but when I try to drag it to a new location I get the error message "Error while copying. The file <name here> cannot be handled because you do not have permissions to read it".

If I right click on a file and select properties, permissions tab, then try to change 'others' access I get the error message "The permissions could not be changed. Sorry, Could not change the permissions of <file name>: Error setting permissions: read-only file system".

The same thing happens when I try to change ownership: :read-only file system". How can I get to copy files off this disk please ? My knowledge of Linux is very limited.

Jinouchi 05-01-2011 10:48 AM

If it says you dont have the proper permissions, that means you need to do it as root. I recommend using the command line if you're comfortable with it.

The cp command is the copy command:
Code:

cp target_file destination_folder
To do it as root, use the sudo command:
Code:

sudo cp target_file destination_folder
Hope this helps. Let me know how it goes.

eugeneg 05-01-2011 10:56 AM

Thanks for the reply. How do I get to the command line prompt ?
If I want to copy the entire contents of my disk to a folder on the desktop, how would I refer to those locations in the CP command please ?

Sjonnie48 05-01-2011 11:08 AM

You certainly have a program named 'terminal'. That's the command line. For an introduction read http://hacktux.com/bash/function

Jinouchi 05-01-2011 11:11 AM

Good questions. I'm not familiar with the distro of Linux you're using, but to get to the command prompt you need to find the Terminal or Terminal Emulator program. Once there, you need to know the path of your drive - it might be /media/sdb1 or /mnt/sdc1, for example. Once you know that, just

Code:

sudo cp -r /device/path/* /destination/folder/
-r tells it to copy recursivley - copying all subfolders - and the asterisk is a wildcard, which means, in this case, all files and folders on that device.

lisle2011 05-01-2011 11:39 AM

Copying a disk and changing permissions
 
If you don't really know how to get to a command line you probably have not added your user name to the /etc/sudoers.

If you know the root password you can also su in terminal window and that will do the same thing only your now very powerful so be careful.

And while you are the superuser edit /etc/sudoers and add your name using the visudo editor. Now you can use the sudo command.

Depending on the distribution you are using the file might be elsewhere such as sudoers.d so don't give up if you don't find it right away.

locate /sudoers
or
find /sudoers
should help

PTrenholme 05-01-2011 11:56 AM

If (as the message you reported in your first post suggested) the whole file system is mounted read only, even root will not be able to make any changes to the permissions. If you are in a terminal window, issue the command mount (with no arguments) to get a list of your currently mounted file systems. Look for the problem drive in the list, and verify the mount settings. If it says RO, then the command su -c 'mount -o remount,defaults /dev/sd[xn] /[place]' (where [xn] is the drive letter and partition number of the file system you're mounting, and [place] is the location at which you're mounting it) should remount the file system with read and write permissions.

Note that your drive may have incurred physical damage when it hit the floor which might make it impossible for you to recover some files. Have you tried running fsck on the (unmounted) drive? Warning: You should probably image the drive (use the ddrecover command) before running fsck so you have a "prior to messing" drive copy. In fact, you might be better off imaging the drive and using the image in your recovery efforts instead of the (damaged?) drive. If the drive has incurred physical damage, the damage may get worse every time you apply power to the drive. (For example, a bent drive head could be scraping the drive platter, filling the drive with magnetic "dust.")

eugeneg 05-01-2011 12:06 PM

I opened the the File Browser, right clicked the drive then mounted it. Then right clicked again and opened it in Terminal. I then entered the command
sudo cp -r * ~/Desktop
That seemed to work - thanks. I now have a copy on a disk I believe to be working properly.

Unfortunately the protections seem to have been copied also. If I open the folder into which the files were copied, many sub-folders have a cross on them. I right clicked one and opened as Administrator (red background). I was seemingly able to change the owner to me and the Access to read-write, but when I try to drag the file to the desktop I get the error "The file <file name> cannot be handled because you do not have permissions to read it". However, if I double click it (a .PDF file) I get to read it. Confusion.

My ultimate aim here is to copy all the files to a CD where they can be read by anyone on any computer.

eugeneg 05-01-2011 12:19 PM

PTrenholme, our posts crossed in the ether. I typed Mount and the first line is what I presume relates to the problem disk:
/dev/sda1 on / type ext4 (rw,errors=remount - ro)
When I copied the files there were two that caused errors but I don't care about those two.

Jinouchi 05-01-2011 01:19 PM

Good. Now that you have a copy on your desktop, you can do
Code:

cd ~/Desktop
sudo chmod -R 755 *

This will make all the files on your desktop readable by any user.

eugeneg 05-01-2011 03:34 PM

Jinouchi. THANK YOU very much.


All times are GMT -5. The time now is 07:33 PM.