Tag Archives: parted

Resize sdcard with parted

So I had to reinstall Debian in the sdcard of my Orange Pi Lite. Thing is original image / fs is only 4Gb, which on a 64Gb sdcard leaves 60Gb unused.

Here is where parted comes to the rescue. Easier than fdisk for me. Below example extends ext4 partition to 62Gb and creates a 2Gb swap partition.

sudo parted  /dev/mmcblk0 
GNU Parted 3.2 
Using /dev/mmcblk0 
Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print
Model: SD BC2QT (sd/mmc) 
Disk /dev/mmcblk0: 64,0GB 
Sector size (logical/physical): 512B/512B 
Partition Table: msdos 
Disk Flags:  

Number  Start   End     Size    Type     File system  Flags  
1      21,0MB  73,4MB  52,4MB  primary  fat16        lba  
2      73,4MB  3743MB  3670MB  primary  ext4 

(parted) resizepart
Partition number? 2
End?  [3743MB]? 62000MB
(parted) print
Model: SD BC2QT (sd/mmc)
Disk /dev/mmcblk0: 64,0GB 
Sector size (logical/physical): 512B/512B 
Partition Table: msdos 
Disk Flags:  

Number  Start   End     Size    Type     File system  Flags  
1      21,0MB  73,4MB  52,4MB  primary  fat16        lba  
2      73,4MB  62,0GB  61,9GB  primary  ext4 

(parted) mkpart                                                            Partition type?  primary/extended? primary
File system type?  [ext2]? linux-swap
Start? 62.0GB
End? 64.0GB
(parted) print
Model: SD BC2QT (sd/mmc)
Disk /dev/mmcblk0: 64,0GB 
Sector size (logical/physical): 512B/512B 
Partition Table: msdos 
Disk Flags:  

Number  Start   End     Size    Type     File system     Flags  
1      21,0MB  73,4MB  52,4MB  primary  fat16           lba  
2      73,4MB  62,0GB  61,9GB  primary  ext4  
3      62,0GB  64,0GB  2022MB  primary  linux-swap(v1)  lba 
(parted)  
(parted) quit 
Information: You may need to update /etc/fstab. 

Continue reading