From 3461413d283f1bac77e541b1054e775ec105212f Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Mon, 27 May 2013 18:04:44 +0100 Subject: [PATCH] Shrink file systems to exact size (#701075) Ext[234] file systems were being shrunk 1 KiB too small. Ntfs and reiserfs file systems were being shrunk 1 byte too small. The resultant file systems were ending up 1 block smaller than they could have been. This looks like an accidental leftover from when GParted use to: 1) Shrink the file system 1 cylinder too small 2) Shrink the partition 3) Grow the file system to fill the partition Relevant commit: d663c3c277f60da2ac1785c039f25f7920a315e9 removed cylindersize buffering during resize from the filesystems Closes Bug #701075 - Setting the backup boot sector when resizing NTFS --- src/ext2.cc | 4 ++-- src/ntfs.cc | 2 +- src/reiserfs.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ext2.cc b/src/ext2.cc index 9b54010f..2b3bdd45 100644 --- a/src/ext2.cc +++ b/src/ext2.cc @@ -186,8 +186,8 @@ bool ext2::resize( const Partition & partition_new, OperationDetail & operationd if ( ! fill_partition ) str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit( - partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) -1 ) + "K" ; - + partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) ) + "K" ; + return ! execute_command( str_temp, operationdetail ) ; } diff --git a/src/ntfs.cc b/src/ntfs.cc index 3a160af5..d7ca9546 100644 --- a/src/ntfs.cc +++ b/src/ntfs.cc @@ -199,7 +199,7 @@ bool ntfs::resize( const Partition & partition_new, OperationDetail & operationd { str_temp += " -s " ; str_temp += Utils::num_to_str( Utils::round( Utils::sector_to_unit( - partition_new .get_sector_length(), partition_new .sector_size, UNIT_BYTE ) ) -1 ) ; + partition_new .get_sector_length(), partition_new .sector_size, UNIT_BYTE ) ) ) ; } //simulation.. diff --git a/src/reiserfs.cc b/src/reiserfs.cc index 50a35baa..0c4eb27a 100644 --- a/src/reiserfs.cc +++ b/src/reiserfs.cc @@ -160,7 +160,7 @@ bool reiserfs::resize( const Partition & partition_new, OperationDetail & operat if ( ! fill_partition ) { size = " -s " + Utils::num_to_str( Utils::round( Utils::sector_to_unit( - partition_new .get_sector_length(), partition_new .sector_size, UNIT_BYTE ) ) -1 ) ; + partition_new .get_sector_length(), partition_new .sector_size, UNIT_BYTE ) ) ) ; } Glib::ustring cmd = "sh -c 'echo y | resize_reiserfs" + size + " " + partition_new .get_path() + "'" ;