在linux下格式化SD卡成多个磁盘区间

http://www.fengfly.com/plus/view-163969-1.html

 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值