Hi,
I installed DietPi on a 4GB SD card, set up everything, working fine. I made an image from the installed system than copied to a 16GB SD card.
I know that the first step of the installation is that the installer expand the root file system to the maximum size of SD card but how can I do this after the migration? In raspbian config there is a setup of this but in dietpi config I haven't seen.
Is there any method to do this after the installation?
Thanks!
Regards,
nemeth9
Expand root partition after the installation
Re: Expand root partition after the installation
Hi Nemeth9,nemeth9 wrote:Hi,
I installed DietPi on a 4GB SD card, set up everything, working fine. I made an image from the installed system than copied to a 16GB SD card.
I know that the first step of the installation is that the installer expand the root file system to the maximum size of SD card but how can I do this after the migration? In raspbian config there is a setup of this but in dietpi config I haven't seen.
Is there any method to do this after the installation?
Thanks!
Regards,
nemeth9
As per the re-partition and resize ext4 code in DietPi: https://github.com/Fourdee/DietPi/blob/ ... ot#L44-L72.
You could essentially make the following scripts to complete the above:
Remember to chmod +x before executing them.
Resize Partition (run 1st):
Code: Select all
#!/bin/bash
#Stop Services
/DietPi/dietpi/dietpi-services stop
#Resize partition
cat << _EOF_ | fdisk /dev/mmcblk0
p
d
2
n
p
2
$(parted /dev/mmcblk0 -ms unit s p | grep ':ext4::;' | sed 's/:/ /g' | sed 's/s//g' | awk '{ print $2 }')
p
w
_EOF_
Code: Select all
reboot
Code: Select all
#!/bin/bash
# Stop Services
/DietPi/dietpi/dietpi-services stop
# Resize Filesystem to new partition size
resize2fs /dev/mmcblk0p2
# Start services
/DietPi/dietpi/dietpi-services start
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Re: Expand root partition after the installation
Thanks for your fast reply!Fourdee wrote:Hi Nemeth9,nemeth9 wrote:Hi,
I installed DietPi on a 4GB SD card, set up everything, working fine. I made an image from the installed system than copied to a 16GB SD card.
I know that the first step of the installation is that the installer expand the root file system to the maximum size of SD card but how can I do this after the migration? In raspbian config there is a setup of this but in dietpi config I haven't seen.
Is there any method to do this after the installation?
Thanks!
Regards,
nemeth9
As per the re-partition and resize ext4 code in DietPi: https://github.com/Fourdee/DietPi/blob/ ... ot#L44-L72.
You could essentially make the following scripts to complete the above:
Remember to chmod +x before executing them.
Resize Partition (run 1st):Reboot System (run 2nd):Code: Select all
#!/bin/bash #Stop Services /DietPi/dietpi/dietpi-services stop #Resize partition cat << _EOF_ | fdisk /dev/mmcblk0 p d 2 n p 2 $(parted /dev/mmcblk0 -ms unit s p | grep ':ext4::;' | sed 's/:/ /g' | sed 's/s//g' | awk '{ print $2 }') p w _EOF_
Resize ext4 filesystem (run 3rd):Code: Select all
reboot
Code: Select all
#!/bin/bash # Stop Services /DietPi/dietpi/dietpi-services stop # Resize Filesystem to new partition size resize2fs /dev/mmcblk0p2 # Start services /DietPi/dietpi/dietpi-services start
It's working!
Regards,
nemeth9
Re: Expand root partition after the installation
I would like to see an option for MAX_ROOT_PARTITION in dietpi.txt that would allow for partition expansion... but not to the maximum size of the uSD card.
the blank line in the script (that I marked as "HERE") is essentially taking fdisk's default value for the ending sector (which is the last sector of the uSD). However, if you change that line to "+2048M" , then you get a 2GB partition.... even on a 4-64GB card. By adding a setting in the dietpi.txt file, it can be caught during that initial boot where the resizing occurs.
This would allow the admin to come back in and add additional partitions if desired.
or, just resize to 2GB during initial boot and allow for resize in the dietpi-config script to any arbitrary larger size.
Code: Select all
#Resize partition
cat << _EOF_ | fdisk /dev/mmcblk0
p
d
2
n
p
2
$(parted /dev/mmcblk0 -ms unit s p | grep ':ext4::;' | sed 's/:/ /g' | sed 's/s//g' | awk '{ print $2 }')
<<<<-------------HERE
p
w
_EOF_
This would allow the admin to come back in and add additional partitions if desired.
or, just resize to 2GB during initial boot and allow for resize in the dietpi-config script to any arbitrary larger size.
Re: Expand root partition after the installation
Much simpler, with no I/O redirect or sub-shells...
parted /dev/mmcblk0 -s resizepart 2 100%
(I haven't tested this yet with a "+500M" type of parameter)
parted /dev/mmcblk0 -s resizepart 2 100%
(I haven't tested this yet with a "+500M" type of parameter)
Re: Expand root partition after the installation
i do that kind of things with gparted on another linux PC
works perfectly
works perfectly
Re: Expand root partition after the installation
After first boot my partition was expanded, but I didn't want that.
I wanted to shrink my partion again.
Is there an option to do so at DietPi?
Thanks
I wanted to shrink my partion again.
Is there an option to do so at DietPi?
Thanks
Re: Expand root partition after the installation
There is no build in option to do that. Using gparted on another PC (booting from Live USB Stick) would be best option
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team