на главную | войти | регистрация | DMCA | контакты | справка | donate |      

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я


моя полка | жанры | рекомендуем | рейтинг книг | рейтинг авторов | впечатления | новое | форум | сборники | читалки | авторам | добавить



2.8.3.1. ...partitioning a flash drive?

You can use the standard fdisk utility to partition a flash drive (after unmounting it, if necessary). Here is an example in which fdisk is used to divide a 64 MB flash drive into two partitions:

# fdisk /dev/sdb


Since fdisk is an interactive tool, it's necessary to enter single-letter commands to specify the changes that should be made to the partition table. First, print the partition table on the screen so you can review it:

Command (m for help): p


Disk /dev/sdb: 65 MB, 65536000 bytes

3 heads, 42 sectors/track, 1015 cylinders

Units = cylinders of 126 * 512 = 64512 bytes


 Device Boot Start End Blocks Id System

/dev/sdb1 1 1015 63924 83 Linux


This table shows a 64 MB device (64,512 bytes) with one partition.

If the display does not match the device you are trying to partition, you may be partitioning the wrong device; enter q to exit immediately! 


Delete the old partition:

Command (m for help): d

Selected partition 1


Create a new primary partition number 1 that is 30 MB in size:

Command (m for help): n

Command action

 e extended

 p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-1015, default 1): ENTER

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-1015, default 1015): +30M  


Create a new primary partition number 2, taking up the rest of the drive:

Command (m for help): n

Command action

 e extended

 p primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (467-1015, default 467): ENTER

Using default value 467

Last cylinder or +size or +sizeM or +sizeK (467-1015, default 1015): ENTER

Using default value 1015


Print the partition table to check it:

Command (m for help): p


Disk /dev/sdb: 65 MB, 65536000 bytes

3 heads, 42 sectors/track, 1015 cylinders

Units = cylinders of 126 * 512 = 64512 bytes


 Device Boot Start End Blocks Id System

/dev/sdb1 1 466 29337 83 Linux

/dev/sdb2 467 1015 34587 83 Linux


Set the type code for the two partitions:

Command (m for help): t

Partition number (1-4): 1

Hex code (type L to list codes): L


 0 Empty 1e Hidden W95 FAT1 80 Old Minix be Solaris boot

 1 FAT12 24 NEC DOS 81 Minix / old Lin bf Solaris

 2 XENIX root 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-

...(snip)...

 9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt

 a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access

 b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O

 c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor

 e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs

...(snip)...

1c Hidden W95 FAT3 75 PC/IX

Hex code (type L to list codes): c

Changed system type of partition 1 to c (W95 FAT32 (LBA))


Command (m for help): t

Partition number (1-4): 2

Hex code (type L to list codes): c

Changed system type of partition 2 to c (W95 FAT32 (LBA))


Write (save) and exit:

Command (m for help): w

The partition table has been altered!


Calling ioctl( ) to re-read partition table.


Syncing disks.


The partition type used, c , indicates that the partition will contain a FAT filesystem. This enables compatibility with Windows and Mac OS X systems and is also necessary for most camera flash-memory cards and digital music players.

Once the partitions have been created, they can be formatted with mkfs :

# mkfs -t vfat -n spreadsheet -F 32 /dev/sdb1

mkdosfs 2.10 (22 Sep 2003)

# mkfs -t vfat -n database -F 3 2 /dev/sdb2

mkdosfs 2.10 (22 Sep 2003)

You may need to remove and reinsert the drive to force the kernel to load the new partition table before you can format the partitions.  

The option -F 32 forces the use of 32-bit file allocation tables, which is not strictly necessary for drives under 512 MB in size but is required for larger drives and matches the filesystem type assigned to the partition by the previous fdisk command. The -n labelname option sets the filesystem label, which will be used to determine the mount points for the filesystem.

If you have ever used your USB drive without a partition table (formatting /dev/sda instead of /dev/sda1, for example), erase the master boot record (MBR) before partitioning to prevent udev from later detecting the drive as unpartitioned and mounting it incorrectly:

# dd bs=1k count=1 if=/dev/zero of=/dev/sdb


2.8.2. How Does It Work? | Fedora Linux | 2.8.3.2. ...using a Linux filesystem such as ext2 on a USB storage device?