注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

时间记录器

记录我的Linux、Android学习之路

 
 
 

日志

 
 

Manually resizing the SD card on Linux  

2013-09-13 18:27:01|  分类: Linux |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
URL: http://elinux.org/RPi_Resize_Flash_Partitions

Tutorial video here: http://www.youtube.com/watch?v=R4VovMDnsIE

Following on from the instructions above, keep the newly-written SD card in the card reader, but unmounted. We'll use the parted (partition editor) tool to resize the partitions.

  • Show partition information to find your SD card

$ df -h

Look for a partition that matches the roughly 2GB size of your distribution image.

  • Unmount the partition

$ umount /dev/sdc2

  • Use parted to examine the card
$ sudo parted /dev/sdd
(parted) unit chs
(parted) print
Disk /dev/sdd: 121535,3,31
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 121536,4,32.  Each cylinder is 65.5kB.
Partition Table: msdos

Number  Start      End         Type     File system     Flags
 1      16,0,0     1215,3,31   primary  fat32           lba
 2      1232,0,0   26671,3,31  primary  ext4
 3      26688,0,0  29743,3,31  primary  linux-swap(v1)
This shows how my SD card was formatted after writing the image. Notice that nothing uses the card from end of 'cylinder' 29743 to the card's maximum at 121535.
Partition 1 is the boot partition: we'll leave that alone. Partition 2 is the root partition, which we'll grow to fill most of the card. Some OS versions will have a Partition 3 for swap space, which needs to be moved to the end of the card. Note that on some other versions of linux (and some other versions of hardware) use /sde not /sdd.
  • Move the swap partition if it exists (you'll have to adjust the numbers so that the end of partition 3 is at the end cylinder/head/sector of the card)
  • to calculate the number to use in the following command do:- (Maximum - (Partition 3 End - Partition 3 Start) ) - 1 = Partition 3 New Start so in this example (121535 - ( 29743 - 26688)) -1 = 118479
  • Will not work with parted versions later than 2.4
(parted) move 3 118479,0,0
  • Now grow the root partition. This involves removing the partition, re-creating it, then using resize2fs to grow the filesystem to fill the partition. It won't destroy any data.
(parted) rm 2
(parted) mkpart primary 1232,0,0 118478,3,31
(parted) quit
Note that the starting address of the new partition is identical to its original value, and the ending address is immediately before the start of the swap partition.
  • Now clean and resize the root partition. As before, some users may need to use /sde2 instead.
$ sudo e2fsck -f /dev/sdd2
(allow it to add lost-and-found)
$ sudo resize2fs /dev/sdd2
  • Then put the card in the RPi and boot. You end up with a 7Gb partition to use.
pi@raspberrypi:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
tmpfs                  94M  4.0K   94M   1% /lib/init/rw
udev                   10M  168K  9.9M   2% /dev
tmpfs                  94M     0   94M   0% /dev/shm
rootfs                7.1G  1.3G  5.4G  20% /
/dev/mmcblk0p1         75M   28M   48M  37% /boot
  评论这张
 
阅读(426)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017