How to expand the Linaro image to fill your SD card

A forum for documenting the Parallella and Epiphany . (Not Q&A!)

How to expand the Linaro image to fill your SD card

Postby DrBlackAdder » Thu Jun 19, 2014 5:35 am

First off you'll need to create the device points for SD card access:

sudo mknod -m 660 /dev/mmcblk0 b 179 0

sudo mknod -m 660 /dev/mmcblk0p1 b 179 1

sudo mknod -m 660 /dev/mmcblk0p2 b 179 2

Once done you can use fdisk to resize the disk:
sudo fdisk /dev/mmcblk0

Command (m for help): p

Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes
4 heads, 16 sectors/track, 486192 cylinders, total 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00056828

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 264191 131072 b W95 FAT32
/dev/mmcblk0p2 264192 31116287 15426048 83 Linux

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (264192-31116287, default 264192):
Using default value 264192
Last sector, +sectors or +size{K,M,G} (264192-31116287, default 31116287):
Using default value 31116287

Command (m for help): p

Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes
4 heads, 16 sectors/track, 486192 cylinders, total 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00056828

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 264191 131072 b W95 FAT32
/dev/mmcblk0p2 264192 31116287 15426048 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
linaro-nano:~>

Now reboot your device:
sudo reboot

Lastly run the resize tool on the root partition:
sudo resize2fs /dev/mmcblkp2

Enjoy all the extra space!
DrBlackAdder
 
Posts: 1
Joined: Mon Dec 17, 2012 3:20 am

Re: How to expand the Linaro image to fill your SD card

Postby over9000 » Thu Jun 19, 2014 2:25 pm

Be careful with that. You're showing that you just accept the defaults when recreating the second partition. This will fail if there's enough free space at the start of the disk to create a new one.

What you /should/ do is is print the current partition table (with p), then note the value for the start of the 2nd one. For example:

Code: Select all
/dev/mmcblk0p1            3072      266239      131584    6  FAT16
/dev/mmcblk0p2          266240    30777343    15255552   83  Linux


In this case, when you recreate the second partition, you should give an explicit starting sector of 266240. You can choose the default for the last sector, and it will fill the disk.

***EDIT*** ignore my second point below, since MAKEDEV seems to be deprecated (or at least not installed by default):
Also, knowing the device numbers for the SD card /might/ be useful, but I'd guess that it won't be necessary to create them with mknod. Even then, there should be a /dev/MAKEDEV script to make any device files that are missing. I'm not 100% sure about that on Linaro, though, but if either the mmcblk devices or MAKEDEV script exists, it's a lot safer to not issue your own mknod commands (one less thing to go wrong)...
over9000
 
Posts: 98
Joined: Tue Aug 06, 2013 1:49 am

Re: How to expand the Linaro image to fill your SD card

Postby Gravis » Tue Jun 24, 2014 5:51 pm

another way is to use a gui based partitioning program like GParted on your computer. for those in windows, use a GParted live CD.
User avatar
Gravis
 
Posts: 445
Joined: Mon Dec 17, 2012 3:27 am
Location: East coast USA.

Re: How to expand the Linaro image to fill your SD card

Postby Feik » Fri Aug 01, 2014 4:10 am

Hi,
I am running on 9600's Debian image and when I run the resize2fs step it freezes the board.
I did edit the image in order to remove the network rules.d file. But other than that its a fresh install.

