Commit Graph

189 Commits

Author SHA1 Message Date
Andrey V. Elsukov
d4746e107f Always reconstruct partition entries in the PMBR when Boot Camp is
disabled. This helps to easily recover from situations when PMBR is
damaged and contains no entries.

MFC after:	1 week
2012-06-14 11:17:54 +00:00
Marcel Moolenaar
f24a8224b2 Add a partition type for nandfs to the apm, bsd, gpt and vtoc8 schemes.
The gpart alias for these partition types is "freebsd-nandfs".
2012-05-25 20:33:34 +00:00
Dmitry Morozovsky
b20e4de387 VMware environments are not unusual now. Add VMware partitions recognition
(both MBR for ESXi <= 4.1 and GPT for ESXi 5) to g_part.

Reviewed by:	ae
Approved by:	ae
MFC after:	2 weeks
2012-04-18 11:59:03 +00:00
Andrey V. Elsukov
ba289b84b0 VMDB offset should be greater than logical volume size only for MBR. 2012-03-29 07:29:27 +00:00
Andrey V. Elsukov
1c45872b03 Do proper cleanup for the GPT case when an error occurs. 2012-03-29 06:37:02 +00:00
Andrey V. Elsukov
472794bb9f Check that scheme is not already registered. This may happens when a
KLD is preloaded with loader(8) and leads to infinity loops.

Also do not return EEXIST error code from MOD_LOAD handler, because
we have undocumented(?) ability replace kernel's module with preloaded one.
And if we have so, then preloaded module will be initialized first.
Thus error in MOD_LOAD handler will be triggered for the kernel.

PR:		kern/165573
MFC after:	3 weeks
2012-03-23 07:26:17 +00:00
Andrey V. Elsukov
f1104f7190 Add CTLFLAG_TUN to sysctls.
MFC after:	1 month
2012-03-19 13:21:10 +00:00
Andrey V. Elsukov
37d1a121d9 Add new GEOM_PART_LDM module that implements the Logical Disk Manager
scheme. The LDM is a logical volume manager for MS Windows NT and it
is also known as dynamic volumes. It supports about 2000 partitions
and also provides the capability for software RAID implementations.

This version implements only partitioning scheme capability and based
on the linux-ntfs project documentation and several publications across
the Web. NOTE: JBOD, RAID0 and RAID5 volumes aren't supported.

An access to the LDM metadata is read-only. When LDM is on the disk
partitioned with MBR we can also destroy metadata. For the GPT
partitioned disks destroy action is not supported.

Reviewed by:	ivoras (previous version)
MFC after:	1 month
2012-03-19 13:14:44 +00:00
Andrey V. Elsukov
422783e365 Make kern.geom.part node not static. Also add CTLFLAG_TUN to the
check_integrity sysctl.

MFC after:	1 month
2012-03-19 12:57:52 +00:00
Andrey V. Elsukov
5284aff594 Add MODULE_DEPEND() to geom_part modules.
MFC after:	2 weeks
2012-03-15 08:39:10 +00:00
Ed Maste
972f6945b8 Remove unactionable message about label geometry
It's not clear to a user what they should do after seeing the "geometry
does not match label" kernel message, and it does not appear to present
a problem in practice.  Thus, just remove the messages.

Approved by:	marcel
2012-03-08 01:48:44 +00:00
Andrey V. Elsukov
5357f27569 If nested scheme allows dump kernel to its partition, we may allow
dump for the parent partition too.

MFC after:	2 weeks
2012-02-20 06:35:52 +00:00
Andrey V. Elsukov
c3f9f306d2 Add alias for the partition type 0x0f. Now "ebr" name is used for both
types 0x05 and 0x0f, but 0x05 is preferred and used when partition is
created with "gpart add -t ebr ...".
This should keep EBR partitions accessible after r231754 for those,
who have EBR on the partition with type 0x0f.
2012-02-20 05:48:57 +00:00
Andrey V. Elsukov
3bcf7d7191 Add additional check to EBR probe and create methods:
don't try probe and create  EBR scheme when parent partition type
is not "ebr". This fixes error messages about corrupted EBR for
some partitions where is actually another partition scheme.

NOTE: if you have EBR on the partition with different than "ebr"
(0x05) type, then you will lost access to partitions until it will be
changed.

