Max_G
Posts: 32
Joined: Sat May 28, 2016 8:27 am

Stretch: extend partition and file system w/o loosing data

Fri Feb 15, 2019 5:36 am

I have set-up a headless rPi3+ with Stretch Lite; burned the image with Ether to a 16GB SD card; extended the partition to 16GB. USed Etcher to grapb this image and burned it to a 240GB SSD.

What do I need to do to use the entire SSD? More so, without loosing the data on it if possible).

Code: Select all

df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/root                       15G  2.2G   12G  16% /
devtmpfs                       484M     0  484M   0% /dev
tmpfs                          489M     0  489M   0% /dev/shm
tmpfs                          489M   51M  438M  11% /run
tmpfs                          5.0M  4.0K  5.0M   1% /run/lock
tmpfs                          489M     0  489M   0% /sys/fs/cgroup
/dev/sda1                       44M   23M   22M  52% /boot
//HPSERVER/linux-bup/rpi3ohv2  446G -3.3T  3.7T    - /media/hpserver-linux-bup
tmpfs                           98M     0   98M   0% /run/user/1001

sudo fdisk -l
Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        8192    97889    89698 43.8M  c W95 FAT32 (LBA)
/dev/sda2       98304 31116287 31017984 14.8G 83 Linux

sudo parted /dev/sda 'unit s print' free
Model: External USB3.0 (scsi)
Disk /dev/sda: 468877312s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start      End         Size        Type     File system  Flags
        63s        8191s       8129s                Free Space
 1      8192s      97889s      89698s      primary  fat32        lba
        97890s     98303s      414s                 Free Space
 2      98304s     31116287s   31017984s   primary  ext4
        31116288s  468877311s  437761024s           Free Space
Why extend? The idea was that the SSD will last forever if it can move data around on as much free disk as possible.
I may run cross-backups for other rPis; other than that, this rPi runs an automation system (nothing else).
Last edited by Max_G on Fri Feb 15, 2019 6:31 am, edited 1 time in total.

fruitoftheloom
Posts: 20167
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Stretch: extend partition and file system w/o loosing data

Fri Feb 15, 2019 5:43 am

Max_G wrote:
Fri Feb 15, 2019 5:36 am
I have set-up a rPi3+ with Stretch Lite; burned the image with Ether to a 16GB SD card; extended the partition to 16GB. USed Etcher to grapb this image and burned it to a 240GB SSD.

What do I need to do to use the entire SSD? More so, without loosing the data on it if possible).

Code: Select all

df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/root                       15G  2.2G   12G  16% /
devtmpfs                       484M     0  484M   0% /dev
tmpfs                          489M     0  489M   0% /dev/shm
tmpfs                          489M   51M  438M  11% /run
tmpfs                          5.0M  4.0K  5.0M   1% /run/lock
tmpfs                          489M     0  489M   0% /sys/fs/cgroup
/dev/sda1                       44M   23M   22M  52% /boot
//HPSERVER/linux-bup/rpi3ohv2  446G -3.3T  3.7T    - /media/hpserver-linux-bup
tmpfs                           98M     0   98M   0% /run/user/1001

sudo fdisk -l
Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        8192    97889    89698 43.8M  c W95 FAT32 (LBA)
/dev/sda2       98304 31116287 31017984 14.8G 83 Linux

sudo parted /dev/sda 'unit s print' free
Model: External USB3.0 (scsi)
Disk /dev/sda: 468877312s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start      End         Size        Type     File system  Flags
        63s        8191s       8129s                Free Space
 1      8192s      97889s      89698s      primary  fat32        lba
        97890s     98303s      414s                 Free Space
 2      98304s     31116287s   31017984s   primary  ext4
        31116288s  468877311s  437761024s           Free Space
Why extend? The idea was that the SSD will last forever if it can move data around on as much free disk as possible.
I may run cross-backups for other rPis; other than that, this rPi runs an automation system (nothing else).

gparted is in the repositories, it is a nice GUI for parted:

https://gparted.org
adieu

Asus CS10 Chromebit / HP Envy 4500 Wireless Printer / Raspberry Pi Model 2B v1.1 / RealVNC Software...

Max_G
Posts: 32
Joined: Sat May 28, 2016 8:27 am

Re: Stretch: extend partition and file system w/o loosing data

Fri Feb 15, 2019 6:33 am

gparted is a graphical interface (GUI).

Edited my post, and added "headless" rPi.
Hence, some command line tools have to do the trick.
Would appreciate, based on the data provided (and am happy to provide more if required), an idea on how to perform the necessary commands.

k-pi
Posts: 922
Joined: Sun Feb 12, 2017 1:46 pm
Location: Upper Hale, Surrey, UK.

Re: Stretch: extend partition and file system w/o loosing data

Fri Feb 15, 2019 12:06 pm

I think fdisk or cfdisk will do what you want.

From memory, you extend the partition & write it to disk, then enlarge the file system - but check for the exact details.

Edit: Use ssh to access your machine.

Return to “Troubleshooting”