コード例 #1
0
        /// <summary>
        /// Creates a new partition table on a disk containing a single partition.
        /// </summary>
        /// <param name="disk">The disk to initialize.</param>
        /// <param name="type">The partition type for the single partition</param>
        /// <returns>An object to access the newly created partition table</returns>
        public static GuidPartitionTable Initialize(VirtualDisk disk, WellKnownPartitionType type)
        {
            GuidPartitionTable pt = Initialize(disk);

            pt.Create(type, true);
            return(pt);
        }
コード例 #2
0
        private static byte ConvertType(WellKnownPartitionType type, long size)
        {
            switch (type)
            {
            case WellKnownPartitionType.WindowsFat:
                if (size < 512 * Sizes.OneMiB)
                {
                    return(BiosPartitionTypes.Fat16);
                }
                else if (size < 1023 * (long)254 * 63 * 512)
                {
                    // Max BIOS size
                    return(BiosPartitionTypes.Fat32);
                }
                else
                {
                    return(BiosPartitionTypes.Fat32Lba);
                }

            case WellKnownPartitionType.WindowsNtfs:
                return(BiosPartitionTypes.Ntfs);

            case WellKnownPartitionType.Linux:
                return(BiosPartitionTypes.LinuxNative);

            case WellKnownPartitionType.LinuxSwap:
                return(BiosPartitionTypes.LinuxSwap);

            case WellKnownPartitionType.LinuxLvm:
                return(BiosPartitionTypes.LinuxLvm);

            default:
                throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "Unrecognized partition type: '{0}'", type), "type");
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates a new partition table on a disk containing a single partition.
        /// </summary>
        /// <param name="disk">The disk to initialize.</param>
        /// <param name="type">The partition type for the single partition</param>
        /// <returns>An object to access the newly created partition table</returns>
        public static BiosPartitionTable Initialize(VirtualDisk disk, WellKnownPartitionType type)
        {
            BiosPartitionTable table = Initialize(disk.Content, disk.BiosGeometry);

            table.Create(type, true);
            return(table);
        }
コード例 #4
0
        /// <summary>
        /// Creates a new primary partition with a target size.
        /// </summary>
        /// <param name="size">The target size (in bytes)</param>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <returns>The index of the new partition</returns>
        public override int Create(long size, WellKnownPartitionType type, bool active)
        {
            int cylinderCapacity = _diskGeometry.SectorsPerTrack * _diskGeometry.HeadsPerCylinder * _diskGeometry.BytesPerSector;
            int numCylinders     = (int)(size / cylinderCapacity);

            int startCylinder = FindCylinderGap(numCylinders);

            return(CreatePrimaryByCylinder(startCylinder, startCylinder + numCylinders - 1, ConvertType(type, size), active));
        }
コード例 #5
0
        /// <summary>
        /// Creates a new aligned partition that encompasses the entire disk.
        /// </summary>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <param name="alignment">The alignment (in bytes)</param>
        /// <returns>The index of the partition</returns>
        /// <remarks>The partition table must be empty before this method is called,
        /// otherwise IOException is thrown.</remarks>
        /// <remarks>
        /// Traditionally partitions were aligned to the physical structure of the underlying disk,
        /// however with modern storage greater efficiency is acheived by aligning partitions on
        /// large values that are a power of two.
        /// </remarks>
        public override int CreateAligned(WellKnownPartitionType type, bool active, int alignment)
        {
            Geometry allocationGeometry = new Geometry(_diskData.Length, _diskGeometry.HeadsPerCylinder, _diskGeometry.SectorsPerTrack, _diskGeometry.BytesPerSector);

            ChsAddress start = new ChsAddress(0, 1, 1);

            long startLba = Utilities.RoundUp(allocationGeometry.ToLogicalBlockAddress(start), alignment / _diskGeometry.BytesPerSector);
            long lastLba  = Utilities.RoundDown((_diskData.Length / _diskGeometry.BytesPerSector), alignment / _diskGeometry.BytesPerSector);

            return(CreatePrimaryBySector(startLba, lastLba - 1, ConvertType(type, (lastLba - startLba) * Utilities.SectorSize), active));
        }