Anyone got any clues on how to fix it? Sadly I only have a MacBook to work with, so no Linux box. :(

The output from /var/log/syslog is like this,
Code: Select all
Aug  1 04:12:47 debian-parallella kernel: EXT4-fs (mmcblk0p2): resizing filesystem from 380160 to 7778688 blocks
Aug  1 04:13:11 debian-parallella kernel: INFO: task resize2fs:2609 blocked for more than 20 seconds.
Aug  1 04:13:11 debian-parallella kernel:      Not tainted 3.12.0-g3d42549 #9
Aug  1 04:13:11 debian-parallella kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Aug  1 04:13:11 debian-parallella kernel: mmc0: Timeout waiting for hardware interrupt.
Aug  1 04:13:11 debian-parallella kernel: mmcblk0: timed out sending r/w cmd command, card status 0x900
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658064
Aug  1 04:13:11 debian-parallella kernel: resize2fs       D c05de9e0     0  2609   2608 0x00000000
Aug  1 04:13:11 debian-parallella kernel: [<c05de9e0>] (__schedule+0x4a8/0x5b0) from [<c05db1e8>] (schedule_timeout+0x18/0x164)
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658072
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658080
Aug  1 04:13:11 debian-parallella kernel: [<c05db1e8>] (schedule_timeout+0x18/0x164) from [<c05de094>] (io_schedule_timeout+0x70/0x9c)
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658088
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658096
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658104
Aug  1 04:13:11 debian-parallella kernel: [<c05de094>] (io_schedule_timeout+0x70/0x9c) from [<c05de48c>] (wait_for_common_io.clone.58+0xa4/0x12c)
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658112
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658120
Aug  1 04:13:11 debian-parallella kernel: [<c05de48c>] (wait_for_common_io.clone.58+0xa4/0x12c) from [<c021dedc>] (__blkdev_issue_zeroout+0x190/0x1bc)
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658128
Aug  1 04:13:11 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 6658136
Aug  1 04:13:11 debian-parallella kernel: [<c021dedc>] (__blkdev_issue_zeroout+0x190/0x1bc) from [<c021df90>] (blkdev_issue_zeroout+0x88/0x98)
Aug  1 04:13:11 debian-parallella kernel: EXT4-fs (mmcblk0p2): resized filesystem to 7778688
Aug  1 04:13:11 debian-parallella kernel: [<c021df90>] (blkdev_issue_zeroout+0x88/0x98) from [<00000007>] (0x7)
Aug  1 04:13:11 debian-parallella kernel: 2 locks held by resize2fs/2609:
Aug  1 04:13:11 debian-parallella kernel: #0:  (sb_writers#3){.+.+.+}, at: [<c00d9b7c>] mnt_want_write_file+0x1c/0x44
Aug  1 04:13:11 debian-parallella kernel: #1:  (&journal->j_barrier){+.+...}, at: [<c0175740>] jbd2_journal_lock_updates+0x164/0x170
Aug  1 04:13:21 debian-parallella kernel: mmc0: Timeout waiting for hardware interrupt.
Aug  1 04:13:51 debian-parallella kernel: INFO: task kworker/u4:1:17 blocked for more than 20 seconds.
Aug  1 04:13:51 debian-parallella kernel:      Not tainted 3.12.0-g3d42549 #9
Aug  1 04:13:51 debian-parallella kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Aug  1 04:13:51 debian-parallella kernel: mmcblk0: timed out sending r/w cmd command, card status 0x900
Aug  1 04:13:51 debian-parallella kernel: blk_update_request: 82 callbacks suppressed
Aug  1 04:13:51 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 1153024
Aug  1 04:13:51 debian-parallella kernel: Buffer I/O error on device mmcblk0p2, logical block 131072
Aug  1 04:13:51 debian-parallella kernel: lost page write due to I/O error on mmcblk0p2
Aug  1 04:13:51 debian-parallella kernel: JBD2: Error -5 detected when updating journal superblock for mmcblk0p2-8.
Aug  1 04:13:51 debian-parallella kernel: kworker/u4:1    D c05de9e0     0    17      2 0x00000000
Aug  1 04:13:51 debian-parallella kernel: Workqueue: writeback bdi_writeback_workfn (flush-179:0)
Aug  1 04:13:51 debian-parallella kernel: [<c05de9e0>] (__schedule+0x4a8/0x5b0) from [<c0174de8>] (start_this_handle+0x1a0/0x580)
Aug  1 04:13:51 debian-parallella kernel: [<c0174de8>] (start_this_handle+0x1a0/0x580) from [<c0175420>] (jbd2__journal_start+0xb0/0x120)
Aug  1 04:13:51 debian-parallella kernel: [<c0175420>] (jbd2__journal_start+0xb0/0x120) from [<c0157174>] (__ext4_journal_start_sb+0x58/0x60)
Aug  1 04:13:51 debian-parallella kernel: [<c0157174>] (__ext4_journal_start_sb+0x58/0x60) from [<c01405e8>] (ext4_writepages+0x38c/0x52c)
Aug  1 04:13:51 debian-parallella kernel: [<c01405e8>] (ext4_writepages+0x38c/0x52c) from [<c0091410>] (do_writepages+0x24/0x38)
Aug  1 04:13:51 debian-parallella kernel: [<c0091410>] (do_writepages+0x24/0x38) from [<c00dfd4c>] (__writeback_single_inode+0x34/0x100)
Aug  1 04:13:51 debian-parallella kernel: [<c00dfd4c>] (__writeback_single_inode+0x34/0x100) from [<c00e0a80>] (writeback_sb_inodes+0x1a8/0x2f4)
Aug  1 04:13:51 debian-parallella kernel: [<c00e0a80>] (writeback_sb_inodes+0x1a8/0x2f4) from [<c00e0c24>] (__writeback_inodes_wb+0x58/0xa8)
Aug  1 04:13:51 debian-parallella kernel: [<c00e0c24>] (__writeback_inodes_wb+0x58/0xa8) from [<c00e0f48>] (wb_writeback+0x11c/0x198)
Aug  1 04:13:51 debian-parallella kernel: [<c00e0f48>] (wb_writeback+0x11c/0x198) from [<c00e11cc>] (bdi_writeback_workfn+0x160/0x2dc)
Aug  1 04:13:51 debian-parallella kernel: [<c00e11cc>] (bdi_writeback_workfn+0x160/0x2dc) from [<c00373d8>] (process_one_work+0x268/0x400)
Aug  1 04:13:51 debian-parallella kernel: [<c00373d8>] (process_one_work+0x268/0x400) from [<c0037f6c>] (worker_thread+0x21c/0x330)
Aug  1 04:13:51 debian-parallella kernel: [<c0037f6c>] (worker_thread+0x21c/0x330) from [<c003d9d4>] (kthread+0xa0/0xac)
Aug  1 04:13:51 debian-parallella kernel: [<c003d9d4>] (kthread+0xa0/0xac) from [<c000dba8>] (ret_from_fork+0x14/0x2c)
Aug  1 04:13:51 debian-parallella kernel: 3 locks held by kworker/u4:1/17:
Aug  1 04:13:51 debian-parallella kernel: #0:  (writeback){.+.+.+}, at: [<c0037364>] process_one_work+0x1f4/0x400
Aug  1 04:13:51 debian-parallella kernel: #1:  ((&(&wb->dwork)->work)){+.+.+.}, at: [<c0037364>] process_one_work+0x1f4/0x400
Aug  1 04:13:51 debian-parallella kernel: #2:  (&type->s_umount_key#17){++++.+}, at: [<c00bf1bc>] grab_super_passive+0x4c/0x90
Aug  1 04:13:51 debian-parallella kernel: INFO: task rs:main Q:Reg:2310 blocked for more than 20 seconds.
Aug  1 04:13:51 debian-parallella kernel:      Not tainted 3.12.0-g3d42549 #9
Aug  1 04:13:51 debian-parallella kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Aug  1 04:13:51 debian-parallella kernel: rs:main Q:Reg   S c05de9e0     0  2310      1 0x00000000
Aug  1 04:13:51 debian-parallella kernel: [<c05de9e0>] (__schedule+0x4a8/0x5b0) from [<c006c3d4>] (futex_wait_queue_me+0xd8/0xf4)
Aug  1 04:13:51 debian-parallella kernel: [<c006c3d4>] (futex_wait_queue_me+0xd8/0xf4) from [<c006c52c>] (futex_wait+0xec/0x1f4)
Aug  1 04:13:51 debian-parallella kernel: [<c006c52c>] (futex_wait+0xec/0x1f4) from [<c006e2bc>] (do_futex+0xc0/0x950)
Aug  1 04:13:51 debian-parallella kernel: [<c006e2bc>] (do_futex+0xc0/0x950) from [<c006ec78>] (SyS_futex+0x12c/0x16c)
Aug  1 04:13:51 debian-parallella kernel: [<c006ec78>] (SyS_futex+0x12c/0x16c) from [<c000dae0>] (ret_fast_syscall+0x0/0x48)
Aug  1 04:13:51 debian-parallella kernel: no locks held by rs:main Q:Reg/2310.
Aug  1 04:14:31 debian-parallella kernel: INFO: task jbd2/mmcblk0p2-:905 blocked for more than 20 seconds.
Aug  1 04:14:31 debian-parallella kernel: mmc0: Timeout waiting for hardware interrupt.
Aug  1 04:14:31 debian-parallella kernel:      Not tainted 3.12.0-g3d42549 #9
Aug  1 04:14:31 debian-parallella kernel: mmcblk0: timed out sending r/w cmd command, card status 0x900
Aug  1 04:14:31 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 180600
Aug  1 04:14:31 debian-parallella kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Aug  1 04:14:31 debian-parallella kernel: EXT4-fs warning (device mmcblk0p2): ext4_end_bio:316: I/O error writing to inode 35706 (offset 0 size 0 starting block 22575)
Aug  1 04:14:31 debian-parallella kernel: Buffer I/O error on device mmcblk0p2, logical block 9519
Aug  1 04:14:31 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 180608
Aug  1 04:14:31 debian-parallella kernel: end_request: I/O error, dev mmcblk0, sector 180616
Aug  1 04:14:31 debian-parallella kernel: EXT4-fs warning (device mmcblk0p2): ext4_end_bio:316: I/O error writing to inode 35706 (offset 176128 size 8192 starting block 22578)
Aug  1 04:14:31 debian-parallella kernel: Buffer I/O error on device mmcblk0p2, logical block 9520
Aug  1 04:14:31 debian-parallella kernel: Buffer I/O error on device mmcblk0p2, logical block 9521
Aug  1 04:14:31 debian-parallella kernel: jbd2/mmcblk0p2- D c05de9e0     0   905      2 0x00000000
Aug  1 04:14:31 debian-parallella kernel: ------------[ cut here ]------------
Aug  1 04:14:31 debian-parallella kernel: WARNING: CPU: 1 PID: 905 at fs/buffer.c:1204 __find_get_block+0x200/0x218()
Aug  1 04:14:31 debian-parallella kernel: [<c05de9e0>] (__schedule+0x4a8/0x5b0) from [<c013aa14>] (ext4_bmap+0x0/0xe8)
Aug  1 04:14:31 debian-parallella kernel: [<c013aa14>] (ext4_bmap+0x0/0xe8) from [<ec143814>] (0xec143814)
Aug  1 04:14:31 debian-parallella kernel: no locks held by jbd2/mmcblk0p2-/905.
Aug  1 04:14:31 debian-parallella kernel: VFS: brelse: Trying to free free buffer
Aug  1 04:14:31 debian-parallella kernel: Modules linked in:
Aug  1 04:14:31 debian-parallella kernel: CPU: 1 PID: 905 Comm: jbd2/mmcblk0p2- Not tainted 3.12.0-g3d42549 #9
Aug  1 04:14:31 debian-parallella kernel: [<c0014394>] (unwind_backtrace+0x0/0xe0) from [<c0010dc8>] (show_stack+0x10/0x14)
Aug  1 04:14:31 debian-parallella kernel: [<c0010dc8>] (show_stack+0x10/0x14) from [<c05db18c>] (dump_stack+0x80/0xc4)
Aug  1 04:14:31 debian-parallella kernel: [<c05db18c>] (dump_stack+0x80/0xc4) from [<c001f2a8>] (warn_slowpath_common+0x60/0x80)
Aug  1 04:14:31 debian-parallella kernel: [<c001f2a8>] (warn_slowpath_common+0x60/0x80) from [<c001f348>] (warn_slowpath_fmt+0x2c/0x3c)
Aug  1 04:14:31 debian-parallella kernel: [<c001f348>] (warn_slowpath_fmt+0x2c/0x3c) from [<c00e8e18>] (__find_get_block+0x200/0x218)
Aug  1 04:14:31 debian-parallella kernel: [<c00e8e18>] (__find_get_block+0x200/0x218) from [<c00e8f78>] (__getblk+0x1c/0x2b4)
Aug  1 04:14:31 debian-parallella kernel: [<c00e8f78>] (__getblk+0x1c/0x2b4) from [<c017d610>] (jbd2_journal_get_descriptor_buffer+0x34/0x8c)
Aug  1 04:14:31 debian-parallella kernel: [<c017d610>] (jbd2_journal_get_descriptor_buffer+0x34/0x8c) from [<c0177c24>] (journal_submit_commit_record.clone.13+0x40/0x158)
Aug  1 04:14:31 debian-parallella kernel: [<c0177c24>] (journal_submit_commit_record.clone.13+0x40/0x158) from [<c0178964>] (jbd2_journal_commit_transaction+0xc28/0x12ac)
Aug  1 04:14:31 debian-parallella kernel: [<c0178964>] (jbd2_journal_commit_transaction+0xc28/0x12ac) from [<c017b860>] (kjournald2+0x9c/0x1e8)
Aug  1 04:14:31 debian-parallella kernel: [<c017b860>] (kjournald2+0x9c/0x1e8) from [<c003d9d4>] (kthread+0xa0/0xac)
Aug  1 04:14:31 debian-parallella kernel: [<c003d9d4>] (kthread+0xa0/0xac) from [<c000dba8>] (ret_from_fork+0x14/0x2c)
Aug  1 04:14:31 debian-parallella kernel: ---[ end trace 9388640fec9f1e38 ]---


SOLVED: It appears that edited the image prior to dd'ing was a mistake. After applying the original image, I gParted it to the correct size and removed the offending network rules file. Now its working fine.
User avatar
Feik
 
Posts: 4
Joined: Mon Dec 17, 2012 3:20 am

Re: How to expand the Linaro image to fill your SD card

Postby aihaike » Wed Aug 13, 2014 2:05 am

I successfully used gParted.
User avatar
aihaike
 
Posts: 31
Joined: Wed Aug 06, 2014 5:41 am
Location: Shanghai, China

Re: How to expand the Linaro image to fill your SD card

Postby 9600 » Wed Aug 13, 2014 10:55 am

I tend to use gparted also.

Regards,

Andrew
Andrew Back (a.k.a. 9600 / carrierdetect)
User avatar
9600
 
Posts: 997
Joined: Mon Dec 17, 2012 3:25 am

Re: How to expand the Linaro image to fill your SD card

Postby fuzz » Sun Nov 09, 2014 8:50 pm

I was able to do this on a live node. Recalling commands from memory:

Code: Select all
sudo apt-get install kpartx
sudo fdisk /dev/mmcblk0p2 (delete partition 2, add primary partition 2, use same start block, default to fill rest of block device)
sudo kpartx /dev/mmcblk0
sudo resize2fs /dev/mmcblk0p2
df-h (Will show increased size, no reboot required)
fuzz
 
Posts: 11
Joined: Fri Jul 04, 2014 2:19 am

Re: How to expand the Linaro image to fill your SD card

Postby Claggy » Wed Feb 18, 2015 9:50 pm

DrBlackAdder wrote:Lastly run the resize tool on the root partition:
sudo resize2fs /dev/mmcblkp2

Enjoy all the extra space!

A typo, that should be:

sudo resize2fs /dev/mmcblk0p2

Claggy
Claggy
 
Posts: 40
Joined: Mon Dec 17, 2012 3:25 am
Location: U.K

Re: How to expand the Linaro image to fill your SD card

Postby zynqfan » Sun Jun 19, 2016 6:43 pm

Just to reiterate I did this with the most recent Ubuntu headless image, and you can use partprobe also:

Assuming you are already root (sudo su - root) run the following as indicated by fuzz. (I use partprobe instead)

1) fdisk /dev/mmcblk0p2
a) type p to print out what is currently configured and to save so you can recreate the partition if you screw up

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 2048 206847 204800 100M b W95 FAT32
/dev/mmcblk0p2 206848

b) d (press enter)
c) 2 (press enter) [you have now deleted partition 2 from the partition table - but don't worry the OS is still working...]
d) n (press enter) [create a new partition 2]
e) p (press enter)
f) 2 (press enter)
g) choose starting sector as the same (in this case 206848, which it probably defaults to but matches the p statement above)
h) leave default as the very large number, which should now fill all 32gb (or however big) of the SDHC vs the normal 3-4gb

2) fdisk will moan about having to run partprobe or kpartx, so run "partprobe" and hit enter - if you don't have partprobe installed run "apt-get install parted" and then run partprobe
3) resize2fs /dev/mmcblk0p2
4) you should be good without rebooting -- but why not run synq and reboot to make sure there weren't any surprises!
zynqfan
 
Posts: 1
Joined: Sun Jun 19, 2016 6:32 pm


Return to Quick Start Guides , Documentation, Examples (Start Here!)

Who is online

Users browsing this forum: No registered users and 1 guest