parted/parted.c: change --align default value to optimal tests/*.sh: adjust for alignment changes where necessary --- NEWS | 3 +++ 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/NEWS b/NEWS index 53477d3..2e1861c 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ GNU parted NEWS -*- outline -*- The default minimum alignment aligns to physical sector size, the default optimal alignment is 1MiB, which is what vista and windows 7 do. + The default alignment (--align option) for newly created partitions has + been changed to optimal. + ** Bug Fixes Fix physical sector size being 0 or smaller then the logical sector size. 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 _______________________________________________ bug-parted mailing list bug-parted@gnu.org http://lists.gnu.org/mailman/listinfo/bug-parted