コード例 #6
0
ファイル: ModuleHelpers.cs プロジェクト: Lukas0610/ndiscutils
        public static bool IsSupportedPartitionType(WellKnownPartitionType partitionType)
        {
            // Exactly clone critical partitions like BIOS/EFI boot
            if (partitionType == WellKnownPartitionType.BiosBoot ||
                partitionType == WellKnownPartitionType.EfiSystem)
            {
                return(false);
            }

            return(true);
        }
コード例 #7
0
        /// <summary>
        /// Creates a new partition that encompasses the entire disk.
        /// </summary>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <returns>The index of the partition</returns>
        /// <remarks>The partition table must be empty before this method is called,
        /// otherwise IOException is thrown.</remarks>
        public override int Create(WellKnownPartitionType type, bool active)
        {
            Geometry allocationGeometry = new Geometry(_diskData.Length, _diskGeometry.HeadsPerCylinder, _diskGeometry.SectorsPerTrack, _diskGeometry.BytesPerSector);

            ChsAddress start = new ChsAddress(0, 1, 1);
            ChsAddress last  = allocationGeometry.LastSector;

            long startLba = allocationGeometry.ToLogicalBlockAddress(start);
            long lastLba  = allocationGeometry.ToLogicalBlockAddress(last);

            return(CreatePrimaryByCylinder(0, allocationGeometry.Cylinders - 1, ConvertType(type, (lastLba - startLba) * Utilities.SectorSize), active));
        }
コード例 #8
0
        /// <summary>
        /// Creates a new partition that encompasses the entire disk.
        /// </summary>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <returns>The index of the partition</returns>
        /// <remarks>The partition table must be empty before this method is called,
        /// otherwise IOException is thrown.</remarks>
        public override int Create(WellKnownPartitionType type, bool active)
        {
            List <GptEntry> allEntries = new List <GptEntry>(GetAllEntries());

            EstablishReservedPartition(allEntries);

            // Fill the rest of the disk with the requested partition
            long start = FirstAvailableSector(allEntries);
            long end   = FindLastFreeSector(start, allEntries);

            return(Create(start, end, GuidPartitionTypes.Convert(type), 0, "Data Partition"));
        }
コード例 #9
0
        /// <summary>
        /// Creates a new primary partition with a target size.
        /// </summary>
        /// <param name="size">The target size (in bytes)</param>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <returns>The index of the new partition</returns>
        public override int Create(long size, WellKnownPartitionType type, bool active)
        {
            if (size < _diskGeometry.BytesPerSector)
            {
                throw new ArgumentOutOfRangeException("size", size, "size must be at least one sector");
            }

            long sectorLength = size / _diskGeometry.BytesPerSector;
            long start        = FindGap(size / _diskGeometry.BytesPerSector, 1);

            return(Create(start, start + sectorLength - 1, GuidPartitionTypes.Convert(type), 0, "Data Partition"));
        }
