ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • RPi 를 위한 SD카드 파티션
    Raspberry Pi 2013. 10. 18. 14:01

    파티션 테이블 만들기

    참조: http://myembeddedlinux.blogspot.kr/2013/05/partition-your-sd-card-for-pi.html

    http://elinux.org/RPi_Advanced_Setup


    알아야 할 내용

    CHS 와 LBA : http://lunatine.net/post/40829528445/faq-cylinder-chs-vs-lba

    fdisk 사용법 : 


     Create the parition table

    1. Plug your SD Card to your computer.

    2. Identify your /dev/ node

    sudo fdisk -l
    The output lists your disks :
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1        2473    19864341    7  HPFS/NTFS
    /dev/sda2            2474       19456   136415745    f  W95 Ext'd (LBA)
    /dev/sda5            3279        6374    24868588+   7  HPFS/NTFS
    /dev/sda6            6375       19456   105081133+   7  HPFS/NTFS
    /dev/sda7            2474        3237     6133760   83  Linux
    /dev/sda8            3237        3278      330752   82  Linux swap / Solaris

    Partition table entries are not in disk order

    Disk /dev/sdb: 3974 MB, 3974103040 bytes
    4 heads, 16 sectors/track, 121280 cylinders
    Units = cylinders of 64 * 512 = 32768 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1         611       19544   83  Linux
    /dev/sdb2             612      121280     3861408   83  Linux

    Note : sda identifies your hard drives (or partitions) while sdb (or c, d, ...) is used for removable disks

    My SD Card is referred as /dev/sdb and it currently has 2 partitions.

    3. Clear the partition table

    sudo fdisk /dev/sdb/
    At the fdisk command line prompt, enter 'o'. It will create a new virtual  DOS partition table :
    Building a new DOS disklabel with disk identifier 0xd39a6636.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.
    Now enter 'p', it will display the SD Card properties. Note the card size somewhere, we will need it later :
    Disk /dev/sdb: 3974 MB, 3974103040 bytes
    ...

    4. Set SD Card geometry

    Enter 'x' to go into the expert mode.

    The setup configuration is : 255 heads and 63 sectors (512 bytes each). We need to calculate the number of cylinders :

    cylinders_nb = card_size_bytes / heads_nb / sectors_nb / sector_size

    Here :

    cylinders_nb = 3974103040 / 63 / 255 / 512 = 483, 15

    The result must be rounded down, which means that cylinders_nb = 483.

    Enter 'h' and set the heads number :
    Expert command (m for help): h
    Number of heads (1-256, default 4): 255
    Enter 's' and set the sectors number:
    Expert command (m for help): s
    Number of sectors (1-63, default 16): 63
    Warning: setting sector offset for DOS compatiblity
    Enter 'c' and set the cylinders number :
    Expert command (m for help): c
    Number of cylinders (1-1048576, default 121280): 483

    5 . Create a FAT32 partition (boot partition)

    Enter 'r' to go back to normal mode.

    Follow these steps :
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-483, default 1): 1
    Last cylinder, +cylinders or +size{K,M,G} (1-483, default 483): +50

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): c
    Changed system type of partition 1 to c (W95 FAT32 (LBA))

    Command (m for help): a
    Partition number (1-4): 1

    6. Create a Linux partition (root filesystem)

    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 2
    First cylinder (52-483, default 52): (press Enter)
    Using default value 52
    Last cylinder, +cylinders or +size{K,M,G} (52-483, default 483): (press Enter)
    Using default value 483

    7. Apply the partition table to the card

    Enter 'p' and verify that you have these 2 partitions :
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1   *           1          51      409626    c  W95 FAT32 (LBA)
    /dev/sdb2              52         483     3470040   83  Linux
    Enter 'w' to write it on the card.

    Format the SD Card

    1. Format the DOS partition

    sudo mkfs.msdos -F 32 /dev/sdb1 -n DOS

    2. Format the Linux partition to ext3

    sudo mkfs.ext3 /dev/sdb2 
    And that's it ! To avoid doing this manually everytime, the Pi-community have written some scripts that execute these commands for you. One of them can be found here and all you have to do is :
    # Make it executable
    chmod +x mkcard.txt
    # Run it (use your own disk node ! )
    ./mkcard.txt /dev/sdb







    728x90
    반응형

    댓글

Designed by Tistory.