Operation of SD card under Linux (fdisk)

Source: Internet
Author: User
Tags hex code

When you get an SD card, you need to format, partition, modify parameters in the Linux environment, please look over.

Ubuntu Virtual Machine Environment

1, insert, force point, because there may be poor contact, causing the computer is not recognized.

2,cat/proc/partions or fdisk-l (some may need to go to get administrator privileges, deei~ command before +sudo on line)

For example: cat/proc/partitions
Major Minor #blocks name

   2        0           4 fd0
   8        0  167772160 SDA
   8  ;       1  163576832 sda1
   8         2          1 sda2
   8         5    4192257 sda5
   8       16  167772160 SDB
   8       17  167771136 sdb1
  11         0    1048575 sr0
   8        32    7761920 SDC
   8       33    7237664 SDC1

My SD card is mounted to/DEV/SDC-----> It has 1 partition SDC1.

3, input sudo fdisk/dev/sdc

Command (M for help): M//See the various commands are introduced
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
xExtra functionality (experts only)

Well, these commands are simple and clear. Let's partition the SD card.

Command (M for help):D//If only one partition is deleted directly, if multiple partitions, there will be a number, select the partition you want to delete

Command (M for help): N//Add new partition

Partition Type:
P Primary (2 primary, 0 extended, 2 free)
E Extended

Command (M for help):P//General Select P

Partition number (1-4, default 1): 1//default is added starting from the first partition
First sector (2048-15523839, default 2048)://This is where the memory begins to divide, such as 8G of memory, there will be 11,523,839 sector, starting from 2048, that is to set aside the 2048*512=1m. This is the SD card to save information with.

Last sector, +sectors or +size{k,m,g} (2048-15523839, default 15523839): +3g//I assigned 3G size, if you just want to divide a zone, OK, directly enter, that is divided 8g-1m to the first a partition.

Command (M for help): t//Select a format for the partition, Linux or FAT32

Selected partition 1//Select the first partition, set the format
Hex code (Type L to list codes): L//display can be set in a number of formats not listed here such as: Fat32-->b linux-->83

Hex code (type L to list codes): b//Do FAT32

  

Command (M for help): N//Next partition of Linux system
Partition Type:
P Primary (1 primary, 0 extended, 3 free)
E Extended
Select (default p): P
Partition number (1-4, default 2):
Using Default value 2
First sector (6293504-15523839, default 6293504):
Using Default Value 6293504
Last sector, +sectors or +size{k,m,g} (6293504-15523839, default 15523839)://size is the direct return, the rest to the Linux partition
Using Default Value 15523839

Command (M for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 83//This is the Linux setting

Command (M for help): P//ok, it's over, print it out and check it out.

disk/dev/sdc:7948 MB, 7948206080 bytes
4 heads, Sectors/track, 242560 cylinders, total 15523840 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

Device Boot Start End Blocks Id System
/DEV/SDC1 2048 6293503 3145728 b W95 FAT32//windows
/DEV/SDC2 6293504 15523839 4615168, Linux//linux

Command (M for help): w//OK, save it
The partition table has been altered!

Calling IOCTL () to re-read partition table.

Warning:if you has created or modified any DOS 6.x
partitions, please see the Fdisk manual page for additional
Information.

OK, basically 、、、、 Emma, no, not yet formatted yet.

Go on:

sudo mkdosfs/dev/sdc1//formatted FAT32

sudo mkfs.ext3/dev/sdc2//formatted Linux

OK, to this partition and format end, you can according to their own needs, one or two, here the Sub-window and Linux under the said, size these are based on their own needs.

At this point, if the SD card inserted in the Windows environment, will only pop up a mobile device, that is, the size of the FAT32, on the virtual machine, then two will bounce out.

Here's another thing to add: Dude, I'm going to die on this day, I think I demons ~ a problem is not clear, their own death is difficult, always thinking, affect the work, affect the mood, this is why? 艹, no brains.

Talk about my situation, in fact, understand the SD card partition of things, there is no need so tangled, can use on the line, but I was demons ~ dead brain ~ I have to the SD card of the heads sectors cylinders with the Development Board card, so, SB was trapped a day, Work is not efficient is this SB-like.

How to modify heads sectors these. See just the last command of Fdisk explained: X (Expert only), OK, SB also want to be an expert, a good-looking, actually very simple.

  

Command (M for help): D//Erase all partitions

Command (M for help): X//Enter edit

Expert command (M for help): H//can type m, see related commands, H denotes heads
Number of heads (1-256, default 245): 4//instead of 4

Expert command (M for help): s//sectors
Number of sectors (1-63, default 62): 16

Expert command (M for help): C//cylinders These few numbers to note that the final to be multiplied by equal to the capacity of the SD card, otherwise wasted, this can be counted.
Number of cylinders (1-1048576, default 1021): 242560

Expert command (M for help): R//Return to the main menu to continue the partitioning work.

  so simple operation, where do I die???? Right here!!! I thought it would be OK, indeed, after the change, p is changed, but W save exit, again into the no save. The reason may be, so modify, can't touch its partition table bar, do not know right. As soon as you come back to work on the partition, and then save it, we can implement the modification of H S C. This is the day, the man who has no brains.

Operation of SD card under Linux (fdisk)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.