MFC after:	2 weeks
2012-02-15 10:33:29 +00:00
Andrey V. Elsukov
0d8bc07eba Add PART::type attribute handler. It returns partition type as string.
MFC after:	2 weeks
2012-02-15 10:02:19 +00:00
Andrey V. Elsukov
48ef46e55a Add alias for the partition with type 0x42 to the MBR scheme.
MFC after:	1 week
2012-02-10 09:55:18 +00:00
Andrey V. Elsukov
f44d97bd0c Let's be more realistic and limit maximum number of partition to 4k.
MFC after:	1 week
2012-02-10 06:44:30 +00:00
Ed Maste
23f6856fff Correct typo in comment (numbver) 2012-02-04 18:14:39 +00:00
Andrey V. Elsukov
7b540236bb The scheme code may not know about some inconsistency in the metadata.
So, add an integrity check after recovery attempt.

MFC after:	1 week
2012-02-01 09:28:16 +00:00
Nathan Whitehorn
090dd24636 Experimental support for booting CHRP-type PowerPC systems from hard disks. 2012-01-25 03:37:39 +00:00
Don Lewis
b5bad28182 Allow an MBR primary or extended Linux swap partition to be specified
as the system dump device.  This was already allowed for GPT.  The Linux
swap metadata at the beginning of the partition should not be disturbed
because the crash dump is written at the end.

Reviewed by:	alfred, pjd, marcel
MFC after:	2 weeks
2012-01-13 18:32:56 +00:00
Andrey V. Elsukov
a85a0d469e Add an ability to increase number of allocated APM entries when we
have reserved free space in the APM area.
Also instead of one write request per each APM entry, use MAXPHY
sized writes when we are updating APM.

MFC after:	1 month
2011-11-28 16:07:26 +00:00
Andrey V. Elsukov
64c4a83782 The size of APM could be bigger than number of already allocated entries.
And the first usable sector should not start from the inside of APM area.

MFC after:	1 month
2011-11-28 12:38:24 +00:00
Ed Schouten
6472ac3d8a Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.
The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.
2011-11-07 15:43:11 +00:00
Andrey V. Elsukov
aea26bc05a Our geom withering function could take some time before geom with its
providers and consumers will be destroyed.  Before take some actions
with a geom, check that it is not destroyed at the moment.

Tested by:	nwhitehorn
MFC after:	1 week
2011-10-28 11:45:24 +00:00
Marcel Moolenaar
369fe59de8 Add support for Boot Camp. The support is defined as follows:
o   Detect when Boot Camp is enabled (i.e. the MBR mirrors the GPT).
o   When Boot Camp is enabled, update the MBR whenever we write the GPT.
o   Creation of a Boot Camp enabled GPT is not supported.
o   Automatically disable Boot Camp when the GPT has been changed so that
    there's either no EFI partition or no HFS+ partition.
o   The first 4 partitions (by index) get mirrored in the MBR.

Requested by, discussed with and tested by: kris@pcbsd.org
MFC after: 1 week
2011-10-23 02:51:23 +00:00
Marius Strobl
479a4ef021 Allow to dump on Solaris swap partitions.
PR:		161764
Submitted by:	Peter Jeremy
2011-10-18 20:16:02 +00:00
Andrey V. Elsukov
2b9be05588 Initialize elements of state array when creating the GPT table.
This fixes the problem, when the secondary GPT header is not erased when
partition table destroyed. Move equal operations from g_part_gpt_create
and g_part_gpt_recover to the separate function g_gpt_set_defaults.

Reported by:	dwhite
MFC after:	1 week
2011-06-29 05:41:14 +00:00
Andrey V. Elsukov
671dfdbf11 EBR could contain an early stage of boot code. But we do not support it.
Remove message about non empty bootcode, we can not break something
while GEOM_PART_EBR_COMPAT is defined.

But without GEOM_PART_EBR_COMPAT any changes in EBR are allowed and we
can accidentally wipe the boot code. To do not break anything save
the first EBR chunk and keep it untouched each time when we are
changing EBR. Note that we are still not support boot code for EBR.

