1

When shrinking a partition with GNU Parted, some contents must be moved from the area of the physical disk that will be left out of the new shrunken partition. The contents of those files are of course unchanged.

But could it be that some files in the shrunken partition must be altered by the program?. I mean those files that contain information about the partition or the physical disk. Perhaps within the /etc folder, or perhaps /dev? I don't know, and that is my question:

Which are exactly those files (if any) that change after shrinking a partition?

  • Thanks for your answers. But, not even the file /etc/fstab is altered? Are you sure? – Mephisto Feb 24 '15 at 7:27
  • Why would you expect /etc/fstab to be altered? It contains only a name for the partition, it doesn't describe where the partition is let alone how big it is. – Gilles Feb 25 '15 at 0:16
  • 1
    This question currently has close votes as unclear. I have no idea why: this question is clear to me and evidently also to the people who answered. If someone votes to close, please write a comment explaining why. – Gilles Feb 25 '15 at 0:17
  • @Giles Maybe it is perhaps I assumed that some files do change indeed. I have rewritten the question a bit, so that it has a more doubtful appearance. – Mephisto Feb 25 '15 at 7:43
1

The partition table is changed, this stores the start and end block number of the partitions. This table is not in the partition, and therefore not in the file-system.

Various block addresses are changed within the file-system (this is part of the file-system meta-data). This is part of the mapping from directory entries to physical locations. None of this is stored in a file.

So the short answer is, no files are changed.

You could zip (using an archiver that preserves all file attributes and permissions etc) the file-system, then recreate a smaller one, and unzip it back. This is how you do it if you don't have file-system grow/shrink tools for your file-system.

2

What is changed is the partition table. None of the files in the partitions are changed. Traditionally the partition table is stored in the MBR (Master Boot Record). Alternatively you may have a GPT (GUID partition table).

  • Filesystem metadata will be re-written as well. Nothing that would show up to users as a regular file or directory though. – Bratchley Feb 23 '15 at 20:56
2

Partition layout is a different level than the one on which the files with user (or system) data live. Partition schemes divide a block device, usually a hard drive, into several regions, which operating system kernel can use to support file systems, which in turn are used for hosting files.

When you resize a partition that already holds some file system, that file system's meta data may be changed. Emphasis on the "may" is important - resizing a partition doesn't mandate changing the file system - you can easily have a file system that uses less (or more) space than there is in a partition. If it uses less, all is fine, except for not being able to access the difference between the partition size and the file system boundary. The opposite case is where it gets problematic - the file system is using space that someone else might be claiming (the file system basically overlaps the subsequent partition). You can even have a file system that is completely unaligned with any partitions on a disk - but then again people usually don't do this kind of things.

That said, some programs (parted being one) can try to resize the file system on a partition, provided they find it there and know how to do that - some file systems can only be grown.

1

Your disk is usually structured using a partition table like this:

partition table http://1.1.1.3/bmi/upload.wikimedia.org/wikipedia/commons/thumb/0/07/GUID_Partition_Table_Scheme.svg/400px-GUID_Partition_Table_Scheme.svg.png

A partitions usually contains a file system, which in turn contains all your files and directories.

If you shrink a partition you first have to shrink the file system to cover less space of the partition, afterwards you can shrink the partition.

The details of shrinking a file system depends heavily on the type of file system. There are many very different file systems with very different features. (For some it is not even possible to shrink them.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.