[parted-devel] shrink partition and ext3 file-system on it from the beginning using parted
Håkon Løvdal
hlovdal at gmail.com
Tue Apr 24 22:27:46 UTC 2012
On 24 April 2012 21:28, Martin T <m4rtntns at gmail.com> wrote:
> I was fairly sure that parted is able to handle such operations, but
> for my surprise it's heading away from operations related to file
> systems.. In case one can't use Gparted, I guess the best option is
> to:
I am not sure if this was supported, and the reason for removing
file system code from parted was that it was not maintained and
I think parts of it had known problems that were not fixed. So parted
is consolidating on its core business, partition management, and
then let file system specific programs do the file system operations.
Since parted also is available as a library it is possible to combine
partition management and file system operation in other programs,
like Gparted.
> 1) shrink the file system(resize2fs) and then partition(fdisk) towards
> the beginning
> 2) create a new partition(fdisk) and file system(mkfs.ext3) to the
> space which was freed in the first step
> 3) copy(cp -a) content of first file system to the second file
> system(the one which was created in step 2)
> 4) delete the first partition
> 5) associate the new partition with the correct mount point in /etc/fstab
>
> Any other options/suggestions for shrinking the partition and
> file-system in it starting from the beginning from the CLI?
This sounds like a correct approach, although you can skip step 5
if you use label or uuid instead of device file name to identify the partition.
Also while "cp -a" makes identical copies of files, it will not preserve SELinux
information, so using a tar[1] pipe to copy is probably preferable.
If you pipe through pv[2] as well you get very nice progress information, e.g.
(cd /mnt/source; tar cf - . ) | pv -s $(du -sb /mnt/source | awk
'{print $1}') | (cd /mnt/target; tar xf -)
[1]
http://docs.fedoraproject.org/en-US/Fedora/13/html/SELinux_FAQ/index.html#id3037344
[2]
http://www.ivarch.com/programs/pv.shtml
BR Håkon Løvdal
More information about the parted-devel
mailing list