Changeset 259 for soft/giet_vm/create_dmg
- Timestamp:
- Dec 5, 2013, 12:45:34 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/create_dmg
r258 r259 8 8 reserved_sectors=32 9 9 10 # FAT32 SPEC: The first two clusters are not present in the data region but 11 # they are used in the computation of the FAT sectors 12 data_region_clusters=$clusters-2 10 13 11 let "data_sectors = (clusters - 2) * sectors_per_cluster" 12 let "fat_sectors = (clusters * 4) / 512" 13 let "sectors=data_sectors + fat_sectors + reserved_sectors" 14 let "data_sectors = data_region_clusters * sectors_per_cluster" 15 let "fat_sectors = (clusters * 4) / 512" 16 17 # The disk image contains: 18 # - MBR sector : this sector is removed by this script as it will be copied 19 # after) 20 # - Reserved region sectors (usually 32) 21 # - FAT region sectors 22 # - DATA region sectors 23 let "sectors = data_sectors + fat_sectors + reserved_sectors + 1" 14 24 15 25 platform=`uname` … … 43 53 # RAW DISK IMAGE READ-ONLY 44 54 # The not used space is not considered (smaller disk image) 45 #format="UDRO"55 format="UDRO" 46 56 47 57 # RAW DISK IMAGE READ-WRITE 48 58 # None compression is made 49 format="UDRW"59 # format="UDRW" 50 60 51 61 echo "Creating partition file $3 from $2 directory" … … 59 69 -format $format \ 60 70 $3; 61 # 71 # -verbose \ 62 72 63 73 echo "Removing first sector of diskimage" … … 106 116 107 117 elif [[ $platform == "Linux" ]]; then 108 echo "Creating partion file: partition.dmg" 109 mkfs.vfat -C -F32 -S $sector_size -s $sectors_per_cluster \ 110 partition.dmg $sectors 118 case $1 in 119 create ) 120 if [[ -z $2 ]]; then 121 echo "Create action need second argument: <srcdir_path>" 122 exit 1; 123 fi; 111 124 112 echo "Copying files into the partition" 113 mcopy -s -i partition.dmg build ::// 114 mcopy -i partition.dmg map.bin ::// 125 if [[ -z $3 ]]; then 126 echo "Create action need third argument: <disk_image>" 127 exit 1; 128 fi; 115 129 116 echo "Copying MBR on the first sector" 117 dd if=mbr.dmg of=disk.dmg count=1 bs=$sector_size 130 echo "Creating partition file: $3" 118 131 119 echo "Copying partition file on the sector 200 of the disk" 120 dd if=partition.dmg of=disk.dmg seek=200 bs=$sector_size 132 let "sectors = (sectors - 1) / 2" 133 mkfs.vfat \ 134 -C \ 135 -F32 \ 136 -f 1 \ 137 -R $reserved_sectors \ 138 -S $sector_size \ 139 -s $sectors_per_cluster \ 140 -v \ 141 $3.dmg $sectors 142 143 if [[ -e $2 ]]; then 144 echo "Copying files from $2 into partition" 145 mcopy -s -i $3.dmg $2/* ::// 146 fi;; 147 148 * ) 149 echo "Pass the command as the first parameter: " 150 echo " - create: create disk image" 151 echo " First parameter after create action is the path" 152 echo " of the directory to copy in the created " 153 echo " partition" 154 echo "" 155 echo "EXAMPLES:" 156 echo " ./create_diskimage.sh create /path/to/source_dir disk_image" 157 esac; 121 158 122 159 else
Note: See TracChangeset
for help on using the changeset viewer.