--- /dev/null
+From 6c4c8464c704b645ddeccce4c4931b8e9d11c3a8 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Fri, 29 Jan 2010 10:58:17 +0100
+Subject: [PATCH parted 1/7] linux: Fixup phys_sector_size setting
+
+1) Use the logical sector size as physical sector size instead of 512
+ when not compiled with libblkid support, this fixes problems
+ with logical sector size > physical sector size.
+2) blkid_topology_get_physical_sector_size() can return 0 when it could
+ not determine the physical sector size, handle this.
+* libparted/arch/linux.c (_device_set_sector_size): Fixup
+phys_sector_size setting.
+---
+ libparted/arch/linux.c | 17 +++++++++++------
+ 2 files changed, 14 insertions(+), 6 deletions(-)
+
+diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
+index f3b54f0..4b7b9f5 100644
+--- a/libparted/arch/linux.c
++++ b/libparted/arch/linux.c
+@@ -654,22 +654,27 @@ _device_set_sector_size (PedDevice* dev)
+ dev->path, strerror (errno), PED_SECTOR_SIZE_DEFAULT);
+ } else {
+ dev->sector_size = (long long)sector_size;
++ dev->phys_sector_size = dev->sector_size;
+ }
+
+ #if USE_BLKID
+ get_blkid_topology(arch_specific);
+ if (!arch_specific->topology) {
+- ped_exception_throw (
+- PED_EXCEPTION_WARNING,
+- PED_EXCEPTION_OK,
+- _("Could not determine minimum io size for %s: %s.\n"
+- "Using the default size (%lld)."),
+- dev->path, strerror (errno), PED_SECTOR_SIZE_DEFAULT);
++ dev->phys_sector_size = 0;
+ } else {
+ dev->phys_sector_size =
+ blkid_topology_get_physical_sector_size(
+ arch_specific->topology);
+ }
++ if (dev->phys_sector_size == 0) {
++ ped_exception_throw (
++ PED_EXCEPTION_WARNING,
++ PED_EXCEPTION_OK,
++ _("Could not determine physical sector size for %s.\n"
++ "Using the logical sector size (%lld)."),
++ dev->path, dev->sector_size);
++ dev->phys_sector_size = dev->sector_size;
++ }
+ #endif
+
+ #if defined __s390__ || defined __s390x__
+--
+1.6.6
+
+From 4bb123a121b54d758f87fc6c38d8edab4ddc6d6b Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Fri, 29 Jan 2010 19:55:10 +0100
+Subject: [PATCH parted 2/7] libparted: Give device_get_*_alignment sane defaults
+
+When the topology info is incomplete or non existent, return something
+more sensible then NULL (which ends up being interpreted as
+PedAlignmentAny in most cases). The default minimum alignment aligns to
+physical sector size, the default optimal alignment is 1 MiB, which is
+what vista and windows 7 do.
+* libparted/device.c (device_get_*_alignment): Add default aligments.
+---
+ libparted/device.c | 30 ++++++++++++++++++++++++++----
+ 2 files changed, 33 insertions(+), 4 deletions(-)
+
+diff --git a/libparted/device.c b/libparted/device.c
+index dda8d74..0f36a03 100644
+--- a/libparted/device.c
++++ b/libparted/device.c
+@@ -501,10 +501,16 @@ ped_device_get_optimal_aligned_constraint(const PedDevice *dev)
+ PedAlignment*
+ ped_device_get_minimum_alignment(const PedDevice *dev)
+ {
++ PedAlignment *align = NULL;
++
+ if (ped_architecture->dev_ops->get_minimum_alignment)
+- return ped_architecture->dev_ops->get_minimum_alignment(dev);
++ align = ped_architecture->dev_ops->get_minimum_alignment(dev);
++
++ if (align == NULL)
++ align = ped_alignment_new(0,
++ dev->phys_sector_size / dev->sector_size);
+
+- return NULL; /* ped_alignment_none */
++ return align;
+ }
+
+ /**
+@@ -521,10 +527,26 @@ ped_device_get_minimum_alignment(const PedDevice *dev)
+ PedAlignment*
+ ped_device_get_optimum_alignment(const PedDevice *dev)
+ {
++ PedAlignment *align = NULL;
++
+ if (ped_architecture->dev_ops->get_optimum_alignment)
+- return ped_architecture->dev_ops->get_optimum_alignment(dev);
++ align = ped_architecture->dev_ops->get_optimum_alignment(dev);
++
++ /* If the arch specific code could not give as an alignment
++ return a default value based on the type of device. */
++ if (align == NULL) {
++ switch (dev->type) {
++ case PED_DEVICE_DASD:
++ align = ped_device_get_minimum_alignment(dev);
++ break;
++ default:
++ /* Align to a grain of 1MiB (like vista / win7) */
++ align = ped_alignment_new(0,
++ 1048576 / dev->sector_size);
++ }
++ }
+
+- return NULL; /* ped_alignment_none */
++ return align;
+ }
+
+ /** @} */
+--
+1.6.6
+
+From 82f42a9e059a8f5dea46090889914041204ebe36 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Fri, 29 Jan 2010 19:59:06 +0100
+Subject: [PATCH parted 3/7] linux: handle incomplete topology information
+
+The topology information returned by libblkid is not always complete
+(as the kernel does not always have complete information).
+This patch makes the linux_get_*_alignment() alignment functions handle
+this. The algorithm used for linux_get_optimum_alignment is:
+1) Always use the reported aligment offset as offset
+2a)If optimal io size is present in the topology info use that as grain
+2b)If optimal io size is not present in topology info and aligment
+ offset is 0 and minimum io size is a power of 2, use the device.c
+ default optimal alignment (grain 1MiB).
+2c)If not 2a and 2b, use the minimum io size, or if that is not defined
+ the physical sector size as grain (iow the minimum alignment).
+The algorithm used for linux_get_minimum_alignment is:
+1) Always use the reported aligment offset as offset
+2) Use the minimum io size, or if that is not defined the physical
+ sector size as grain.
+* libparted/arch/linux.c (linux_get_*_alignment): handle incomplete
+topology information.
+---
+ libparted/arch/linux.c | 25 +++++++++++++++++++++----
+ 1 files changed, 21 insertions(+), 4 deletions(-)
+
+diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
+index 4b7b9f5..a083028 100644
+--- a/libparted/arch/linux.c
++++ b/libparted/arch/linux.c
+@@ -2564,9 +2564,14 @@ PedAlignment*
+ linux_get_minimum_alignment(const PedDevice *dev)
+ {
+ blkid_topology tp = LINUX_SPECIFIC(dev)->topology;
++ if (!tp)
++ return NULL;
+
+- if (!tp || blkid_topology_get_minimum_io_size(tp) == 0)
+- return NULL; /* ped_alignment_none */
++ if (blkid_topology_get_minimum_io_size(tp) == 0)
++ return ped_alignment_new(
++ blkid_topology_get_alignment_offset(tp) /
++ dev->sector_size,
++ dev->phys_sector_size / dev->sector_size);
+
+ return ped_alignment_new(
+ blkid_topology_get_alignment_offset(tp) / dev->sector_size,
+@@ -2577,9 +2582,21 @@ PedAlignment*
+ linux_get_optimum_alignment(const PedDevice *dev)
+ {
+ blkid_topology tp = LINUX_SPECIFIC(dev)->topology;
++ if (!tp)
++ return NULL;
++
++ /* If optimal_io_size is 0 _and_ alignment_offset is 0 _and_
++ minimum_io_size is a power of 2 then go with the device.c default */
++ unsigned long minimum_io_size = blkid_topology_get_minimum_io_size(tp);
++ if (blkid_topology_get_optimal_io_size(tp) == 0 &&
++ blkid_topology_get_alignment_offset(tp) == 0 &&
++ (minimum_io_size & (minimum_io_size - 1)) == 0)
++ return NULL;
+
+- if (!tp || blkid_topology_get_optimal_io_size(tp) == 0)
+- return NULL; /* ped_alignment_none */
++ /* If optimal_io_size is 0 and we don't meet the other criteria
++ for using the device.c default, return the minimum alignment. */
++ if (blkid_topology_get_optimal_io_size(tp) == 0)
++ return linux_get_minimum_alignment(dev);
+
+ return ped_alignment_new(
+ blkid_topology_get_alignment_offset(tp) / dev->sector_size,
+--
+1.6.6
+
+From 4be1b004ad2c576fc093ca5227e22bb78b35f1fd Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Fri, 29 Jan 2010 23:28:13 +0100
+Subject: [PATCH parted 4/7] parted: Honor --align option also in mkpartfs, resize and print cmds
+
+parted/parted.c (do_mkpartfs,do_print,do_resize): honor --align
+---
+ parted/parted.c | 26 +++++++++++++++++++++++++-
+ 1 files changed, 25 insertions(+), 1 deletions(-)
+
+diff --git a/parted/parted.c b/parted/parted.c
+index c4d1779..5ba8bbf 100644
+--- a/parted/parted.c
++++ b/parted/parted.c
+@@ -949,6 +949,11 @@ do_mkpartfs (PedDevice** dev)
+ if (!disk)
+ goto error;
+
++ if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
++ if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
++ alignment == ALIGNMENT_CYLINDER))
++ goto error_destroy_disk;
++
+ if (!ped_disk_type_check_feature (disk->type, PED_DISK_TYPE_EXTENDED)) {
+ part_type = PED_PARTITION_NORMAL;
+ } else {
+@@ -989,7 +994,14 @@ do_mkpartfs (PedDevice** dev)
+ range_end);
+ PED_ASSERT (user_constraint != NULL, return 0);
+
+- dev_constraint = ped_device_get_constraint (*dev);
++ if (alignment == ALIGNMENT_OPTIMAL)
++ dev_constraint =
++ ped_device_get_optimal_aligned_constraint(*dev);
++ else if (alignment == ALIGNMENT_MINIMAL)
++ dev_constraint =
++ ped_device_get_minimal_aligned_constraint(*dev);
++ else
++ dev_constraint = ped_device_get_constraint(*dev);
+ PED_ASSERT (dev_constraint != NULL, return 0);
+
+ final_constraint = ped_constraint_intersect (user_constraint,
+@@ -1353,6 +1365,11 @@ do_print (PedDevice** dev)
+ if (!disk)
+ goto error;
+
++ if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
++ if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
++ alignment == ALIGNMENT_CYLINDER))
++ goto error_destroy_disk;
++
+ peek_word = command_line_peek_word ();
+ if (peek_word) {
+ if (strncmp (peek_word, "devices", 7) == 0) {
+@@ -1697,6 +1697,7 @@ do_print (PedDevice** dev)
+
+ return 1;
+
++error_destroy_disk:
+ ped_disk_destroy (disk);
+ error:
+ return 0;
+@@ -1862,6 +1881,11 @@ do_resize (PedDevice** dev)
+ if (!disk)
+ goto error;
+
++ if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
++ if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
++ alignment == ALIGNMENT_CYLINDER))
++ goto error_destroy_disk;
++
+ if (!command_line_get_partition (_("Partition number?"), disk, &part))
+ goto error_destroy_disk;
+ if (part->type != PED_PARTITION_EXTENDED) {
+--
+1.6.6
+
+From 950bfc92b1a67c8baa8c7cfab04103bd38a2d24b Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Fri, 29 Jan 2010 22:51:30 +0100
+Subject: [PATCH parted 5/7] parted: change warnings when initial constrained mkpart fails
+
+In do_mkpart we first try to create a partition using a constraint
+derived from the user input intersected with the devices alignment
+needs. And if that fails we try again without any constraint.
+
+However the warning given when this happens only takes into account
+the user not getting what he asked for, while the alignment might be
+a problem too (or even the only problem). So this patch adds a check
+to see if the user really did not get what he asked before giving that
+warning, and adds a new check + warning to see if the created partition
+is properly aligned.
+*parted/parted.c (do_mkpart,do_mkpartfs): change warnings when initial
+constrained mkpart fails.
+---
+ parted/parted.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++------
+ 1 files changed, 52 insertions(+), 7 deletions(-)
+
+diff --git a/parted/parted.c b/parted/parted.c
+index 5ba8bbf..3ce356f 100644
+--- a/parted/parted.c
++++ b/parted/parted.c
+@@ -178,6 +178,8 @@ static TimerContext timer_context;
+
+ static int _print_list ();
+ static void _done (PedDevice* dev);
++static bool partition_align_check (PedDisk const *disk,
++ PedPartition const *part, enum AlignmentType a_type);
+
+ static void
+ _timer_handler (PedTimer* timer, void* context)
+@@ -833,7 +835,12 @@ do_mkpart (PedDevice** dev)
+ bool added_ok = ped_disk_add_partition (disk, part,
+ constraint_any);
+ ped_constraint_destroy (constraint_any);
+- if (added_ok) {
++
++ if (!added_ok)
++ goto error_remove_part;
++
++ if (!ped_geometry_test_sector_inside(range_start, part->geom.start) ||
++ !ped_geometry_test_sector_inside(range_end, part->geom.end)) {
+ start_usr = ped_unit_format (*dev, start);
+ end_usr = ped_unit_format (*dev, end);
+ start_sol = ped_unit_format (*dev, part->geom.start);
+@@ -867,8 +874,23 @@ do_mkpart (PedDevice** dev)
+ /* undo partition addition */
+ goto error_remove_part;
+ }
+- } else {
+- goto error_remove_part;
++ }
++
++ if ((alignment == ALIGNMENT_OPTIMAL &&
++ !partition_align_check(disk, part, PA_OPTIMUM)) ||
++ (alignment == ALIGNMENT_MINIMAL &&
++ !partition_align_check(disk, part, PA_MINIMUM))) {
++ if (ped_exception_throw(
++ PED_EXCEPTION_WARNING,
++ (opt_script_mode
++ ? PED_EXCEPTION_OK
++ : PED_EXCEPTION_IGNORE_CANCEL),
++ _("The resulting partition is not properly "
++ "aligned for best performance.")) ==
++ PED_EXCEPTION_CANCEL) {
++ /* undo partition addition */
++ goto error_remove_part;
++ }
+ }
+ } else {
+ ped_exception_leave_all();
+@@ -1018,8 +1040,16 @@ do_mkpartfs (PedDevice** dev)
+ if (!added_ok) {
+ ped_exception_leave_all();
+
+- if (ped_disk_add_partition (disk, part,
+- ped_constraint_any (*dev))) {
++ PedConstraint *constraint_any = ped_constraint_any (*dev);
++ bool added_ok = ped_disk_add_partition (disk, part,
++ constraint_any);
++ ped_constraint_destroy (constraint_any);
++
++ if (!added_ok)
++ goto error_remove_part;
++
++ if (!ped_geometry_test_sector_inside(range_start, part->geom.start) ||
++ !ped_geometry_test_sector_inside(range_end, part->geom.end)) {
+ start_usr = ped_unit_format (*dev, start);
+ end_usr = ped_unit_format (*dev, end);
+ start_sol = ped_unit_format (*dev, part->geom.start);
+@@ -1048,8 +1078,23 @@ do_mkpartfs (PedDevice** dev)
+ /* undo partition addition */
+ goto error_remove_part;
+ }
+- } else {
+- goto error_remove_part;
++ }
++
++ if ((alignment == ALIGNMENT_OPTIMAL &&
++ !partition_align_check(disk, part, PA_OPTIMUM)) ||
++ (alignment == ALIGNMENT_MINIMAL &&
++ !partition_align_check(disk, part, PA_MINIMUM))) {
++ if (ped_exception_throw(
++ PED_EXCEPTION_WARNING,
++ (opt_script_mode
++ ? PED_EXCEPTION_OK
++ : PED_EXCEPTION_IGNORE_CANCEL),
++ _("The resulting partition is not properly "
++ "aligned for best performance.")) ==
++ PED_EXCEPTION_CANCEL) {
++ /* undo partition addition */
++ goto error_remove_part;
++ }
+ }
+ } else {
+ ped_exception_leave_all();
+--
+1.6.6
+
+From 6c2db872647816b84a5efc8c8995a019d47f89a9 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Sat, 30 Jan 2010 17:46:23 +0100
+Subject: [PATCH parted 6/7] Makefiles: Fix check-other-sector_sizes
+
+Atleast on my system check-other-sector_sizes was actually just testing
+512 bytes sectors 4 times. This fixes this.
+* Makefile.am: Fix check-other-sector_sizes
+---
+ Makefile.am | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 0e80967..d5a32ef 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -1415,7 +1415,7 @@ MAINTAINERCLEANFILES += \
+
+ .PHONY: ss-1024 ss-2048 ss-4096
+ ss-1024 ss-2048 ss-4096:
+- PARTED_SECTOR_SIZE=$(ss-,,$@) $(MAKE) check-recursive
++ PARTED_SECTOR_SIZE=$(subst ss-,,$@) $(MAKE) check-recursive
+
+ # Run the regression test suite with different settings,
+ # to ensure it works with simulated partition sizes > 512.
+--
+1.6.6
+
+From 6ba62ce27f84c5c931d021f4be4af0cce011bdbf Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Fri, 29 Jan 2010 20:30:18 +0100
+Subject: [PATCH parted 7/7] parted: Change default alignment to optimal
+
+parted/parted.c: change --align default value to optimal
+tests/*.sh: adjust for alignment changes where necessary
+---
+ parted/parted.c | 2 +-
+ tests/t0220-gpt-msftres.sh | 4 ++--
+ tests/t0280-gpt-corrupt.sh | 6 +++---
+ tests/t2100-mkswap.sh | 14 +++++++-------
+ tests/t2200-dos-label-recog.sh | 11 ++++++-----
+ tests/t2300-dos-label-extended-bootcode.sh | 12 ++++++------
+ tests/t3000-resize-fs.sh | 4 ++--
+ tests/t4100-dvh-partition-limits.sh | 4 +++-
+ tests/t4100-msdos-partition-limits.sh | 22 +++++-----------------
+ tests/t4100-msdos-starting-sector.sh | 10 +++++-----
+ tests/t5000-tags.sh | 6 +++---
+ tests/t8000-loop.sh | 1 +
+ tests/t9021-maxima.sh | 3 ++-
+ 14 files changed, 49 insertions(+), 53 deletions(-)
+
+diff --git a/parted/parted.c b/parted/parted.c
+index 3ce356f..e35ce6a 100644
+--- a/parted/parted.c
++++ b/parted/parted.c
+@@ -133,7 +133,7 @@ int pretend_input_tty = 0;
+ int opt_machine_mode = 0;
+ int disk_is_modified = 0;
+ int is_toggle_mode = 0;
+-int alignment = ALIGNMENT_CYLINDER;
++int alignment = ALIGNMENT_OPTIMAL;
+
+ static const char* number_msg = N_(
+ "NUMBER is the partition number used by Linux. On MS-DOS disk labels, the "
+diff --git a/tests/t0220-gpt-msftres.sh b/tests/t0220-gpt-msftres.sh
+index 8ef885f..bbc415b 100755
+--- a/tests/t0220-gpt-msftres.sh
++++ b/tests/t0220-gpt-msftres.sh
+@@ -35,8 +35,8 @@ NTFS
+ reiserfs
+ '
+
+-start=200
+-part_size=100
++start=2048
++part_size=2048
+ n_types=$(echo "$fs_types"|wc -w)
+
+ # Create a "disk" with enough room for one partition per FS type,
+diff --git a/tests/t0280-gpt-corrupt.sh b/tests/t0280-gpt-corrupt.sh
+index 28c9035..5c48116 100755
+--- a/tests/t0280-gpt-corrupt.sh
++++ b/tests/t0280-gpt-corrupt.sh
+@@ -43,7 +43,7 @@ poke()
+ dev=loop-file
+
+ ss=$sector_size_
+-n_sectors=200
++n_sectors=5000
+
+ fail=0
+ dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
+@@ -62,7 +62,7 @@ printf "BYT;\n$dev:${n_sectors}s:file:$sector_size_:$sector_size_:gpt:;\n" \
+ compare exp out || fail=1
+
+ # create a partition
+-parted -s $dev mkpart sw linux-swap 60s 100s > empty 2>&1 || fail=1
++parted -s $dev mkpart sw linux-swap 2048s 4095s > empty 2>&1 || fail=1
+ compare /dev/null empty || fail=1
+
+ # We're going to change the name of the first partition,
+@@ -123,7 +123,7 @@ compare exp err || fail=1
+ parted -m -s $dev u s print > out 2>&1 || fail=1
+
+ # check for expected output
+-printf "BYT;\nfile\n1:60s:100s:41s::foo:;\n" > exp || fail=1
++printf "BYT;\nfile\n1:2048s:4095s:2048s::foo:;\n" > exp || fail=1
+ sed "s/.*gpt:;/file/" out > k && mv k out || fail=1
+ compare exp out || fail=1
+
+diff --git a/tests/t2100-mkswap.sh b/tests/t2100-mkswap.sh
+index 1462e5d..1e4c444 100755
+--- a/tests/t2100-mkswap.sh
++++ b/tests/t2100-mkswap.sh
+@@ -27,7 +27,7 @@ require_512_byte_sector_size_
+ # table, ensure that the proper file system type (0x82) is used.
+ # Some releases, e.g. parted-1.8.8 would mistakenly use 0x83.
+ ######################################################################
+-N=1M
++N=2M
+ dev=loop-file
+ dev2=loop-file-2
+ test_expect_success \
+@@ -41,7 +41,7 @@ test_expect_success 'expect no output' 'compare out /dev/null'
+
+ test_expect_success \
+ 'create a partition' \
+- 'parted -s $dev mkpart primary 0 1 > out 2>&1'
++ 'parted -s $dev mkpart primary 2048s 4095s > out 2>&1'
+ test_expect_success 'expect no output' 'compare out /dev/null'
+
+ test_expect_success \
+@@ -66,7 +66,7 @@ test_expect_success 'expect no output' 'compare out /dev/null'
+
+ test_expect_success \
+ 'create another partition' \
+- 'parted -s $dev2 mkpart primary 0 1 > out 2>&1'
++ 'parted -s $dev2 mkpart primary 2048s 4095s > out 2>&1'
+ test_expect_success 'expect no output' 'compare out /dev/null'
+
+ test_expect_success \
+@@ -74,13 +74,13 @@ test_expect_success \
+ 'parted -s $dev2 mkfs 1 "linux-swap(v1)" > out 2>&1'
+ test_expect_success 'expect no output' 'compare out /dev/null'
+
+-# partition starts at offset 16384; swap UUID is 1036 bytes in
++# partition starts at offset 1048576; swap UUID is 1036 bytes in
+ test_expect_success \
+ 'extract UUID 1' \
+- 'od -t x1 -An -j17420 -N16 $dev > uuid1'
++ 'od -t x1 -An -j1049612 -N16 $dev > uuid1'
+ test_expect_success \
+ 'extract UUID 2' \
+- 'od -t x1 -An -j17420 -N16 $dev2 > uuid2'
++ 'od -t x1 -An -j1049612 -N16 $dev2 > uuid2'
+ test_expect_failure \
+ 'two linux-swap file systems have different UUIDs' \
+ 'compare uuid1 uuid2'
+@@ -92,7 +92,7 @@ test_expect_success 'expect no output' 'compare out /dev/null'
+
+ test_expect_success \
+ 'extract new UUID 2' \
+- 'od -t x1 -An -j17420 -N16 $dev2 > uuid2-new'
++ 'od -t x1 -An -j1049612 -N16 $dev2 > uuid2-new'
+ test_expect_success \
+ 'check preserves linux-swap UUID' \
+ 'compare uuid2 uuid2-new'
+diff --git a/tests/t2200-dos-label-recog.sh b/tests/t2200-dos-label-recog.sh
+index 1254226..92e6d42 100755
+--- a/tests/t2200-dos-label-recog.sh
++++ b/tests/t2200-dos-label-recog.sh
+@@ -25,11 +25,12 @@ test_description='improved MSDOS partition-table recognition'
+ # parted 1.8.8.1.29 and earlier would fail to recognize a DOS
+ # partition table.
+ ######################################################################
+-N=10M
++ss=$sector_size_
++N=8192
+ dev=loop-file
+ test_expect_success \
+ 'create a file to simulate the underlying device' \
+- 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
++ 'dd if=/dev/null of=$dev bs=$ss seek=$N 2> /dev/null'
+
+ test_expect_success \
+ 'label the test disk' \
+@@ -39,8 +40,8 @@ test_expect_success 'expect no output' 'compare out /dev/null'
+ test_expect_success \
+ 'create two partition' \
+ '
+- parted -s $dev mkpart primary 1s 40s > out 2>&1 &&
+- parted -s $dev mkpart primary 41s 80s >> out 2>&1
++ parted -s $dev mkpart primary 2048s 4095s > out 2>&1 &&
++ parted -s $dev mkpart primary 4096s 8191s >> out 2>&1
+
+ '
+ test_expect_success 'expect no output' 'compare out /dev/null'
+@@ -54,7 +55,7 @@ test_expect_success \
+ '
+ parted -m -s $dev unit s p > out &&
+ tail -2 out > k && mv k out &&
+- printf "1:1s:40s:40s:::;\n2:41s:80s:40s:::;\n" > exp
++ printf "1:2048s:4095s:2048s:::;\n2:4096s:8191s:4096s:::;\n" > exp
+
+ '
+ test_expect_success 'expect two partitions' 'compare out exp'
+diff --git a/tests/t2300-dos-label-extended-bootcode.sh b/tests/t2300-dos-label-extended-bootcode.sh
+index 6f2b219..73fa45b 100755
+--- a/tests/t2300-dos-label-extended-bootcode.sh
++++ b/tests/t2300-dos-label-extended-bootcode.sh
+@@ -27,7 +27,7 @@ bootcode_size=446
+
+ test_expect_success \
+ 'Create the test file' \
+- 'dd if=/dev/zero of=$dev bs=1024c count=100 >/dev/null 2>&1'
++ 'dd if=/dev/zero of=$dev bs=1M count=4 >/dev/null 2>&1'
+
+ test_expect_success \
+ 'Create msdos label' \
+@@ -36,23 +36,23 @@ test_expect_success 'Expect no output' 'compare out /dev/null'
+
+ test_expect_success \
+ 'Create extended partition' \
+- 'parted -s $dev mkpart extended 32s 127s > out 2>&1'
++ 'parted -s $dev mkpart extended 2048s 8191s > out 2>&1'
+ test_expect_success 'Expect no output' 'compare out /dev/null'
+
+ test_expect_success \
+ 'Create logical partition' \
+- 'parted -s $dev mkpart logical 64s 127s > out 2>&1'
++ 'parted -s $dev mkpart logical 4096s 8191s > out 2>&1'
+ test_expect_success 'Expect no output' 'compare out /dev/null'
+
+ test_expect_success \
+ 'Install fake bootcode' \
+ 'printf %0${bootcode_size}d 0 > in &&
+- dd if=in of=$dev bs=1c seek=16384 count=$bootcode_size \
++ dd if=in of=$dev bs=1c seek=1M count=$bootcode_size \
+ conv=notrunc > /dev/null 2>&1'
+
+ test_expect_success \
+ 'Save fake bootcode for later comparison' \
+- 'dd if=$dev of=before bs=1 skip=16384 count=$bootcode_size > /dev/null 2>&1'
++ 'dd if=$dev of=before bs=1 skip=1M count=$bootcode_size > /dev/null 2>&1'
+
+ test_expect_success \
+ 'Do something to the label' \
+@@ -61,7 +61,7 @@ test_expect_success 'Expect no output' 'compare out /dev/null'
+
+ test_expect_success \
+ 'Extract the bootcode for comparison' \
+- 'dd if=$dev of=after bs=1 skip=16384 count=$bootcode_size > /dev/null 2>&1'
++ 'dd if=$dev of=after bs=1 skip=1M count=$bootcode_size > /dev/null 2>&1'
+
+ test_expect_success \
+ 'Expect bootcode has not changed' \
+diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
+index 2abc71b..d6af67d 100755
+--- a/tests/t3000-resize-fs.sh
++++ b/tests/t3000-resize-fs.sh
+@@ -64,8 +64,8 @@ for fs_type in hfs+ fat32; do
+
+ # create an empty $fs_type partition, cylinder aligned, size > 256 MB
+ parted -s $dev mkpart primary $fs_type $start $default_end > out 2>&1 || fail=1
+- # expect no output
+- compare out /dev/null || fail=1
++ echo "Warning: The resulting partition is not properly aligned for best performance." > exp
++ compare out exp || fail=1
+
+ # print partition table
+ parted -m -s $dev u s p > out 2>&1 || fail=1
+diff --git a/tests/t4100-dvh-partition-limits.sh b/tests/t4100-dvh-partition-limits.sh
+index 01e3078..17b1530 100755
+--- a/tests/t4100-dvh-partition-limits.sh
++++ b/tests/t4100-dvh-partition-limits.sh
+@@ -33,11 +33,13 @@ fs=fs_file
+ mp=`pwd`/mount-point
+ n=4096
+
++# We must use -f otherwise newer mkfs.xfs fail with:
++# mkfs.xfs: probe of test.img failed, cannot detect existing filesystem.
+ test_expect_success \
+ 'create an XFS file system' \
+ '
+ dd if=/dev/zero of=$fs bs=1MB count=2 seek=20 &&
+- mkfs.xfs -q $fs &&
++ mkfs.xfs -f -q $fs &&
+ mkdir "$mp"
+
+ '
+diff --git a/tests/t4100-msdos-partition-limits.sh b/tests/t4100-msdos-partition-limits.sh
+index 0c5b404..b9f168a 100755
+--- a/tests/t4100-msdos-partition-limits.sh
++++ b/tests/t4100-msdos-partition-limits.sh
+@@ -33,11 +33,13 @@ fs=fs_file
+ mp=`pwd`/mount-point
+ n=4096
+
++# We must use -f otherwise newer mkfs.xfs fail with:
++# mkfs.xfs: probe of test.img failed, cannot detect existing filesystem.
+ test_expect_success \
+ 'create an XFS file system' \
+ '
+ dd if=/dev/zero of=$fs bs=1MB count=2 seek=20 &&
+- mkfs.xfs -q $fs &&
++ mkfs.xfs -f -q $fs &&
+ mkdir "$mp"
+
+ '
+@@ -102,27 +104,13 @@ test_expect_success \
+ 'check for new diagnostic' \
+ 'bad_part_length 4294967296 > exp && diff -u err exp'
+
+-# FIXME: investigate this.
+-# Unexpectedly to me, both of these failed with this same diagnostic:
+-#
+-# Error: partition length of 4294967296 sectors exceeds the \
+-# DOS-partition-table-imposed maximum of 2^32-1" > exp &&
+-#
+-# I expected the one below to fail with a length of _4294967297_.
+-# Debugging, I see that _check_partition *does* detect this,
+-# but the diagnostic doesn't get displayed because of the wonders
+-# of parted's exception mechanism.
+-
+ test_expect_failure \
+ "$table_type: a partition length of 2^32+1 sectors provokes failure." \
+ 'do_mkpart $n $(echo $n+2^32|bc) > err 2>&1'
+
+-# FIXME: odd that we asked for 2^32+1, yet the diagnostic says 2^32
+-# FIXME: Probably due to constraints.
+-# FIXME: For now, just accept the current output.
+ test_expect_success \
+ 'check for new diagnostic' \
+- 'bad_part_length 4294967296 > exp && diff -u err exp'
++ 'bad_part_length 4294967297 > exp && diff -u err exp'
+
+ # =========================================================
+ # Now consider partition starting sector numbers.
+@@ -164,7 +152,7 @@ test_expect_failure \
+ 'do_mkpart_start_and_len $(echo 2^32+1|bc) 1000 > err 2>&1'
+ test_expect_success \
+ 'check for new diagnostic' \
+- 'bad_start_sector 4294967296 > exp && diff -u err exp'
++ 'bad_start_sector 4294967297 > exp && diff -u err exp'
+
+ done
+
+diff --git a/tests/t4100-msdos-starting-sector.sh b/tests/t4100-msdos-starting-sector.sh
+index 7761e75..3d0233b 100755
+--- a/tests/t4100-msdos-starting-sector.sh
++++ b/tests/t4100-msdos-starting-sector.sh
+@@ -27,7 +27,7 @@ ss=$sector_size_
+ # consistent in the use of metadata padding for msdos labels.
+ ######################################################################
+
+-N=200 # number of sectors
++N=4096 # number of sectors
+ dev=loop-file
+ test_expect_success \
+ 'create a file to simulate the underlying device' \
+@@ -43,7 +43,7 @@ fail=0
+ cat <<EOF > exp || fail=1
+ BYT;
+ path:${N}s:file:$ss:$ss:msdos:;
+-1:32s:127s:96s:free;
++1:32s:4095s:4064s:free;
+ EOF
+
+ test_expect_success 'create expected output file' 'test $fail = 0'
+@@ -62,15 +62,15 @@ fail=0
+ cat <<EOF > exp || fail=1
+ BYT;
+ path:${N}s:file:$ss:$ss:msdos:;
+-1:32s:50s:19s:free;
+-1:51s:199s:149s:::;
++1:32s:2047s:2016s:free;
++1:2048s:4095s:2048s:::;
+ EOF
+
+ test_expect_success 'create expected output file' 'test $fail = 0'
+
+ test_expect_success \
+ 'create a partition at the end of the label' \
+- 'parted -s $dev mkpart primary 51s 199s'
++ 'parted -s $dev mkpart primary 2048s 4095s'
+
+ test_expect_success \
+ 'display output of label with partition' \
+diff --git a/tests/t5000-tags.sh b/tests/t5000-tags.sh
+index d1e9533..9b0a1cc 100755
+--- a/tests/t5000-tags.sh
++++ b/tests/t5000-tags.sh
+@@ -22,10 +22,10 @@ test_description="test bios_grub flag in gpt labels"
+ ss=$sector_size_
+
+ dev=loop-file
+-N=300 # number of sectors
++N=4200 # number of sectors
+
+-part_sectors=128
+-start_sector=60
++part_sectors=2048
++start_sector=2048
+ end_sector=$(expr $start_sector + $part_sectors - 1)
+
+ test_expect_success \
+diff --git a/tests/t8000-loop.sh b/tests/t8000-loop.sh
+index 313e3b8..cba3454 100755
+--- a/tests/t8000-loop.sh
++++ b/tests/t8000-loop.sh
+@@ -25,6 +25,7 @@ fi
+ . $srcdir/t-lib.sh
+
+ require_root_
++lvm_init_root_dir_
+
+ d1= f1=
+ cleanup_()
+diff --git a/tests/t9021-maxima.sh b/tests/t9021-maxima.sh
+index 999a696..c8316bc 100755
+--- a/tests/t9021-maxima.sh
++++ b/tests/t9021-maxima.sh
+@@ -25,6 +25,7 @@ fi
+ . $srcdir/t-lib.sh
+
+ fail=0
++ss=$sector_size_
+ dev=dev-file
+ PATH="..:$PATH"
+ export PATH
+@@ -33,7 +34,7 @@ export PATH
+ for t in msdos gpt dvh sun mac bsd amiga loop pc98; do
+ echo $t
+ rm -f $dev
+- dd if=/dev/zero of=$dev bs=512 count=1 seek=10000 || { fail=1; continue; }
++ dd if=/dev/zero of=$dev bs=$ss count=1 seek=10000 || { fail=1; continue; }
+ parted -s $dev mklabel $t || { fail=1; continue; }
+
+ #case $t in pc98) sleep 999d;; esac
+--
+1.6.6
+