Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), of size 10MB filled with a FAT32 filesystem.
()
| 41 | // Create a disk of size 20MB with an MBR partition table, a single partition beginning at block 2048 (1MB), |
| 42 | // of size 10MB filled with a FAT32 filesystem. |
| 43 | func ExampleCreate_mbr() { |
| 44 | var size int64 = 20 * 1024 * 1024 // 20 MB |
| 45 | |
| 46 | diskImg := "/tmp/disk.img" |
| 47 | defer os.Remove(diskImg) |
| 48 | theDisk, _ := diskfs.Create(diskImg, size, diskfs.SectorSizeDefault) |
| 49 | |
| 50 | table := &mbr.Table{ |
| 51 | LogicalSectorSize: 512, |
| 52 | PhysicalSectorSize: 512, |
| 53 | Partitions: []*mbr.Partition{ |
| 54 | { |
| 55 | Bootable: false, |
| 56 | Type: mbr.Linux, |
| 57 | Start: 2048, |
| 58 | Size: 20480, |
| 59 | }, |
| 60 | }, |
| 61 | } |
| 62 | |
| 63 | check(theDisk.Partition(table)) |
| 64 | |
| 65 | fs, err := theDisk.CreateFilesystem(disk.FilesystemSpec{ |
| 66 | Partition: 1, |
| 67 | FSType: filesystem.TypeFat32, |
| 68 | }) |
| 69 | check(err) |
| 70 | unused(fs) |
| 71 | } |
| 72 | |
| 73 | // Create a disk of size 20MB with a GPT partition table, a single partition beginning at block 2048 (1MB), of size 10MB, and fill with the contents from the 10MB file "/root/contents.dat" |
| 74 | func ExampleCreate_gpt() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…