N900分区详解

时间: 2011-05-09 / 分类: Maemo / 浏览次数: 1,153 阅 / 0个评论 发表评论

写在文章前面。
分区有风险,数据无价,请做好备份等相关工作,非技术党需要一定的折腾能力,熟悉linux的操作起来就感觉小菜啦~
普及知识,N900的32GB存储默认三个分区。分别是mmcblk0p1、2、3 来个简介:
mmcblk0p1为FAT32格式此分区挂载的我们常说的MyDocs目录;
mmcblk0p2为linux的ext3格式的系统数据分区;
mmcblk0p3乃linux的swap交换分区。
以上三个分区均为主分区(primary partition,一块硬盘最多4个主分区,分别为1234,其中扩展分区也是主分区的一种,只是扩展分区有一个或多个逻辑分区组成。分区编号也有讲究的,1234只能是主分区名,即使只有一个主分区,其他是逻辑分区,逻辑分区编号也从5开始编排。。。),mmcblk0意思就是第一块磁盘,p1(partition1)就是这块磁盘的第一个分区啦。本分区仅涉及到对MyDocs即第1分区的重新划分,数据都将丢失,所以请备份好此分区所有数据到其他存储设备上。整个操作在N900的X-terminal进行,所有命令行均预先取得超级权限。
一、安装分区工具FDISK(安装在系统分区home内的)

Nokia-N900:~# mkdir -p /home/user/util-linux /home/user/bin 依次建立两个目录,前者是临时目录,后者是FDISK存放目录
Nokia-N900:~# cd /home/user/util-linux 进入临时目录
Nokia-N900:~# wget http://ftp.de.debian.org/debian/pool/main/u/util-linux/util-linux_2.13.1.1-1_armel.deb 在临时目录下载工具包,也可在电脑端下载,然后拷到此目录
Nokia-N900:~# dpkg-deb -x util-linux_2.13.1.1-1_armel.deb root 解压到/home/user/util-linux/root目录
Nokia-N900:~# cp root/sbin/fdisk /home/user/bin/ 把临时目录里的FDISK工具拷到目标目录
Nokia-N900:~# cd ..
Nokia-N900:~# rm -rf util-linux 删除临时目录

二、分区

卸载第一分区,即mmcblk0p1。

Nokia-N900:~# umount /home/user/MyDocs

然后进入分区软件目录,调用软件,查看当前分区情况。

Nokia-N900:~# cd /home/user/bin/
Nokia-N900:/home/user/bin# ./fdisk -l

如果未进行过分区,可以看到手机里共挂载了两个外置设备,分别是手机本身的硬盘/dev/mmcblk0和外置的SD卡/dev/mmcblk1
N900的32GB磁盘如前所述分了三个区,分别是/dev/mmcblk0p1,/dev/mmcblk0p2和/dev/mmcblk0p3,分区格式依次是FAT32,Linux和Linux swap / Solaris 你看到的信息可能是:

Disk /dev/mmcblk0: 32.0 GB, 32015122432 bytes
4 heads, 16 sectors/track, 977024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0×00000000

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2 884865 28315648 c W95 FAT32 (LBA)
/dev/mmcblk0p2 884866 950401 2097152 83 Linux
/dev/mmcblk0p3 950402 974977 786432 82 Linux swap / Solaris

Disk /dev/mmcblk1: 15.9 GB, 15997075456 bytes
4 heads, 16 sectors/track, 488192 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0×00000000

Device Boot Start End Blocks Id System
/dev/mmcblk1p1 1 451200 14438399+ c W95 FAT32 (LBA)
/dev/mmcblk1p2 451201 488192 1183744 83 Linux

接下来,我们开始修改刚才我们卸载下来的第一个分区。输入命令:

Nokia-N900:/home/user/bin# ./fdisk /dev/mmcblk0

出现如下信息:

The number of cylinders for this disk is set to 977024.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): m (这里按m显示帮助,按p查看当前分区表情况)
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): d (按d,进行删除分区操作)
Partition number (1-4): 1 (选择1,删除第一块主分区,即/dev/mmcblk0p1,也就是我们的/home/user/MyDocs)

Command (m for help): p (按p,查看操作后的分区表情况)

Disk /dev/mmcblk0: 32.0 GB, 32015122432 bytes
4 heads, 16 sectors/track, 977024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0×00000000

Device Boot Start End Blocks Id System
/dev/mmcblk0p2 884866 950401 2097152 83 Linux
/dev/mmcblk0p3 950402 974977 786432 82 Linux swap / Solaris
(注: 可以看到第一块分区mmcblk0p1已经被删除了。)

