0

xattr worked on mac desktop system

but I want to let it work in mac recovery terminal

but xattr is not included in bash of terminal

I copy xattr to usb drive and run it on recovery terminal ,but it not working and tip :

/System/Library/Frameworks/Python.framework/Version/2.7/Resources/Python.app: bad interpreter: No such file or directory

How to solve this problem? Thank you !

3
  • 2
    Why do you want to run it? What are you trying to achieve?
    – mmmmmm
    Commented Feb 19, 2022 at 11:48
  • I want to change file's extended attributes on recovery Commented Feb 19, 2022 at 17:30
  • Which files? The current macOS really ties things down and I can't think of reasons to try this
    – mmmmmm
    Commented Feb 19, 2022 at 17:51

2 Answers 2

0

Note: This answer was also tested using High Sierra.

The macOS Recovery for newer versions of macOS do include the xattr command. Going back to Mavericks, I find that the xattr command is not included in OS X Recovery. However, if while booted to OS X Recovery for Mavericks, you have a working Mavericks installed, then you still can use the xattr command that was included with Mavericks. The image below was taken while booted to OS X Recovery for Mavericks. This image shows Mavericks is installed on the Macintosh HD volume.

starutp disk

The commands below were entered in a Terminal window while booted to OS X Recovery for Mavericks.

Below is the output from the echo $PATH command.

/usr/bin:/bin:/usr/sbin:/sbin

Below is the output from the ls /Volumes/Macintosh\ HD/usr/bin/xattr command.

/Volumes/Macintosh HD/usr/bin/xattr

So the xattr command would be in the search path for commands, if the colon‑separated list of directories output by echo $PATH were proceeded with /Volumes/Macintosh\ HD. As the OP has pointed out, other software (such as python) may need to be included in this path. This can be accomplished by proceeding the xattr command with the chroot command, as shown below.

chroot "/Volumes/Macintosh HD" xattr

In this case the chroot command changes its root directory to the supplied directory "/Volumes/Macintosh HD".

Example When Accessing a File in the Current Working Directory

If the current working directory contained the file test.txt, then the following command would not work. (Unless the current working directory was /Volumes/Macintosh HD.)

chroot "/Volumes/Macintosh HD" xattr -c test.txt

However, the following command would cause all attributes to be removed from the file test.txt.

chroot "/Volumes/Macintosh HD" xattr -c "$PWD/test.txt"

Using $PWD works in the above command, because /Volumes/Macintosh HD/Volumes/Macintosh HD is a symbolic link to /.

How to Remount When Necessary to Access One or More Files

Note: Any remounting only persists until the Mac restarts.

If one or more files to be accessed do not reside in the Mavericks startup volume, then the mount point for each of these other volumes will need to be moved to the Mavericks startup volume. For example, if the test.txt file is stored in the MyHFS volume instead of in the Macintosh HD volume, then you will need to remount the MyHFS volume. First, enter the command below to unmount the MyHFS volume.

diskutil unmount MyHFS

Example output is shown below.

Volume MyHFS on disk1s3 unmounted

Next, use the commands below to insure the new mount point exists in the Macintosh HD volume, then mount the MyHFS volume at that point. The identifier disk1s3 that is entered should be the same as shown in the above output.

mkdir -p /Volumes/Macintosh\ HD/Volumes/MyHFS
diskutil mount -mountpoint /Volumes/Macintosh\ HD/Volumes/MyHFS disk1s3

Example output is shown below.

Volume MyHFS on disk1s3 mounted

 

6
  • Thank you. I repect your work.But chroot "/Volumes/Macintosh HD" xattr -c "$PWD/test.txt" also not working , it can not find the test.txt which I put in the current dir. But chroot "/Volumes/Macintosh HD" xattr -h can list the help . Commented Feb 19, 2022 at 15:23
  • What is the value of the PWD variable? Commented Feb 19, 2022 at 15:26
  • My usb name is AAA, first I cd /Volumes/AAA, my test.txt file path is /Volumes/AAA/test.txt, $PWD variable is /Volumes/AAA, but no matter: chroot "/Volumes/Macintosh HD" xattr -c "$PWD/test.txt" or chroot "/Volumes/Macintosh HD" xattr -c /Volumes/AAA/test.txt not working,both of then say no that file Commented Feb 19, 2022 at 17:34
  • I made the assumption you would be only accessing files stored on the Mavericks startup volume. Since I now know you may access files on other volumes, I added the section "How to Remount When Necessary to Access One or More Files". Commented Feb 19, 2022 at 18:32
  • Great! I repect that,and It worked by the section.But unfortunately the usb volume is my app located and I can not move it. So I make a soft link on the /Volumes/Macintosh\ HD/Users/mac/Desktop/1.sh ,which link to /Volumes/AAA/test.txt , and I confirm the soft link is correct .But again,cannot find the file. I think the path in softlink is not worked after chroot,so Is there a good way to achieve the target ? Thank you ! Commented Feb 19, 2022 at 18:37
0

The xattr command has relied on the system-bundled python2. If you've copied the command for use in the recovery partition, it won't work, as the Recover Partition doesn't have python.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .