Resizing SD card via command line

This forum is for topics specific to the Raspberry Pi and Arch Linux ARM

Re: Resizing SD card via command line

Postby BasiK » Fri Jul 20, 2012 1:09 pm

Works like tomahhunt described.

@Philoo: to clarify, it's the resize2fs command (from the e2fsprogs package) that fixes your filesystem to the partition geometry. But to be honest, I also do think it's rather creepy to do this with a live partition with important data.
BasiK
 
Posts: 7
Joined: Sun Jun 03, 2012 6:59 am

Re: Resizing SD card via command line

Postby wwwkk1 » Sun Jul 22, 2012 4:32 pm

Hi,

Thanks for the tip. I did below step, but after reboot, I can't ssh to it any more. Is this for system with attached monitor/keyboard? Rasbperry Pi no longer response to ping nor let me log on to it via SSH.


tomahhunt wrote:Actually you can resize the disk while active in arch linux.

As root:

fdisk /dev/mmcblk0

Delete the second partition /dev/mmcblk0p2
d
2

Create a new primary partition and use default sizes prompted. This will then create a partiton that fills the disk
n
p
2
enter
enter

Save and exit fdisk:
w


Now reboot. Once rebooted:
resize2fs /dev/mmcblk0p2

Your main / partition should be the full size of the disk now.
wwwkk1
 
Posts: 3
Joined: Fri Jun 22, 2012 1:26 am

Re: Resizing SD card via command line

Postby dpws » Fri Aug 17, 2012 11:01 pm

This is probably because your init is trying to find a partition that is in the /etc/fstab file, but no longer exists. If you plug in a screen and a keyboard, you'll be confronted with a screen which announces some sort of error related to fsck or partitions, and prompts you to log in as root to fix the problem. This is now your only option!

For future reference, the full process including the additional step is:

-----------------------------------

As root:

fdisk /dev/mmcblk0

Delete the second partition /dev/mmcblk0p2
d
2

Create a new primary partition and use default sizes prompted. This will then create a partiton that fills the disk
n
p
2
enter
enter

Save and exit fdisk:
w

Edit /etc/fstab to reflect your new partition system and avoid fsck and sysvinit problems on reboot.

Now reboot. Once rebooted:
resize2fs /dev/mmcblk0p2

Your main / partition should be the full size of the disk now.

---------------------------------

Assuming that you have opted for one large partition, your fstab will look like this:

#
# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
devpts /dev/pts devpts defaults 0 0
shm /dev/shm tmpfs nodev,nosuid 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 1
/dev/mmcblk0p2 / ext4 defaults 1 1
dpws
 
Posts: 2
Joined: Fri Aug 17, 2012 10:54 pm

Re: Resizing SD card via command line

Postby inter1908 » Sun Sep 02, 2012 8:17 am

Sorry, is not clear this fase:

Edit /etc/fstab to reflect your new partition system and avoid fsck and sysvinit problems on reboot.

How I have to modify?

Actually i have:
Code: Select all
#
# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
devpts                 /dev/pts      devpts    defaults            0      0
shm                    /dev/shm      tmpfs     nodev,nosuid        0      0
/dev/mmcblk0p1  /boot           vfat    defaults        0       0


I have execute all step and Im stopped at this point ... :?

Thanks
inter1908
 
Posts: 8
Joined: Fri Aug 31, 2012 2:20 pm

Re: Resizing SD card via command line

Postby longmang » Thu Feb 14, 2013 1:59 pm

Perfect. Worked for me too, no information loss.

tomahhunt wrote:Actually you can resize the disk while active in arch linux.

As root:

fdisk /dev/mmcblk0

Delete the second partition /dev/mmcblk0p2
d
2

Create a new primary partition and use default sizes prompted. This will then create a partiton that fills the disk
n
p
2
enter
enter

Save and exit fdisk:
w


Now reboot. Once rebooted:
resize2fs /dev/mmcblk0p2

Your main / partition should be the full size of the disk now.
longmang
 
Posts: 1
Joined: Thu Feb 14, 2013 1:56 pm

Re: Resizing SD card via command line

Postby brAzzi64 » Sat Mar 09, 2013 8:32 pm

Thanks!
brAzzi64
 
Posts: 2
Joined: Sat Mar 09, 2013 8:29 pm

Re: Resizing SD card via command line

Postby crashmaster » Fri Mar 15, 2013 3:34 am

tomahhunt wrote:Actually you can resize the disk while active in arch linux.

You can do it - but never it can be a recommendation for everybody.
I just wanted to say it for people watching this thread. ;)
Possibly you can get 'mysterious errors' days, weeks or months later, i never would do it this way but maybe you have lots of luck. :D
crashmaster
 
Posts: 112
Joined: Wed Mar 13, 2013 1:00 am

Re: Resizing SD card via command line

Postby crashmaster » Fri Mar 15, 2013 3:46 am

crashmaster wrote:
tomahhunt wrote:Actually you can resize the disk while active in arch linux.

You can do it - but never it can be a recommendation for everybody.
I just wanted to say it for people watching this thread. ;)
Possibly you can get 'mysterious errors' days, weeks or months later, i never would do it this way but maybe you have lots of luck. :D

Ok, if a "fsck" is successfully done after operation, the risk is minimized but not totally cleared.
Only my opinion, good luck!
crashmaster
 
Posts: 112
Joined: Wed Mar 13, 2013 1:00 am

Re: Resizing SD card via command line

Postby lumpynose » Fri Mar 22, 2013 3:52 am

crashmaster wrote:
crashmaster wrote:
tomahhunt wrote:Actually you can resize the disk while active in arch linux.

You can do it - but never it can be a recommendation for everybody.
I just wanted to say it for people watching this thread. ;)
Possibly you can get 'mysterious errors' days, weeks or months later, i never would do it this way but maybe you have lots of luck. :D

Ok, if a "fsck" is successfully done after operation, the risk is minimized but not totally cleared.
Only my opinion, good luck!

I followed tomahhunt's instructions and it seemed to work ok for me. I brought the system down to single user, remounted root read only, and ran fsck and it didn't find any errors.

Can you explain what sort of "mysterious errors" might show up? I'm wondering how a filesystem could pass an fsck and still have problems that would show up later.
lumpynose
 
Posts: 16
Joined: Fri Mar 22, 2013 3:01 am

Re: Resizing SD card via command line

Postby lumpynose » Fri Mar 22, 2013 3:58 am

crashmaster wrote:
crashmaster wrote:
tomahhunt wrote:Actually you can resize the disk while active in arch linux.

You can do it - but never it can be a recommendation for everybody.
I just wanted to say it for people watching this thread. ;)
Possibly you can get 'mysterious errors' days, weeks or months later, i never would do it this way but maybe you have lots of luck. :D

Ok, if a "fsck" is successfully done after operation, the risk is minimized but not totally cleared.
Only my opinion, good luck!

Sort of an addendum to my previous post, would it be safer if you were to go into single user mode and remount the filesystem read only? I.e.,
Code: Select all
systemctl rescue
mount -o ro,remount /

Then follow tomahhunt's recipe. After the reboot go into single user mode and remount root readonly again, then use the resize2fs command.

I'll try this since I haven't done anything significant to my setup yet.
lumpynose
 
Posts: 16
Joined: Fri Mar 22, 2013 3:01 am

PreviousNext

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 1 guest