コード例 #10
0
        /// <summary>
        /// Creates a new partition that encompasses the entire disk.
        /// </summary>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <returns>The index of the partition</returns>
        /// <remarks>The partition table must be empty before this method is called,
        /// otherwise IOException is thrown.</remarks>
        public override int Create(WellKnownPartitionType type, bool active)
        {
            List <GptEntry> allEntries = new List <GptEntry>(GetAllEntries());

            // If no MicrosoftReserved partition, and no Microsoft Data partitions, and the disk
            // has a 'reasonable' size free, create a Microsoft Reserved partition.
            if (CountEntries(allEntries, e => e.PartitionType == GuidPartitionTypes.MicrosoftReserved) == 0 &&
                CountEntries(allEntries, e => e.PartitionType == GuidPartitionTypes.WindowsBasicData) == 0 &&
                _diskGeometry.Capacity > 512 * 1024 * 1024)
            {
                long reservedStart = FirstAvailableSector(allEntries);
                long reservedEnd   = FindLastFreeSector(reservedStart, allEntries);

                if ((reservedEnd - reservedStart + 1) * _diskGeometry.BytesPerSector > 512 * 1024 * 1024)
                {
                    long size = ((_diskGeometry.Capacity < (16 * 1024L * 1024 * 1024)) ? 32 : 128) * 1024 * 1024;
                    reservedEnd = reservedStart + (size / _diskGeometry.BytesPerSector) - 1;

                    int      reservedOffset   = GetFreeEntryOffset();
                    GptEntry newReservedEntry = new GptEntry();
                    newReservedEntry.PartitionType         = GuidPartitionTypes.MicrosoftReserved;
                    newReservedEntry.Identity              = Guid.NewGuid();
                    newReservedEntry.FirstUsedLogicalBlock = reservedStart;
                    newReservedEntry.LastUsedLogicalBlock  = reservedEnd;
                    newReservedEntry.Attributes            = 0;
                    newReservedEntry.Name = "Microsoft reserved partition";
                    newReservedEntry.WriteTo(_entryBuffer, reservedOffset);
                    allEntries.Add(newReservedEntry);
                }
            }

            // Fill the rest of the disk with the requested partition
            long start = FirstAvailableSector(allEntries);
            long end   = FindLastFreeSector(start, allEntries);

            int      offset   = GetFreeEntryOffset();
            GptEntry newEntry = new GptEntry();

            newEntry.PartitionType         = GuidPartitionTypes.Convert(type);
            newEntry.Identity              = Guid.NewGuid();
            newEntry.FirstUsedLogicalBlock = start;
            newEntry.LastUsedLogicalBlock  = end;
            newEntry.Attributes            = 0;
            newEntry.Name = "Data Partition";
            newEntry.WriteTo(_entryBuffer, offset);

            // Commit changes to disk
            Write();

            return(GetEntryIndex(newEntry.Identity));
        }
コード例 #11
0
        private static byte ConvertType(WellKnownPartitionType type, long size)
        {
            switch (type)
            {
            case WellKnownPartitionType.WindowsFat:
                if (size < 512 * Sizes.OneMiB)
                {
                    return(BiosPartitionTypes.Fat16);
                }
                if (size < 1023 * (long)254 * 63 * 512)
                {
                    // Max BIOS size
                    return(BiosPartitionTypes.Fat32);
                }
                return(BiosPartitionTypes.Fat32Lba);

            case WellKnownPartitionType.WindowsNtfs:
                return(BiosPartitionTypes.Ntfs);

            case WellKnownPartitionType.Linux:
                return(BiosPartitionTypes.LinuxNative);

            case WellKnownPartitionType.LinuxSwap:
                return(BiosPartitionTypes.LinuxSwap);

            case WellKnownPartitionType.LinuxLvm:
                return(BiosPartitionTypes.LinuxLvm);

            case WellKnownPartitionType.EfiSystem:
                return(BiosPartitionTypes.EfiSystem);

            case WellKnownPartitionType.WindowsLdmMetadata:
            case WellKnownPartitionType.WindowsLdmData:
            case WellKnownPartitionType.WindowsStorageSpaces:
                return(BiosPartitionTypes.WindowsDynamicVolume);

            case WellKnownPartitionType.MicrosoftReserved:
                return(BiosPartitionTypes.WindowsEfiReserved);

            case WellKnownPartitionType.WindowsRecovery:
                return(BiosPartitionTypes.WindowsRecovery);

            default:
                throw new ArgumentException(
                          string.Format(CultureInfo.InvariantCulture, "Unrecognized partition type: '{0}'", type),
                          nameof(type));
            }
        }
コード例 #12
0
 /// <summary>
 /// Converts a well known partition type to a Guid.
 /// </summary>
 /// <param name="wellKnown">The value to convert</param>
 /// <returns>The GUID value</returns>
 internal static Guid Convert(WellKnownPartitionType wellKnown)
 {
     switch (wellKnown)
     {
         case WellKnownPartitionType.Linux:
         case WellKnownPartitionType.WindowsFat:
         case WellKnownPartitionType.WindowsNtfs:
             return WindowsBasicData;
         case WellKnownPartitionType.LinuxLvm:
             return LinuxLvm;
         case WellKnownPartitionType.LinuxSwap:
             return LinuxSwap;
         default:
             throw new ArgumentException("Unknown partition type");
     }
 }
