[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: shrink ext3 filesystem using e2fsprogs and fdisk



Stefan:

I'm afraid you can't use dd for this because as far as I know dd(1)
reads and writes one block at a time and in case new position for file
system overlaps with the present one, using dd you will start
overwriting the end of the file system with the readings from the
start of the file system. In addition, both parted and Gparted don't
have dd as a dependency. However, it should be doable if current and
new position don't overlap using the "skip=" and "seek=" options of
dd..or how did you think?


Jochen, Darac:

here is what Gparted did:

========================================

GParted 0.6.2

Libparted 2.3
Move /dev/sda9 to the right and shrink it from 904.37 GiB to 611.40
GiB  06:02:27    ( SUCCESS )
     	
calibrate /dev/sda9  00:00:00    ( SUCCESS )
     	
path: /dev/sda9
start: 56924160
end: 1953523711
size: 1896599552 (904.37 GiB)
check file system on /dev/sda9 for errors and (if possible) fix them
00:02:16    ( SUCCESS )
     	
e2fsck -f -y -v /dev/sda9
     	
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

308 inodes used (0.00%)
18 non-contiguous files (5.8%)
0 non-contiguous directories (0.0%)
# of inodes with ind/dind/tind blocks: 20/9/0
3363494 blocks used (2.57%)
0 bad blocks
1 large file

169 regular files
130 directories
0 character device files
0 block device files
0 fifos
0 links
0 symbolic links (0 fast symbolic links)
0 sockets
--------
299 files
e2fsck 1.41.12 (17-May-2010)
shrink file system  00:01:31    ( SUCCESS )
     	
resize2fs /dev/sda9 641099775K
     	
Resizing the filesystem on /dev/sda9 to 160274943 (4k) blocks.
The filesystem on /dev/sda9 is now 160274943 blocks long.

resize2fs 1.41.12 (17-May-2010)
shrink partition from 904.37 GiB to 611.40 GiB  00:00:01    ( SUCCESS )
     	
old start: 56924160
old end: 1953523711
old size: 1896599552 (904.37 GiB)
new start: 56924160
new end: 1339123711
new size: 1282199552 (611.40 GiB)
check file system on /dev/sda9 for errors and (if possible) fix them
00:02:47    ( SUCCESS )
     	
e2fsck -f -y -v /dev/sda9
     	
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

308 inodes used (0.00%)
18 non-contiguous files (5.8%)
0 non-contiguous directories (0.0%)
# of inodes with ind/dind/tind blocks: 20/9/0
3821982 blocks used (2.38%)
0 bad blocks
1 large file

169 regular files
130 directories
0 character device files
0 block device files
0 fifos
0 links
0 symbolic links (0 fast symbolic links)
0 sockets
--------
299 files
e2fsck 1.41.12 (17-May-2010)
grow file system to fill the partition  00:01:03    ( SUCCESS )
     	
resize2fs /dev/sda9
     	
Resizing the filesystem on /dev/sda9 to 160274944 (4k) blocks.
The filesystem on /dev/sda9 is now 160274944 blocks long.

resize2fs 1.41.12 (17-May-2010)
check file system on /dev/sda9 for errors and (if possible) fix them
00:02:46    ( SUCCESS )
     	
e2fsck -f -y -v /dev/sda9
     	
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

308 inodes used (0.00%)
18 non-contiguous files (5.8%)
0 non-contiguous directories (0.0%)
# of inodes with ind/dind/tind blocks: 20/9/0
3821982 blocks used (2.38%)
0 bad blocks
1 large file

169 regular files
130 directories
0 character device files
0 block device files
0 fifos
0 links
0 symbolic links (0 fast symbolic links)
0 sockets
--------
299 files
e2fsck 1.41.12 (17-May-2010)
grow partition from 611.40 GiB to 904.37 GiB  00:00:02    ( SUCCESS )
     	
old start: 56924160
old end: 1339123711
old size: 1282199552 (611.40 GiB)
new start: 56924160
new end: 1953523711
new size: 1896599552 (904.37 GiB)
move file system to the right  05:48:52    ( SUCCESS )
     	
perform read-only test  01:54:58    ( SUCCESS )
     	
using internal algorithm
read 611.40 GiB
finding optimal block size
     	
read 16.00 MiB using a block size of 2.00 MiB  00:00:00    ( SUCCESS )
     	
16.00 MiB of 16.00 MiB read
0.215304 seconds
read 16.00 MiB using a block size of 4.00 MiB  00:00:00    ( SUCCESS )
     	
16.00 MiB of 16.00 MiB read
0.250469 seconds
read 16.00 MiB using a block size of 8.00 MiB  00:00:01    ( SUCCESS )
     	
16.00 MiB of 16.00 MiB read
0.215766 seconds
read 16.00 MiB using a block size of 16.00 MiB  00:00:00    ( SUCCESS )
     	
16.00 MiB of 16.00 MiB read
0.253064 seconds
optimal block size is 2.00 MiB
read 611.34 GiB using a block size of 2.00 MiB  01:54:57    ( SUCCESS )
     	
611.34 GiB of 611.34 GiB read
611.40 GiB (656486170624 B) read
perform real move  03:53:54    ( SUCCESS )
     	
using internal algorithm
copy 611.40 GiB
finding optimal block size
     	
copy 16.00 MiB using a block size of 1.00 MiB  00:00:01    ( SUCCESS )
     	
16.00 MiB of 16.00 MiB copied
0.988301 seconds
copy 16.00 MiB using a block size of 2.00 MiB  00:00:00    ( SUCCESS )
     	
16.00 MiB of 16.00 MiB copied
0.53326 seconds
copy 16.00 MiB using a block size of 4.00 MiB  00:00:01    ( SUCCESS )
     	
16.00 MiB of 16.00 MiB copied
0.598635 seconds
copy 16.00 MiB using a block size of 8.00 MiB  00:00:01    ( SUCCESS )
     	
16.00 MiB of 16.00 MiB copied
0.530564 seconds
copy 16.00 MiB using a block size of 16.00 MiB  00:00:00    ( SUCCESS )
     	
16.00 MiB of 16.00 MiB copied
0.522437 seconds
optimal block size is 16.00 MiB
copy 611.32 GiB using a block size of 16.00 MiB  03:53:51    ( SUCCESS )
     	
611.32 GiB of 611.32 GiB copied
611.40 GiB (656486170624 B) copied
shrink partition from 904.37 GiB to 611.40 GiB  00:00:02    ( SUCCESS )
     	
old start: 56924160
old end: 1953523711
old size: 1896599552 (904.37 GiB)
new start: 671324160
new end: 1953523711
new size: 1282199552 (611.40 GiB)
check file system on /dev/sda9 for errors and (if possible) fix them
00:03:07    ( SUCCESS )
     	
e2fsck -f -y -v /dev/sda9
     	
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

308 inodes used (0.00%)
18 non-contiguous files (5.8%)
0 non-contiguous directories (0.0%)
# of inodes with ind/dind/tind blocks: 20/9/0
3821982 blocks used (2.38%)
0 bad blocks
1 large file

169 regular files
130 directories
0 character device files
0 block device files
0 fifos
0 links
0 symbolic links (0 fast symbolic links)
0 sockets
--------
299 files
e2fsck 1.41.12 (17-May-2010)
grow file system to fill the partition  00:00:00    ( SUCCESS )
     	
resize2fs /dev/sda9
     	
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 160274944 blocks long. Nothing to do!

========================================

So looks like for "sliding" the partition, (G)parted uses some sort of
"internal algorithm"? In other words parted or Gparted is definitely
needed for operation like this?


regards,
martin

Kuupäeval 28. märts 2012 13:49 kirjutas Stefan Monnier
<monnier@iro.umontreal.ca>:
>> thanks for replies! Is it possible to "slide" partition using the
>> tools included with e2fsprogs package as well?
>
> The e2fsprogs tools only deal with the needs specific to
> ext[234] partitions.  Sliding a partition can be done for any partition
> you like with `dd'.
>
>
>        Stefan
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: [🔎] jwvehscdefn.fsf-monnier+gmane.linux.debian.user@gnu.org">http://lists.debian.org/[🔎] jwvehscdefn.fsf-monnier+gmane.linux.debian.user@gnu.org
>


Reply to: