How to resize (expand) the persistence partition on Debian live
I have Debian 12 Live with persistence installed on a pen drive. (I had the iso image of Debian 12 Live flashed on the pen drive).
The OS is in partitions /dev/sda1 and /dev/sda2. The persistence partition is /dev/sda3. This partition was running out of space and since there was free unpartitioned space on the pen drive I decided to expand the /dev/sda3 partition to include the free space.
1. The first step i did was to make a backup of the files in the persistence partition.
1.1 First insert the pen drive in your computer and press escape key while turning on the computer to bring up choices of media to boot from.
Select the pen drive from the list.
1.2 When the GRUB menu comes up, press e to edit boot parameters. At the end of the linux string, type in "toram" (without quotes). Make sure persistence is not on the linux string. Then press Ctrl-X to boot.
1.3 Debian live loads up. To locate your persistence files in the filesystem, run the "Disks" gui application. It showed /dev/sda3 mounted at /media/user/persistence.
1.4 Open a command terminal.
Do "sudo cd /media/user/persistence".
Do "sudo tar --same-owner -cvpz -f /tmp/backup.tar.gz".
1.5 Now copy or move the backup.tar.gz file to a safe location, preferably on another machine or removable media.
2. Now to actually expand the /dev/sda3 partition:
2.1 Run "sudo swapoff -a" to disable (flush) all swap spaces.
2.2 Unmount the partitions on the pen drive:
Do "sudo umount /dev/sda3".
Do "sudo umount /dev/sda2".
Do "sudo umount /dev/sda1".
2.3 Run "sudo fdisk --wipe=never -t dos /dev/sda"
fdisk starts up. Type 'p' (without quotes) to print existing partitions on /dev/sda. Write down the info you see on the screen.
2.4 Type d (to delete the partition from the partition table. The files in the partition are not deleted).
For partition number Type 3
2.5 Type n (To create a new partition).
Type p for "primary partition".
Type 3 for partition number.
For first sector, ensure the default is the same start sector as was for /dev/sda3 in step 2.3. Press enter.
Foe end sector, press enter to use all unpartitioned free space following /dev/sda3 (the default). Alternatively, enter the end sector of your choice. Be careful not to overwrite other partitions or data.
You will see a message "Partition 3 contains a ext3 signature. Do you want to remove the signature?" Type n.
2.6 Type p and view the changes.
2.7 Type w to write the changes to the pen drive and exit fdisk.
3. Restore the volume name:
Run "sudo tune2fs -L "persistence" /dev/sda3"
4. Run partprobe to inform the kernel of changes to the partition table:
Do "sudo partprobe".
5. Run e2fsck to check and repair the filesystem:
Do "sudo e2fsck -f /dev/sda3"
6. Resize the filesystem to occupy the entire partition:
Do "sudo resize2fs /dev/sda3"
7. Now reboot with persistence:
Reboot and bring up the GRUB menu. Type e for boot parameters. At the the end of the linux string, type "persistence" (without quotes). Press Ctrl-X to boot.
8. Debian live with persistence will boot up.
Comments
Post a Comment
Feel free to comment.