コード例 #13
0
        /// <summary>
        /// Converts a well known partition type to a Guid.
        /// </summary>
        /// <param name="wellKnown">The value to convert.</param>
        /// <returns>The GUID value.</returns>
        internal static Guid Convert(WellKnownPartitionType wellKnown)
        {
            switch (wellKnown)
            {
            case WellKnownPartitionType.Linux:
            case WellKnownPartitionType.WindowsFat:
            case WellKnownPartitionType.WindowsNtfs:
                return(WindowsBasicData);

            case WellKnownPartitionType.LinuxLvm:
                return(LinuxLvm);

            case WellKnownPartitionType.LinuxSwap:
                return(LinuxSwap);

            default:
                throw new ArgumentException("Unknown partition type");
            }
        }
コード例 #14
0
        /// <summary>
        /// Creates a new aligned partition that encompasses the entire disk.
        /// </summary>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <param name="alignment">The alignment (in bytes)</param>
        /// <returns>The index of the partition</returns>
        /// <remarks>The partition table must be empty before this method is called,
        /// otherwise IOException is thrown.</remarks>
        /// <remarks>
        /// Traditionally partitions were aligned to the physical structure of the underlying disk,
        /// however with modern storage greater efficiency is acheived by aligning partitions on
        /// large values that are a power of two.
        /// </remarks>
        public override int CreateAligned(WellKnownPartitionType type, bool active, int alignment)
        {
            if (alignment % _diskGeometry.BytesPerSector != 0)
            {
                throw new ArgumentException("Alignment is not a multiple of the sector size");
            }

            List <GptEntry> allEntries = new List <GptEntry>(GetAllEntries());

            EstablishReservedPartition(allEntries);

            // Fill the rest of the disk with the requested partition
            long start = Utilities.RoundUp(FirstAvailableSector(allEntries), alignment / _diskGeometry.BytesPerSector);
            long end   = Utilities.RoundDown(FindLastFreeSector(start, allEntries) + 1, alignment / _diskGeometry.BytesPerSector);

            if (end <= start)
            {
                throw new IOException("No available space");
            }

            return(Create(start, end - 1, GuidPartitionTypes.Convert(type), 0, "Data Partition"));
        }
コード例 #15
0
        /// <summary>
        /// Creates a new aligned partition with a target size.
        /// </summary>
        /// <param name="size">The target size (in bytes)</param>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <param name="alignment">The alignment (in bytes)</param>
        /// <returns>The index of the new partition</returns>
        /// <remarks>
        /// Traditionally partitions were aligned to the physical structure of the underlying disk,
        /// however with modern storage greater efficiency is acheived by aligning partitions on
        /// large values that are a power of two.
        /// </remarks>
        public override int CreateAligned(long size, WellKnownPartitionType type, bool active, int alignment)
        {
            if (size < _diskGeometry.BytesPerSector)
            {
                throw new ArgumentOutOfRangeException("size", size, "size must be at least one sector");
            }

            if (alignment % _diskGeometry.BytesPerSector != 0)
            {
                throw new ArgumentException("Alignment is not a multiple of the sector size");
            }

            if (size % alignment != 0)
            {
                throw new ArgumentException("Size is not a multiple of the alignment");
            }

            long sectorLength = size / _diskGeometry.BytesPerSector;
            long start        = FindGap(size / _diskGeometry.BytesPerSector, alignment / _diskGeometry.BytesPerSector);

            return(Create(start, start + sectorLength - 1, GuidPartitionTypes.Convert(type), 0, "Data Partition"));
        }
コード例 #16
0
        /// <summary>
        /// Converts a well known partition type to a Guid.
        /// </summary>
        /// <param name="wellKnown">The value to convert.</param>
        /// <returns>The GUID value.</returns>
        internal static Guid Convert(WellKnownPartitionType wellKnown)
        {
            switch (wellKnown)
            {
            case WellKnownPartitionType.Linux:
            case WellKnownPartitionType.WindowsFat:
            case WellKnownPartitionType.WindowsNtfs:
                return(WindowsBasicData);

            case WellKnownPartitionType.LinuxLvm:
                return(LinuxLvm);

            case WellKnownPartitionType.LinuxSwap:
                return(LinuxSwap);

            case WellKnownPartitionType.EfiSystem:
                return(EfiSystem);

            case WellKnownPartitionType.WindowsLdmMetadata:
                return(WindowsLdmMetadata);

            case WellKnownPartitionType.WindowsLdmData:
                return(WindowsLdmData);

            case WellKnownPartitionType.WindowsStorageSpaces:
                return(WindowsStorageSpaces);

            case WellKnownPartitionType.MicrosoftReserved:
                return(MicrosoftReserved);

            case WellKnownPartitionType.WindowsRecovery:
                return(WindowsRecovery);

            default:
                throw new ArgumentException("Unknown partition type");
            }
        }
