免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1393 | 回复: 0
打印 上一主题 下一主题

在linux下格式化SD卡成多个磁盘区间 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-24 22:28 |只看该作者 |倒序浏览

SD Configuration and Setup
Since putting a Linux file system on a FAT32 partition is problematic, it is recommended to also create a 2nd partition.
  • Plug your SD card into your Linux box
  • Do not mount it

The card shows up as /dev/sd*. To identify the card, you can either do:
  • dmesg | grep sd[a-z]. You will see something like [172407.246308]  sdb: sdb1 sdb2 so drive is /dev/sdb
  • ls /dev/sd* before and after plugging SD card and find created devices

For this example, we will assume the card shows up as /dev/sdc - substitute this for the real device on your specific machine.
Fdisk the drive and print the partition information

sudo fdisk /dev/sdc
Command (m for help): p
Disk /dev/sdc: 1018 MB, 993001472 bytes
......
Look for the size in bytes of the device and calculate the number of
cylinders, dropping factions, if we have 255 heads and 63 sectors (and
512 bytes per sector so 1 cylinder is 255 * 63 * 512 = 8225280 bytes).
new_cylinders = Size / 8225280 (for this example we will have 993001472 / 8225280 which equals 120.725 or 120 cylinders)


Delete any existing partitons
Since we are changing the underlying geometry of the disk, we must clear the partition table before doing it. So delete all partitions using
the fdisk 'd' command - yes, you will lose all data on the card. Once
that is done, we can set the new geometry in expert mode. We will set
the number of heads to 255, number of sectors to 63, and number of
cylinders to new_cylinders.
Command (m for help):  d
Partition number (1-4): 1
Command (m for help):  d
Partition number (1-4): 2

Configuring SD Card
Command (m for help): x
Expert command (m for help): h
Number of heads (1-256, default 30): 255
Expert command (m for help): s
Number of sectors (1-63, default 29): 63
Warning: setting sector offset for DOS compatiblity
Expert command (m for help): c
Number of cylinders (1-1048576, default 2286):  

Configuring SD Partitions
Now we return to the main menu and create 2 partitions as needed - 1 boot partition of 64Meg and the rest a linux partition.
Note: +64M is used
to set the boot partition to 64MB. If media content is stored on the SD
this parition size should be increased to make room for media content
(mp3, mp4, aac, etc...). Assuming a 2GB SD card is used a partition
size of +1000MB should be enough to handle 1GB of media content.

Expert command (m for help): r
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-123, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-123, default 123): +64M (see note above)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (10-123, default 10):
Using default value 10
Last cylinder or +size or +sizeM or +sizeK (10-123, default 123):
Using default value 123


Set first partition to FAT32 and make it active
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))
* You have to format 1st partitions with vfat32 filesystem.
Command (m for help): a
Partition number (1-4): 1
Check Partition Table
The partition table should look something like the following. Notice
the heads, sectors, and cylinders. Make sure partition 1 is active and
FAT32. If it looks good - write the new partition information out.
Command (m for help): p
Disk /dev/sdc: 993 MB, 993001472 bytes
255 heads, 63 sectors/track, 120 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdc1 * 1 9 72261 c W95 FAT32 (LBA)
/dev/sdc2 10 120 891607+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
Formatting the partitions
Note: Both
partitions may be mounted. The partitions need to be un-mounted prior
to continuing. This action can be done by using the following commands
(partitions names may vary):

sudo umount /media/BOOT
sudo umount/media/disk
Format the filesystems on the partitions:
mkfs.vfat -F 32 -n boot /dev/sdc1
mkfs.ext3 /dev/sdc2



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/64117/showart_2036068.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP