Jump to content

Change

Welcome to We Got Served Forums

Welcome to We Got Served Forums, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be a part of We Got Served Forums by signing in or creating an account.
  • Start new topics and reply to others
  • Download Windows Home Server add-ins
  • Less ads to entertain you
  • Subscribe to topics and forums to get automatic updates
  • Get your own profile and make new friends
  • Customize your experience here

Fix For Read-Only Sparsebundles


2 replies to this topic

#1
SJ_UnderWater

    Advanced Member

  • Members
  • PipPipPip
  • 324 posts
  • Gender:Male
  • Location:Boston, MA
Contributor
After my own experience with a read-only sparsebundle, I'm posting a preliminary script for users with the same issue. At the moment this is in bash-script format, though hopefully I'll have time to convert it into a friendlier Applescript form soon.
Save the script as a *.sh file, add execute permissions (chmod u+x <file>.sh), then mount your sparsebundle location. In Terminal, type "cd " then drag the folder containing your sparsebundle into the Terminal window, resulting in "cd <path to bundle>", and press enter. Now drag the script file into the window, and press enter again.
The script should begin, checking the bundle for common problems, but halting on error. I do not make any promises with this script, use at your own discretion.
#!/bin/bash
set -e
sprs=`ls -d *.sparsebundle 2>/dev/null | head -1`
if [ ! $sprs ]; then echo "No sparsebundle found&#8230;exiting";exit 1;fi
echo -n "Making metadata changes..."
chflags nouchg $sprs/token
defaults write $PWD/$sprs/com.apple.TimeMachine.MachineID VerificationState -int 0
defaults delete $PWD/$sprs/com.apple.TimeMachine.MachineID RecoveryBackupDeclinedDate
echo "Done"
echo -n "Soft-mounting bundle..."
disks=`hdiutil attach -nomount -noverify -noautofsck $sprs | awk '{print $1}'`
disk=`echo $disks | awk '{print $1}'`
echo -n "Done"
echo "Starting Disk Repair as root..."
sudo fsck_hfs -df /dev/$disk's2'
echo -n "Detaching..."
hdiutil detach $disk
echo "Done"
echo "Script Complete"

--edit
The Applescript
try
    display dialog "This script will prompt you for the sparsebundle location, then open a new TextEdit document with \"live\" output. Do not close it until the script is complete. You will be prompted for the administrator password for repairs." with icon stop
on error
    return
end try
set mount to POSIX path of (choose file of type "com.apple.disk-image-sparse-bundle" with prompt "Select the affected sparsebundle")
set dname to "Repair Output " & (do shell script "date +%Y%m%d%H%M%S")
tell application "System Events" to set runs to (name of processes) contains "TextEdit"
tell application "TextEdit"
    activate
    if runs then
        set doc to make new document with properties {name:dname}
    else
        set name of first document to dname
        set doc to first document
    end if
end tell
set dname to quoted form of dname
append(doc, "Processing " & mount)
set mount to quoted form of mount
append(doc, "Turning off TimeMachine: " & (do shell script "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup -bool no 2>&1" with administrator privileges))
append(doc, "Making Metadata changes...")
append(doc, "chflags: " & (do shell script "chflags nouchg " & mount & " " & mount & "token 2>&1"))
append(doc, "VerificationState: " & (do shell script "defaults write " & mount & "com.apple.TimeMachine.MachineID VerificationState -int 0 2>&1"))
append(doc, "RecoveryBackupDeclinedDate: " & (do shell script "defaults delete " & mount & "com.apple.TimeMachine.MachineID RecoveryBackupDeclinedDate 2>&1 || true"))
append(doc, "Soft-mounting bundle...")
set disks to do shell script "hdiutil attach -nomount -noverify -noautofsck " & mount & " 2>&1"
append(doc, disks)
activate
append(doc, "Stopping autofsck: " & (do shell script "killall fsck_hfs 2>&1 || true" with administrator privileges))
set disks to quoted form of (do shell script "echo " & quoted form of disks & " | awk '{print $1}'")
set disk to quoted form of (do shell script "echo " & disks & " | awk '{print $1}'")
append(doc, "Starting Disk Repair as root...")
do shell script "dname=" & dname & ";osascript -e \"tell application \\\"TextEdit\\\" to activate\";fsck_hfs -gdf " & disk & "s2 2>&1 | while read line; do line=`echo $line|cut -f2 -d\\\"|tr -d \"()\"`;osascript -e \"tell application \\\"TextEdit\\\" to make new paragraph at end of (get first document whose name is \\\"$dname\\\") with data \\\"$line\\\"&return\";done" with administrator privileges
append(doc, "Detaching...")
append(doc, do shell script "hdiutil detach " & disk & " 2>&1")
append(doc, "Renaming: " & (do shell script "mount=" & mount & ";mount1=`echo $mount | perl -p -e \"s/_\\d{4}-\\d{2}-\\d{2}-\\d{6}//\"`;if [ \"$mount\" != \"$mount1\" ]; then mv $mount $mount1;fi"))
append(doc, "Turning on TimeMachine: " & (do shell script "defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup -bool yes 2>&1" with administrator privileges))
tell application "TextEdit" to make new paragraph at end of doc with data "Script Complete"
on append(doc1, txt1)
    tell application "TextEdit" to make new paragraph at end of doc1 with data txt1 & return