コード例 #17
0
 /// <summary>
 /// Creates a new partition table on a disk containing a single partition.
 /// </summary>
 /// <param name="disk">The disk to initialize.</param>
 /// <param name="type">The partition type for the single partition</param>
 /// <returns>An object to access the newly created partition table</returns>
 public static BiosPartitionTable Initialize(VirtualDisk disk, WellKnownPartitionType type)
 {
     BiosPartitionTable table = Initialize(disk.Content, disk.BiosGeometry);
     table.Create(type, true);
     return table;
 }
コード例 #18
0
        /// <summary>
        /// Creates a new partition that encompasses the entire disk.
        /// </summary>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <returns>The index of the partition</returns>
        /// <remarks>The partition table must be empty before this method is called,
        /// otherwise IOException is thrown.</remarks>
        public override int Create(WellKnownPartitionType type, bool active)
        {
            Geometry allocationGeometry = new Geometry(_diskData.Length, _diskGeometry.HeadsPerCylinder, _diskGeometry.SectorsPerTrack, _diskGeometry.BytesPerSector);

            ChsAddress start = new ChsAddress(0, 1, 1);
            ChsAddress last = allocationGeometry.LastSector;

            long startLba = allocationGeometry.ToLogicalBlockAddress(start);
            long lastLba = allocationGeometry.ToLogicalBlockAddress(last);

            return CreatePrimaryByCylinder(0, allocationGeometry.Cylinders - 1, ConvertType(type, (lastLba - startLba) * Utilities.SectorSize), active);
        }
コード例 #19
0
        /// <summary>
        /// Creates a new primary partition with a target size.
        /// </summary>
        /// <param name="size">The target size (in bytes)</param>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <returns>The index of the new partition</returns>
        public override int Create(long size, WellKnownPartitionType type, bool active)
        {
            int cylinderCapacity = _diskGeometry.SectorsPerTrack * _diskGeometry.HeadsPerCylinder * _diskGeometry.BytesPerSector;
            int numCylinders = (int)(size / cylinderCapacity);

            int startCylinder = FindCylinderGap(numCylinders);

            return CreatePrimaryByCylinder(startCylinder, startCylinder + numCylinders - 1, ConvertType(type, size), active);
        }
コード例 #20
0
        /// <summary>
        /// Creates a new aligned partition that encompasses the entire disk.
        /// </summary>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <param name="alignment">The alignment (in bytes)</param>
        /// <returns>The index of the partition</returns>
        /// <remarks>The partition table must be empty before this method is called,
        /// otherwise IOException is thrown.</remarks>
        /// <remarks>
        /// Traditionally partitions were aligned to the physical structure of the underlying disk,
        /// however with modern storage greater efficiency is acheived by aligning partitions on
        /// large values that are a power of two.
        /// </remarks>
        public override int CreateAligned(WellKnownPartitionType type, bool active, int alignment)
        {
            Geometry allocationGeometry = new Geometry(_diskData.Length, _diskGeometry.HeadsPerCylinder, _diskGeometry.SectorsPerTrack, _diskGeometry.BytesPerSector);

            ChsAddress start = new ChsAddress(0, 1, 1);

            long startLba = Utilities.RoundUp(allocationGeometry.ToLogicalBlockAddress(start), alignment / _diskGeometry.BytesPerSector);
            long lastLba = Utilities.RoundDown((_diskData.Length / _diskGeometry.BytesPerSector), alignment / _diskGeometry.BytesPerSector);

            return CreatePrimaryBySector(startLba, lastLba - 1, ConvertType(type, (lastLba - startLba) * Utilities.SectorSize), active);
        }
