I want to delete a particular directory in a read only file system. How do I mount its parent directory in read/write mode, so that I can delete that? I've tried several things with googling, but could not succeed. For some methods it says block device required
.
Mount a directory in read only filesystem to read write
mountunix
Related Solutions
On an ext4 filesystem (like ext2, ext3, and most other unix-originating filesystems), the effective file permissions don't depend on who mounted the filesystem or on mount options, only on the metadata stored within the filesystem.
With Ubuntu, mounting should happen automatically when you insert the disk, or you should be able to click on an icon to mount. You can also install pmount
to mount filesystems as an ordinary user from the command line.
If you have a removable filesystem that uses different user IDs from your system, you can use bindfs
(in the Ubuntu package of the same name) to provide a view of any filesystem with different ownership or permissions. The removable filesystem must be mounted already, e.g. on /media/disk9
; then, if you want to appear as the owner of all files, you can run
mkdir ~/disk9
sudo bindfs -u $(id -u) -g $(id -g) /media/disk9 ~/disk9
Windows supports drive mountpoints too (Microsoft calls them "reparse points", but the concept is the same). Since you are more familiar with Windows than with *NIX operating systems, here's a little experiment you can perform in Windows to help you understand the concept:
- Insert a USB flash drive into your computer.
- Create a new, empty folder on your desktop.
- Open up the Disk Management console, right-click your flash drive, and select
Change Drive Letters and Paths...
- In the dialog that comes up, hit the
Add...
button. - Make sure the
Mount in the following empty NTFS folder:
button is selected, and browse to the path of that folder you created on your desktop (e.g.C:\Users\<your profile>\Desktop\New Folder
) - Hit OK and OK. Now check out your desktop. You will see that the folder you created has a drive shortcut icon:
If you look at it from a command prompt window, you will see it as a <JUNCTION>
object type:
Note that your flash drive now has two mount points; E:
(or whatever) and that folder you created in step 2. You can remove the drive letter if you want, and you will still be able to copy files to/from it through the folder on your desktop. You can even add multiple drive letters for it if you want. This is what a mount point is: It's simply a path for you to access your drives/partitions.
Unlike Linux, Windows is representing this folder to you as some kind of oddball shortcut. Windows does this because mountpoints are a bit of a strange concept in Microsoft's world (hence your confusion). They don't even work properly in a lot of cases. But in *NIX operating systems, this is just the way things are done. A directory can be either a folder or a mountpoint in Linux, and most of the time the distinction between the two doesn't matter.
*NIX operating systems do not have a concept of drive letters. Your "root" filesystem (/
) is always at the top of the tree, and is (usually but not always) mounted as your system's boot drive. This is what C:\
is to Windows. There can only ever be one root (just like there can only be one C:
drive). Every other drive or partition on your system must be mounted to a path (directory) under this root. So, what would be D:
or E:
in Windows would be /mnt/D_Drive
, /media/cdrom
, or even /var
, /home
, or whatever in Linux.
Now this is an important thing, and is a big source of your confusion:
A device node is not the same thing as a mountpoint. Both Windows and Linux have device nodes. The difference is that Windows never shows them to you, and they do not exist as files on your hard drive the way they do in Linux.
In the command prompt screenshot above, you'll notice that the folder you created is listed as \??\Volume{GUID}\
. In both Linux and Windows the raw device itself has a device node (e.g. /dev/sda1
in Linux or \??\Volume{GUID}
in Windows). The mountpoint is the filesystem on that device. In Windows, you can think of drive letters (E:\
for example) as mountpoints for your drives/partitions. The only difference is that Windows never shows you the \??\Volume{GUID}
device node. It only shows you mountpoints, and those mountpoints are almost always drive letters (but, as we see from the experiment above, don't have to be).
I hope this clears things up for you.
Now, go back into Disk Management and delete that mountpoint before you accidentally do something stupid, like trying to copy/move it somewhere! :-)
Best Answer
I suppose you would like to remount the
/usr
file system read-write:Just change
/usr
above by the mount point you would like to remount.