Changeset 302 for soft/giet_vm/create_dmg
- Timestamp:
- Apr 14, 2014, 6:47:07 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/create_dmg
r300 r302 42 42 43 43 if [[ -z $2 ]]; then 44 echo "Create action need second argument: < srcdir_path>"44 echo "Create action need second argument: <disk_image>" 45 45 exit 1; 46 46 fi; 47 48 if [[ -z $3 ]]; then49 echo "Create action need third argument: <disk_image>"50 exit 1;51 fi;52 53 # RAW DISK IMAGE READ-ONLY54 # The not used space is not considered (smaller disk image)55 # format="UDRO"56 57 # RAW DISK IMAGE READ-WRITE58 # None compression is made59 format="UDRW"60 47 61 48 # -F FAT type = 32 (FAT32) … … 64 51 # -r reserved sectors 65 52 # -k backup boot sector (VBR and FS INFO) = 0xffff (no backup) 66 echo "Creating partition file $3.dmg from $2 directory"53 echo "Creating empty disk image: $2.dmg" 67 54 fsargs="-F32 -c $sectors_per_cluster -n 1 -r $reserved_sectors -k 0xffff" 55 56 # -layout = NONE (No partition scheme. Hence no Master Boot Record) 68 57 hdiutil create \ 69 58 -fs MS-DOS \ 70 59 -volname virtualdisk \ 71 - srcfolder $2\60 -layout NONE \ 72 61 -sectors $sectors \ 73 62 -ov \ 74 63 -fsargs "$fsargs" \ 75 -format $format \ 76 $3; 77 # -verbose \ 78 79 echo "Removing first sector of diskimage" 80 81 if [[ -e "/tmp" ]]; then 82 if [[ -e "/tmp/diskimage" ]]; then 83 echo "Warning /tmp/diskimage exists already. Rename it or" 84 echo "remove it before executing this script" 85 exit 86 fi; 87 88 dd if=$3.dmg of=/tmp/diskimage iseek=1 oseek=0 89 mv /tmp/diskimage $3.dmg 90 fi;; 64 -type "UDIF" \ 65 $2; 66 ;; 91 67 92 68 attach ) 93 69 # Attach created disk image to the system and mount it 94 hdiutil attach $2;; 70 hdiutil attach $2 71 ;; 95 72 96 73 detach ) 97 74 # Detach attached device. Must pass as parameter the /dev/<device> 98 hdiutil detach $2;; 75 hdiutil detach $2 76 ;; 99 77 100 78 info ) 101 hdiutil imageinfo $2;; 79 hdiutil imageinfo $2 80 ;; 102 81 103 82 * ) 104 83 echo "Pass the command as the first parameter: " 105 84 echo " - create: create disk image" 106 echo " First parameter after create action is the path"107 echo " of the directory to copy in the created "108 echo " partition"109 85 echo " - attach: attach created disk image to the system and " 110 86 echo " mount it (arg: path to disk_image)" … … 115 91 echo "" 116 92 echo "EXAMPLES:" 117 echo " ./create_diskimage.sh create /path/to/source_dirdisk_image"93 echo " ./create_diskimage.sh create disk_image" 118 94 echo " ./create_diskimage.sh attach /path/to/disk_image.dmg" 119 95 echo " ./create_diskimage.sh detach /dev/disk5" 120 96 echo " ./create_diskimage.sh info /path/to/disk_image.dmg" 97 ;; 121 98 esac; 122 99 … … 124 101 case $1 in 125 102 create ) 103 126 104 if [[ -z $2 ]]; then 127 echo "Create action need second argument: < srcdir_path>"105 echo "Create action need second argument: <disk_image>" 128 106 exit 1; 129 107 fi; 130 108 131 if [[ -z $3 ]]; then 132 echo "Create action need third argument: <disk_image>" 133 exit 1; 134 fi; 135 136 echo "Creating partition file: $3" 109 echo "Creating empty disk image: $2" 137 110 138 111 let "sectors = (sectors - 1) / 2" … … 145 118 -s $sectors_per_cluster \ 146 119 -v \ 147 $3.dmg $sectors 148 149 if [[ -e $2 ]]; then 150 echo "Copying files from $2 into partition" 151 mcopy -s -i $3.dmg $2/* ::// 152 fi;; 120 $2.dmg $sectors 121 ;; 153 122 154 123 * ) 155 124 echo "Pass the command as the first parameter: " 156 125 echo " - create: create disk image" 157 echo " First parameter after create action is the path"158 echo " of the directory to copy in the created "159 echo " partition"160 126 echo "" 161 127 echo "EXAMPLES:" 162 echo " ./create_diskimage.sh create /path/to/source_dir disk_image" 128 echo " ./create_diskimage.sh create disk_image" 129 ;; 163 130 esac; 164 131
Note: See TracChangeset
for help on using the changeset viewer.