Loading...

raspberry pi 新增磁盘分区

2012-09-25 16:37:48 发表于电子技术 本文链接: raspberry pi 新增磁盘分区

在raspberry官网上下载到的img文件dd到任何sd卡上,你看到的可用空间一共只有2G左右,而空闲的空间只有几时M,但是你的sd卡可能最少也是4G或者8G,剩余的空间总不能白白浪费掉,对吧?

所以,我们要在这个磁盘上新增加分区,此前搜索到的一个教程基本上是错误的,幸好我有备份,所以您在做如下操作之前,也记得备份你的sd卡,注意不是简单的复制出来备份,win下用这软件Win32DiskImager备份出来,如果出问题,也同样用这个软件将备份的img写入到sd卡上。

下面是方法:来源:http://elinux.org/RPi_Easy_SD_Card_Setup
懒得翻译,英文原文摘录,以免今后再次到处找.

If you would rather not resize the partition on another machine as described above, either because you do not have another working Linux machine or you wish to keep your data on another partition to your operating system, you can instead create a new data partition and have that mount automatically at boot.

  • First you need to become root and install parted (I did all of this from the boot command prompt, although if you feel safer in a GUI, you can do all of this in a terminal window):
sudo su -
apt-get install parted
  • Then you need to run parted on your SD card, mine is /dev/mmcblk0, ymmv:
parted /dev/mmcblk0
  • Once running, set the display units to something usable and then print your partition table
unit chs
print
  • You should see something like this:
Model: SD SD08G (sd/mmc)
Disk /dev/mmcblk0: 121279,3,31
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 121280,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)
  • Now you need to create your data partition – you need to choose one more than the end of partition 3 with ,0,0 as your start and use the number from the line that starts with Disk as your end:
mkpart primary 29744,0,0 121279,3,31
print
  • That should show your new partition:
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)
 4      29744,0,0  121279,3,31  primary
  • Now quit and format the partition (again, ymmv with the specific device name, try ls /dev for some clues), and then label it:
quit
mkfs.ext4 /dev/mmcblk0p4
e2label /dev/mmcblk0p4 data
  • Now we need to make sure that the partition is mounted automatically when the system boots (maybe don’t use vi if you never have before, try nano):
vi /etc/fstab
  • Enter a line exactly like this at the end of the file and save and quit your text editor:
/dev/mmcblk0p4  /data           ext4    defaults        1       2
  • Create the mount point:
mkdir /data
  • Now mount the partition:
mount /data
cd /data
ls

Your new partition has been created!



	标签:
发表于 2012-09-25 16:37:48 目录:电子技术 [RSS 2.0] 你可以发表评论, 或者从您的网站 trackback
  • 相关阅读
  • homezz 美国专业主机商
    已经有2位大师动手指导 拒绝低俗
    评论分页: 1
    (Required)
    (Required, not published)
    如果留言未显示无需重复留言,我将为你恢复!