Shrink an resize of file systems
![](https://seccdn.libravatar.org/avatar/c0cfd5b7246be604feb77f43a3c9626f.jpg?s=120&d=mm&r=g)
Hi, I would like to collect some ideas about shrinking and resizing (expanding) of file systems. Background: On a SD card, e.g. 16GB for a Raspi, the last partition is empty for the most part: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS mmcblk0 179:0 0 14,8G 0 disk ├─mmcblk0p1 179:1 0 64M 0 part ├─mmcblk0p2 179:2 0 2G 0 part └─mmcblk0p3 179:3 0 12,8G 0 part resize2fs -M should do the job of manual shrinking (in case of ext4) When the system is started again, the file system should be automatically expanded to the max available size on the SD card. Any proposal how to achieve this? Thanks Axel
![](https://seccdn.libravatar.org/avatar/9a22d987cba65984271fe481dc6694c5.jpg?s=120&d=mm&r=g)
Hi Axel, On Tue, 17 May 2022, 12:26:05 +0200, Axel Braun wrote:
Hi,
I would like to collect some ideas about shrinking and resizing (expanding) of file systems. Background: On a SD card, e.g. 16GB for a Raspi, the last partition is empty for the most part:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS mmcblk0 179:0 0 14,8G 0 disk ├─mmcblk0p1 179:1 0 64M 0 part ├─mmcblk0p2 179:2 0 2G 0 part └─mmcblk0p3 179:3 0 12,8G 0 part
resize2fs -M should do the job of manual shrinking (in case of ext4)
When the system is started again, the file system should be automatically expanded to the max available size on the SD card.
Any proposal how to achieve this?
I would create a one time start job which calls resize2fs *without* specifying any 'size' parameter for the last partition; according to the manual: If size parameter is not specified, it will default to the size of the partition. As the final step, the script would remove itself.
Thanks Axel
HTH, cheers. l8er manfred
![](https://seccdn.libravatar.org/avatar/78c592e6e354db3e4ae1f8c2dccc892f.jpg?s=120&d=mm&r=g)
On Tue, 17 May 2022 13:36:40 +0200 Manfred Hollstein <mhollstein@t-online.de> wrote:
Hi Axel,
On Tue, 17 May 2022, 12:26:05 +0200, Axel Braun wrote:
Hi,
I would like to collect some ideas about shrinking and resizing (expanding) of file systems. Background: On a SD card, e.g. 16GB for a Raspi, the last partition is empty for the most part:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS mmcblk0 179:0 0 14,8G 0 disk ├─mmcblk0p1 179:1 0 64M 0 part ├─mmcblk0p2 179:2 0 2G 0 part └─mmcblk0p3 179:3 0 12,8G 0 part
resize2fs -M should do the job of manual shrinking (in case of ext4)
When the system is started again, the file system should be automatically expanded to the max available size on the SD card.
Any proposal how to achieve this?
I would create a one time start job which calls resize2fs *without* specifying any 'size' parameter for the last partition; according to the manual:
If size parameter is not specified, it will default to the size of the partition.
As the final step, the script would remove itself.
I wonder how one could identify the device in advance to be included in a script? As an example I have USB drives that regularly show up under the same dev-name but that is still unreliable.
Thanks Axel
HTH, cheers.
l8er manfred
![](https://seccdn.libravatar.org/avatar/e85bb1c491d4dd3ebd96110df58f8739.jpg?s=120&d=mm&r=g)
Hi Gents, Am Dienstag, 17. Mai 2022, 14:30:24 CEST schrieb Ben T. Fender:
On Tue, 17 May 2022 13:36:40 +0200 Manfred Hollstein <mhollstein@t-online.de> wrote:
I would create a one time start job which calls resize2fs *without* specifying any 'size' parameter for the last partition; according to the manual:
If size parameter is not specified, it will default to the size of the partition.
As the final step, the script would remove itself.
I wonder how one could identify the device in advance to be included in a script? As an example I have USB drives that regularly show up under the same dev-name but that is still unreliable.
Yes, that was my thought on that as well. most likely it will be /dev/ mmcblk0p3. And it does not have to be a 'global' solution. There is a firstboot functionality in YaST ( I think) - maybe this can be used to trigger the scrip? Cheers Axel
![](https://seccdn.libravatar.org/avatar/0ab1491ab50291fb6654bd364f499a4f.jpg?s=120&d=mm&r=g)
Op dinsdag 17 mei 2022 12:26:05 CEST schreef Axel Braun:
Hi,
I would like to collect some ideas about shrinking and resizing (expanding) of file systems. Background: On a SD card, e.g. 16GB for a Raspi, the last partition is empty for the most part:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS mmcblk0 179:0 0 14,8G 0 disk ├─mmcblk0p1 179:1 0 64M 0 part ├─mmcblk0p2 179:2 0 2G 0 part └─mmcblk0p3 179:3 0 12,8G 0 part
resize2fs -M should do the job of manual shrinking (in case of ext4)
When the system is started again, the file system should be automatically expanded to the max available size on the SD card.
Any proposal how to achieve this?
Thanks Axel
On a system that accepts the SD, not the RPi, you can use gparted and resize and move partitions around on that card. If you delete a partition and recreate it, which was part of the system meant for the RPi, remember that you need to adapt the file /etc/fstab. This file uses UUIDs to point to partitions, which change when you create a new partition. The easiest way is to use labels in /etc/fstab. -- fr.gr. member openSUSE Freek de Kruijf
participants (5)
-
Axel Braun
-
Axel Braun
-
Ben T. Fender
-
Freek de Kruijf
-
Manfred Hollstein