コード例 #21
0
 /// <summary>
 /// Creates a new aligned partition with a target size.
 /// </summary>
 /// <param name="size">The target size (in bytes)</param>
 /// <param name="type">The partition type</param>
 /// <param name="active">Whether the partition is active (bootable)</param>
 /// <param name="alignment">The alignment (in byte)</param>
 /// <returns>The index of the new partition</returns>
 /// <remarks>
 /// Traditionally partitions were aligned to the physical structure of the underlying disk,
 /// however with modern storage greater efficiency is acheived by aligning partitions on
 /// large values that are a power of two.
 /// </remarks>
 public abstract int CreateAligned(long size, WellKnownPartitionType type, bool active, int alignment);
コード例 #22
0
 /// <summary>
 /// Creates a new aligned partition with a target size.
 /// </summary>
 /// <param name="size">The target size (in bytes)</param>
 /// <param name="type">The partition type</param>
 /// <param name="active">Whether the partition is active (bootable)</param>
 /// <param name="alignment">The alignment (in byte)</param>
 /// <returns>The index of the new partition</returns>
 /// <remarks>
 /// Traditionally partitions were aligned to the physical structure of the underlying disk,
 /// however with modern storage greater efficiency is acheived by aligning partitions on
 /// large values that are a power of two.
 /// </remarks>
 public override int CreateAligned(long size, WellKnownPartitionType type, bool active, int alignment)
 {
     throw new NotImplementedException();
 }
コード例 #23
0
        /// <summary>
        /// Creates a new aligned partition with a target size.
        /// </summary>
        /// <param name="size">The target size (in bytes)</param>
        /// <param name="type">The partition type</param>
        /// <param name="active">Whether the partition is active (bootable)</param>
        /// <param name="alignment">The alignment (in bytes)</param>
        /// <returns>The index of the new partition</returns>
        /// <remarks>
        /// Traditionally partitions were aligned to the physical structure of the underlying disk,
        /// however with modern storage greater efficiency is acheived by aligning partitions on
        /// large values that are a power of two.
        /// </remarks>
        public override int CreateAligned(long size, WellKnownPartitionType type, bool active, int alignment)
        {
            if (size < _diskGeometry.BytesPerSector)
            {
                throw new ArgumentOutOfRangeException("size", size, "size must be at least one sector");
            }

            if (alignment % _diskGeometry.BytesPerSector != 0)
            {
                throw new ArgumentException("Alignment is not a multiple of the sector size");
            }

            if (size % alignment != 0)
            {
                throw new ArgumentException("Size is not a multiple of the alignment");
            }

            long sectorLength = size / _diskGeometry.BytesPerSector;
            long start = FindGap(size / _diskGeometry.BytesPerSector, alignment / _diskGeometry.BytesPerSector);

            return CreatePrimaryBySector(start, start + sectorLength - 1, ConvertType(type, sectorLength * Utilities.SectorSize), active);
        }
コード例 #24
0
        private static byte ConvertType(WellKnownPartitionType type, long size)
        {
            switch (type)
            {
                case WellKnownPartitionType.WindowsFat:
                    if (size < 512 * Sizes.OneMiB)
                    {
                        return BiosPartitionTypes.Fat16;
                    }
                    else if (size < 1023 * (long)254 * 63 * 512)
                    {
                        // Max BIOS size
                        return BiosPartitionTypes.Fat32;
                    }
                    else
                    {
                        return BiosPartitionTypes.Fat32Lba;
                    }

                case WellKnownPartitionType.WindowsNtfs:
                    return BiosPartitionTypes.Ntfs;
                case WellKnownPartitionType.Linux:
                    return BiosPartitionTypes.LinuxNative;
                case WellKnownPartitionType.LinuxSwap:
                    return BiosPartitionTypes.LinuxSwap;
                case WellKnownPartitionType.LinuxLvm:
                    return BiosPartitionTypes.LinuxLvm;
                default:
                    throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "Unrecognized partition type: '{0}'", type), "type");
            }
        }
