Resizing SD card via command line

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

Resizing SD card via command line

Postby wwwkk1 » Fri Jun 22, 2012 1:34 am

Hello everyone,

I am desperately looking for a way to resize my SD card through command line (console). I've installed the latest Arch Linux image from Raspberry site, on Raspberry Pi revision B, with 8GB SD card. Of course, I only see 2GB. I see some instructions using GParted or using fdisk for some other linux distribution (not-arch linux), but I can't find any instruction how-to for Arch LInux, using command line only. I don't have a monitor to hook it up to, so I ssh to the device.

Here is the output of df command:

$this->bbcode_second_pass_code('', '[root@raspberry /]# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 1.8G 1.1G 623M 63% /
/dev/root 1.8G 1.1G 623M 63% /
devtmpfs 109M 0 109M 0% /dev
run 109M 148K 109M 1% /run
shm 109M 0 109M 0% /dev/shm
/dev/mmcblk0p1 96M 35M 61M 37% /boot')

Can anyone tell me how I can resize it to use full 8GB space? creating another parition for the remaining 6GB also. But I'm not quite sure how to do that either. Thanks for your help!
wwwkk1
 
Posts: 3
Joined: Fri Jun 22, 2012 1:26 am

Re: Resizing SD card via command line

Postby qiou » Fri Jun 22, 2012 9:27 am

Hi,

There's plenty of tutorials on the net.

But the simplest way is to user libparted (with gparted GTK front end) to resize the partitions.
Turn off you Pi, remove the SD card from the pi.
Use a computer with linux and gparted, insert the card and start gparted.
Extend the second partition to the remaining size.
You can also leave 512MB at the end and turn this space into a SWAP partition (and add it to you fstab)

The elinux wiki page about resizing :
http://elinux.org/RPi_Resize_Flash_Partitions

/Q
qiou
 
Posts: 2
Joined: Wed Mar 28, 2012 6:15 pm

Re: Resizing SD card via command line

Postby wwwkk1 » Fri Jun 22, 2012 2:25 pm

Thanks for your help. I actually read that page -- My apology, I didn't explain fully about my situation. I was wondering if I could do within Raspberry Pi running Arch Linux. The page does have the information, in "Manually resizing the SD card on Raspberry Pi" section but I don't think it's for Arch Linux; arch linux's fdisk command doesn't accept "cu" paramters.

I guess I'll have to go with the first approach but I need to find a linux machine...
wwwkk1
 
Posts: 3
Joined: Fri Jun 22, 2012 1:26 am

Re: Resizing SD card via command line

Postby WarheadsSE » Fri Jun 22, 2012 2:30 pm

You can't resize a mounted partition, so you can't do it from the running Pi.
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: Resizing SD card via command line

Postby pepedog » Fri Jun 22, 2012 4:48 pm

On a windows machine, you can rename kernel.img and rename kernel_emergency.img to kernel.img
This will boot a busybox system, it has fdisk, e2fschk, and much more.
Partition 2 doesn't mount, that's the one you want to resize
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Resizing SD card via command line

Postby Philoo » Fri Jun 22, 2012 8:42 pm

true you can't change the size of a mounted partition and we won't consider pivoting the root to a usb flash drive.
What can be done on the RPi however is partition the available space, format it and elect it for /home for instance.

you'll need to copy the existing content of the directory you're moving to the new partition and update /etc/fstab so that it actually gets mounted on next reboot.
to put it to effect you can : mount -a or reboot.

you will find https://wiki.archlinux.org/index.php/Partitioning and https://wiki.archlinux.org/index.php/Add_new_partitions_to_an_existing_system quite interesting I think.

HTH
Philoo
 
Posts: 102
Joined: Wed Aug 10, 2011 9:20 pm

Re: Resizing SD card via command line

Postby tomahhunt » Wed Jun 27, 2012 9:31 am

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.
tomahhunt
 
Posts: 3
Joined: Sun May 13, 2012 6:09 pm

Re: Resizing SD card via command line

Postby Philoo » Wed Jun 27, 2012 3:15 pm

I'll sure give it a try, but that's a heck of a stunt.

It sure will show the rebooted kernel a larger partition geometry, but I 'm sure how ext{2,3,4} will react when it gets confronted to extra space vs what was provisionned at formatting time. maybe an fsck will seamlessly take care of business.

Again, I sure will give a try but with a filesystem I'm not afraid of losing.
Philoo
 
Posts: 102
Joined: Wed Aug 10, 2011 9:20 pm

Re: Resizing SD card via command line

Postby tomahhunt » Thu Jun 28, 2012 11:29 am

I have done this a number of times with my arch installs and it has worked fine every time.
fsck not required.
tomahhunt
 
Posts: 3
Joined: Sun May 13, 2012 6:09 pm

Re: Resizing SD card via command line

Postby devacc12 » Fri Jul 20, 2012 11:23 am

Great tip thanks. Painless, easy. Took a few minutes to grow the rootfs on a higher capacity SD card.
devacc12
 
Posts: 13
Joined: Thu Jul 05, 2012 9:20 pm

Next

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 5 guests