PR:		kern/141235
MFC after:	1 month
2011-06-27 12:42:48 +00:00
Andrey V. Elsukov
61162e857a MS Windows NT+ uses 4 bytes at offset 0x1b8 in the MBR to identify
disk drive. The boot0cfg(8) utility preserves these 4 bytes when is
writing bootcode to keep a multiboot ability.
Change gpart's bootcode method to keep DSN if it is not zero. Also
do not allow writing bootcode with size not equal to MBRSIZE.

PR:		kern/157819
Tested by:	Eir Nym
MFC after:	1 month
2011-06-27 10:42:06 +00:00
Andrey V. Elsukov
503e6682cd Change the way how we update bootcode for BSD scheme.
Since the only parameter that we check is size of bootcode, then
allow only two sizes: size of boot1 and size of /boot/boot.
This partially protects users from losing ability to boot if incorrect
bootcode is specified.

Requested by:	ru
2011-06-20 12:22:30 +00:00
Andrey V. Elsukov
38c64884ff Add diagnostic message about not aligned partitions.
Idea from:	ivoras
2011-06-03 06:58:24 +00:00
Andrey V. Elsukov
9854b4eeee Some partitioning tools may have a different opinion about disk
geometry and partitions may start from withing the first track.
If we found such partitions, then do not reserve space of the
first track, only first sector.
2011-05-27 06:37:42 +00:00
Andrey V. Elsukov
6fd1e2e013 Do not truncate available disk space to the closest track boundary. 2011-05-25 09:45:13 +00:00
Andrey V. Elsukov
23a3490034 Do not truncate available disk space to the closest track boundary. 2011-05-25 09:38:12 +00:00
Andrey V. Elsukov
db48d4a92e Do not truncate available disk space to the closest track boundary. 2011-05-25 09:32:19 +00:00
Andrey V. Elsukov
49d12fd5be Remove unused variable.
MFC after:	1 week
2011-05-24 06:46:07 +00:00
Andrey V. Elsukov
e471361279 Remove unused variable.
MFC after:	1 week
2011-05-24 06:44:16 +00:00
Andrey V. Elsukov
d0c8ecb812 Make diagnostic messages more specific. With bootverbose print out
all inconsistencies of integrity in the partition table, not first
found only.

Requested by:	kib
2011-05-16 15:59:50 +00:00
Andrey V. Elsukov
b6c4978f6f Add diagnostic messages for integrity checks. 2011-05-16 12:00:32 +00:00
Andrey V. Elsukov
6e81b75a3c Add a sysctl kern.geom.part.check_integrity for those who has corrupt
partition tables and lost an ability to boot after r221788.
Also unhide an error message from bootverbose, this would help to
easier determine the problem.
2011-05-15 20:03:54 +00:00
Andrey V. Elsukov
c63e8fe201 Add basic metadata integrity check. In case when partition table was
probed and read successfull, but it contains invalid values (e.g.
overlapped partitions, offset or size is out of bounds), then table
will be rejected.

MFC after:	1 month
2011-05-11 19:59:43 +00:00
Andrey V. Elsukov
f30b6bcb60 Limit number of sectors that can be addressed.
MFC after:	1 week
2011-05-08 12:28:13 +00:00
Andrey V. Elsukov
284a82d0bb Limit number of sectors that can be addressed.
MFC after:	1 week
2011-05-08 12:20:30 +00:00
Andrey V. Elsukov
6017ae3fdd Limit number of sectors that can be addressed.
Reject table if blkcount from metadata is greater than provider.
2011-05-08 12:16:39 +00:00
Andrey V. Elsukov
2920db1713 Limit number of sectors that can be addressed.
MFC after:	1 week
2011-05-08 12:11:16 +00:00
Andrey V. Elsukov
4675b2b65f Replace UINT_MAX to UINT32_MAX.
Pointed out by:	kib
MFC after:	1 week
2011-05-08 11:42:51 +00:00
Andrey V. Elsukov
ab0ffb4c88 Limit number of sectors that can be addressed.
MFC after:	1 week
2011-05-08 11:20:27 +00:00
Andrey V. Elsukov
cfbdf6c3c5 Limit number of sectors that can be addressed.
MFC after:	1 week
2011-05-08 11:16:17 +00:00
Gavin Atkinson
47bae5fd09 Remove an incorrect be16toh() that prevented geom_part_apm from working on
little-endian machines.

Reviewed by:	marcel
MFC after:	2 weeks
2011-04-15 12:32:52 +00:00