コード例 #25
0
ファイル: PartitionTable.cs プロジェクト: alexcmd/DiscUtils
 /// <summary>
 /// Creates a new partition with a target size.
 /// </summary>
 /// <param name="size">The target size (in bytes).</param>
 /// <param name="type">The partition type.</param>
 /// <param name="active">Whether the partition is active (bootable).</param>
 /// <returns>The index of the new partition.</returns>
 public abstract int Create(long size, WellKnownPartitionType type, bool active);
コード例 #26
0
ファイル: PartitionTable.cs プロジェクト: alexcmd/DiscUtils
 /// <summary>
 /// Creates a new aligned partition with a target size.
 /// </summary>
 /// <param name="size">The target size (in bytes).</param>
 /// <param name="type">The partition type.</param>
 /// <param name="active">Whether the partition is active (bootable).</param>
 /// <param name="alignment">The alignment (in byte).</param>
 /// <returns>The index of the new partition.</returns>
 /// <remarks>
 /// Traditionally partitions were aligned to the physical structure of the underlying disk,
 /// however with modern storage greater efficiency is achieved by aligning partitions on
 /// large values that are a power of two.
 /// </remarks>
 public abstract int CreateAligned(long size, WellKnownPartitionType type, bool active, int alignment);
コード例 #27
0
ファイル: DiffVHD.cs プロジェクト: virmitio/DiffVHD
 internal static DiscFileSystem CreateSimpleDisk(Stream File, long Size, WellKnownPartitionType VolumeType = WellKnownPartitionType.WindowsNtfs)
 {
     int BlockSize = 512*1024;
     var Out = DiscUtils.Vhd.Disk.InitializeDynamic(File, Ownership.None, Size, BlockSize);
     Out.AutoCommitFooter = false;
     Out.Signature = new Random().Next();
     BiosPartitionTable.Initialize(Out, VolumeType);
     DiscFileSystem sys = Out.FormatPartition(0);
     return sys;
 }
コード例 #28
0
ファイル: PartitionMap.cs プロジェクト: alexcmd/DiscUtils
 /// <summary>
 /// Creates a new aligned partition with a target size.
 /// </summary>
 /// <param name="size">The target size (in bytes).</param>
 /// <param name="type">The partition type.</param>
 /// <param name="active">Whether the partition is active (bootable).</param>
 /// <param name="alignment">The alignment (in byte).</param>
 /// <returns>The index of the new partition.</returns>
 /// <remarks>
 /// Traditionally partitions were aligned to the physical structure of the underlying disk,
 /// however with modern storage greater efficiency is achieved by aligning partitions on
 /// large values that are a power of two.
 /// </remarks>
 public override int CreateAligned(long size, WellKnownPartitionType type, bool active, int alignment)
 {
     throw new NotImplementedException();
 }
コード例 #29
0
 /// <summary>
 /// Creates a new partition that encompasses the entire disk.
 /// </summary>
 /// <param name="type">The partition type</param>
 /// <param name="active">Whether the partition is active (bootable)</param>
 /// <returns>The index of the partition</returns>
 /// <remarks>The partition table must be empty before this method is called,
 /// otherwise IOException is thrown.</remarks>
 public override int Create(WellKnownPartitionType type, bool active)
 {
     throw new NotImplementedException();
 }
コード例 #30
0
ファイル: PartitionMap.cs プロジェクト: alexcmd/DiscUtils
 /// <summary>
 /// Creates a new partition that encompasses the entire disk.
 /// </summary>
 /// <param name="type">The partition type.</param>
 /// <param name="active">Whether the partition is active (bootable).</param>
 /// <returns>The index of the partition.</returns>
 /// <remarks>The partition table must be empty before this method is called,
 /// otherwise IOException is thrown.</remarks>
 public override int Create(WellKnownPartitionType type, bool active)
 {
     throw new NotImplementedException();
 }
コード例 #31
0
 /// <summary>
 /// Creates a new partition with a target size.
 /// </summary>
 /// <param name="size">The target size (in bytes)</param>
 /// <param name="type">The partition type</param>
 /// <param name="active">Whether the partition is active (bootable)</param>
 /// <returns>The index of the new partition</returns>
 public abstract int Create(long size, WellKnownPartitionType type, bool active);