end append



Upgrade to a WGS Supporter Account to remove this ad.

#2
SJ_UnderWater

    Advanced Member

  • Members
  • PipPipPip
  • 324 posts
  • Gender:Male
  • Location:Boston, MA
Contributor
it turns out that even with "-noverify -noautofsck" hdiutil will still launch fsck_hfs when soft-mounting, so i've added another line to kill that process immediately, allowing the new fsck_hfs process's output to be piped to the TextEdit document.

#3
SJ_UnderWater

    Advanced Member

  • Members
  • PipPipPip
  • 324 posts
  • Gender:Male
  • Location:Boston, MA
Contributor
made another change specifically for Lion, where both the token and bundle itself are marked as "locked"





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users


Toggle shoutbox Shoutbox

takiyon : (12 May 2012 - 02:28 PM) Server Scripter Just Got An Update. Check The Add-In Development Thread & Let Me Know What You Think.
takiyon : (12 May 2012 - 02:27 PM) Server Scripter Just Update
Fester : (30 April 2012 - 04:45 AM) Gdatasoft Protects 5 Pc's Yet Homeserver Allow 10 Connections ?
Fester : (30 April 2012 - 04:30 AM) Is This Orbitalbackupconfig Ready For Lion Yet ?
Gordon Currie : (30 April 2012 - 03:34 AM) @myangeldust - Yes Sql Server Express Can Be Installed On Whs1. I Would Recommend 2008 R2 Over 2005.
myangeldust : (21 April 2012 - 05:04 PM) Can Sql Server Express Be Installed On Whs V1?
Shidoshi : (12 April 2012 - 04:07 AM) @omega Ra - Reset Ie 8 And Retry. That Happens Anytime Ie Is Updated To A New Full Version (Like From Ie 6 To Ie 7 And Ie 7 To Ie 8) In Win Xp
Rolatio2 : (28 March 2012 - 01:59 PM) Cleanup
Omega Ra : (16 March 2012 - 02:02 PM) Is It Possible To Connect To A Computer Through The Web Access With A Winxp Sp3 Computer? It Keeps Asking About An Activex Component, But Doesn't Give Me An Option To Download It.
dbailey75 : (13 February 2012 - 03:18 AM) I Just Got My Geek On, It Feels Good
Mightyred : (18 January 2012 - 09:27 PM) @garry - It Seems Very Pricey, Think I'll Wait For Some Reviews.....
Garry : (17 January 2012 - 02:40 PM) @mightyred - I Have Not Heard Of Anyone With A Successful Install
Garry : (17 January 2012 - 02:38 PM) @geoff - Indeed, Have A Great Time! Happy Birthday!
bobbyc : (17 January 2012 - 09:30 AM) Happy Birthday Geoff!
Mightyred : (16 January 2012 - 11:52 PM) Anyone Tried The Gdatasoft Yet? Maybe A Review On Wgs Soon?
Garry : (07 January 2012 - 10:25 PM) News Flash Whs2011 A/v: Http://www.gdatasoft...Homeserver.html
Drashna Jael... : (30 December 2011 - 06:59 PM) The Site Is Still Around, Try Http://www.asoft.be/
msprague : (30 December 2011 - 01:14 AM) What's Happened To Asoft?
Terry (WGS) : (18 December 2011 - 05:58 PM) Indeed - Many Happy Returns Dave!
bobbyc : (18 December 2011 - 09:37 AM) Happy Birthday Dave!
Resize Shouts Area

Upgrade to a WGS Supporter Account to remove this ad.