此时继续,按n,进行新的分区操作,如下

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p (按P,e和p分别是扩展分区和主分区,我们是建立主分区)
Partition number (1-4): 1 (按1,我们建立的主分区是1,即要建立mmcblk0p1)
First cylinder (1-977024, default 1): (按回车,即使用括号里说的默认的,开始cylinder)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-884865, default 884865): +25G
(输入+25G,即,这里我想给MyDocs分25G)

Command (m for help): p (按p,查看操作后的分区表情况,可看到第一块主分区大小是24414072K,约是25G)

Disk /dev/mmcblk0: 32.0 GB, 32015122432 bytes
4 heads, 16 sectors/track, 977024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0×00000000

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 762940 24414072 83 Linux
/dev/mmcblk0p2 884866 950401 2097152 83 Linux
/dev/mmcblk0p3 950402 974977 786432 82 Linux swap / Solaris

本来第一主分区是28G,我们删除再建后是25G,还有3G的空闲空间,这里我们来创建扩展分区:

Command (m for help): n (按n继续分区)
Command action
e extended
p primary partition (1-4)
e (此时要创建扩展分区了,选择e)
Selected partition 4(只能有4个主分区,自动选择4。因为扩展分区也是主分区的一种)
First cylinder (762941-977024, default 762941): (选择开始cylinder,使用默认即可,直接回车)
Using default value 762941
Last cylinder or +size or +sizeM or +sizeK (762941-884865, default 884865): (选择结束cylinder,因为我们要把剩余的空间全部分配给扩展分区,然后再在扩展分区上创建逻辑分区,所以要把剩余空间全部分配给扩展分区,这里使用默认,直接回车)

Using default value 884865

Command (m for help): p(按p,查看操作的后的情况)

Disk /dev/mmcblk0: 32.0 GB, 32015122432 bytes
4 heads, 16 sectors/track, 977024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0×00000000

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 762940 24414072 83 Linux
/dev/mmcblk0p2 884866 950401 2097152 83 Linux
/dev/mmcblk0p3 950402 974977 786432 82 Linux swap / Solaris
/dev/mmcblk0p4 762941 884865 3901600 5 Extended

可以看到,扩展分区是/dev/mmcblk0p4 ,近4G空间。扩展分区是不能直接使用 ,我们将其所剩的创建为一个linux逻辑分区,用来装安卓系统。

Partition table entries are not in disk order

Command (m for help): n (按n,在扩展分区上创建逻辑分区)
First cylinder (762941-884865, default 762941): (按回车,使用默认)
Using default value 762941
Last cylinder or +size or +sizeM or +sizeK (762941-884865, default 884865): (按回车,选择默认结束柱面数将剩余的划为一个区)

Command (m for help): p (按p,查看一下操作后的分区表情况)

Disk /dev/mmcblk0: 32.0 GB, 32015122432 bytes
4 heads, 16 sectors/track, 977024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0×00000000

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 762940 24414072 83 Linux
/dev/mmcblk0p2 884866 950401 2097152 83 Linux
/dev/mmcblk0p3 950402 974977 786432 82 Linux swap / Solaris
/dev/mmcblk0p4 762941 884865 3901600 5 Extended
/dev/mmcblk0p5 762941 823976 3901600 83 Linux

下面把第1个分区,即第一个逻辑分区也转换成76 即unkown

Command (m for help): t
Partition number (1-6): 1
Hex code (type L to list codes): 76
Changed system type of partition 5 to 76 (Unknown)

Command (m for help): p

Disk /dev/mmcblk0: 32.0 GB, 32015122432 bytes
4 heads, 16 sectors/track, 977024 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0×00000000

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 762940 24414072 76 unknow
/dev/mmcblk0p2 884866 950401 2097152 83 Linux
/dev/mmcblk0p3 950402 974977 786432 82 Linux swap / Solaris
/dev/mmcblk0p4 762941 884865 3901600 5 Extended
/dev/mmcblk0p5 762941 823976 3901600 83 Linux

Partition table entries are not in disk order

确定没问题按w执行操作。

Command (m for help): w (按q退出,按w应用分区结果)输入reboot重启手机,然后格式化分区

把第一个分区格式设置为FAT32

root
/home/user/bin/fdisk /dev/mmcblk0
输入t,回车
输入1,回车
输入0c,回车
输入w,回车

格式化第一个分区为FAT32:

mkfs.vfat -F 32 /dev/mmcblk0p1

重新加载MyDocs:

mount /dev/mmcblk0p1 /home/user/MyDocs

————-
完。
参考maemo中文网主题

http://www.wda.cn/thread-8133-1-1.html

发表评论

您的昵称 *

您的邮箱 *

您的网站



无觅相关文章插件,快速提升流量