können sparsebundles gesperrt werden, damit sie schreibgeschützt sind?

2818
noop

Bei Sparseimage-Dateien kann ich das Locked-Attribut in 'Get Info' festlegen, um zu verhindern, dass der Inhalt geändert wird. Mit sparsebundles zu tun hat scheinbar keine Wirkung.

Im Moment speichere ich mein Sparsebundle in einem Sparseimage, um diese Easy-Lock-Funktion zu erhalten.

Übersehe ich einen einfacheren Weg, um mein Sparsebundle-Volume nur lesbar zu machen?

5

1 Antwort auf die Frage

5
Daniel Beck

It seems Finder does not apply the Locked flag (or permission changes in the Get Info dialog for that matter) recursively for the entire bundle. If this is something you regularly need, you might want to look into writing a service for the following suggestions, so you can do this from Finder instead of the Terminal.


You can remove write permissions to the bundle on the command line by running chmod:

chmod -R a-w 

Type this command (including a trailing space character), then drag the icon for the sparse bundle onto the Terminal window. It should look like this, depending on the name of your sparse bundle and where it's stored:

chmod -R a-w /path/to/container.sparsebundle 

Run chmod -R u+w /path/to/container.sparsebundle to get write permissions again. These commands may take a while for large sparse bundles.


Alternatively, you can set the locked flag on all files in the bundle by running the command chflags:

chflags -R uimmutable /path/to/container.sparsebundle 

To revert, run chflags -R nouimmutable /path/to/container.sparsebundle.


You can always mount the bundle read-only as well, to only temporarily prevent changes. To do this, run the following in Terminal:

hdiutil attach /path/to/container.sparsebundle -readonly 

Note that you will need to always mount it like this to prevent changes.


If you can tolerate the image using a different mount point than usual, you can run configure your system to always mount this image read-only.

First, determine the volume UUID. Mount the sparse bundle, and run diskutil list on the command line. Look for an entry with the same name as your volume, like the following:

/dev/disk8 #: TYPE NAME SIZE IDENTIFIER 0: Apple_partition_scheme *102.4 MB disk8 1: Apple_partition_map 32.3 KB disk8s1 2: Apple_HFS Disk Image 102.4 MB disk8s2 

In this example, the volume shows up as "Disk Image" in Finder. Note the identifier on the right (disk8s2). You need to enter it for the following command after /dev/:

diskutil info /dev/disk8s2 

Look for the line that starts with Volume UUID, and note the value to its right, e.g. D7C6180C-2178-32EF-98E6-7FB71AED2ABC

Now we just need to create a custom mount point. Usually, every volume is mounted in /Volumes, but those mount points are deleted when unmounting, and the next mounting attempt of a volume referenced in fstab will fail because the mount point doesn't exist. So just create a folder named "Image" in your home directory.

Now we can OS X to always mount it read-only. In Terminal, run sudo vifs and enter your password. I assume you're familiar enough with vi/vim, if not, now's a good time to read up on it.

Add a line like the following, substituting the correct values for UUID and mount point applicable to your system:

UUID=D7C6180C-2178-32EF-98E6-7FB71AED2A56 /Users/danielbeck/Image hfs ro 

Then save and close. Now you can mount the image with a double-click, it will show up in Finder, and will be read-only.

Wow, danke für diese ausführliche Antwort! Was halten Sie grundsätzlich davon, dass ich das Sparsebundle in einer Sparseimage aufbewahrt habe, die ich abschließen kann? Ich verwende ein sparsebundle, damit ich inkrementell Änderungen an einem vernetzten Volume sichern kann. Gibt es eine Gefahr, die ich dabei übersehe? noop vor 11 Jahren 0
@noop Dies hängt von Ihrem Anwendungsfall ab. Es gibt möglicherweise Probleme mit der CPU-Auslastung, da Sie statt zwei Schichten von virtuellen Festplatten durchlaufen. Darüber hinaus müssen Sie sicherstellen, dass das spärliche Bild immer in Bezug auf die Größenbeschränkung (und die zugehörige Partitionszuordnung, wenn Sie> 2 TB gehen) beim Ändern des spärlichen Bündelinhalts dem Bündel entspricht. Wenn Sie den Bildinhalt häufig ändern, ist das Komprimieren (dh das Wiederherstellen von Speicherplatz, der derzeit im spärlichen Bündel nicht verwendet wird) aufgrund der verschachtelten Natur Ihrer Lösung mehr Aufwand. Daniel Beck vor 11 Jahren 0
ich kann mich jetzt nicht entscheiden, ob ich mit sparseimage / sparsebundle fortfahren oder hdiutil -readonly verwenden möchte. trotzdem danke für eure einsichten. noop vor 11 Jahren 0