Android Format the partition command

mkfs.vfat / dev / block / mmcblk0pxxxx vfat format to format a partition

busybox mkfs.vfat  /dev/block/mmcblk0pxxxx

 

mount -t vfat -o ro, uid = 0, gid = 1000, fmask = 0027, dmask = 0027 / dev / block / mmcblk0pxx / mnt / partion the / dev / block / mmcblk0pxx according to read-only, the root user, system group, access mask to root read-write executables, system readable perform, other users do not have permission to mount / mnt / partion directory

 

Remount the partition need to uninstall and then re remount

umount / mnt / pation closed all access to the file system before // uninstall, close all open files

mount -t vfat -o rw,uid=0,gid=1000,fmask=0027,dmask=0027 /dev/block/mmcblk0pxx /mnt/partion 

 

 

Planning disk partition: fdisk

Second, formatted disk partition: mkfs.xxx

Third, mount the disk partitions: mount, umount

Fourth, the file system management: e2abel, blkid, tun2fs, df

5, switched automatically mount: / etc / fstab

Sixth, expand

   1, swap partition plan, and Automatic Mounting

   2, mount folder

   3, autofs trigger mount

   4, NTFS partitions to create, mount, use

 

One: Planning Disk Partitions

1, View disk partition: fdisk -l

Format: fdisk -l [disk name]

 

Example:

[Root @ localhost ~] # fdisk -l / dev / sda // If you do not specify the disk name, all disk partitions listed

 

Disk /dev/sda: 64.4GB, 64424509440 bytes

255 heads, 63sectors/track, 7832 cylinders

Units = cylinders of16065 * 512 = 8225280 bytes

 

  Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *          1          25      200781  83  Linux

/dev/sda2              26        2575   20482875   83  Linux

/ Dev / sda3 2576 3850 10241437+ 83 Linux

/dev/sda4            3851        7832   31985415    5  Extended

/dev/sda5            3851        4111    2096451   82  Linux swap / Solaris

/dev/sda6            4112        5085    7823623+  83  Linux

[root@localhost ~]#

 

 

2, planning disk partition: fdisk common options

m: View help information

p: List View partition information

n: New Partition

d: delete partition

t: change the partition type (when using t, and if you do not know)

w: Save the partition settings and exit

q: give up the partition settings and exit

 

Example: fdisk disk partition interactive division: http://murongqingqqq.blog.51cto.com/2902694/1361896

 

 

Second, formatted disk partition

Formatting tools: mkfs

mkfs -t type file system partition device

Or use mkfs.xxx partition device

[root@localhost ~]#mkfs.

mkfs.cramfs  mkfs.ext2   mkfs.ext3    mkfs.msdos   mkfs.vfat

We can see, mkfs. May be followed by the format, which is the file system type of the connected behind -t.

 

Note:

- when in use, mkfs as the preceding paragraph, each program by calling -t

- by -L option to specify the volume label for the file system when using mkfs.ext3

- You can specify the time by using the -F option mkfs.vfat FAT digit (the default is 32, is generally not specified, because the specified time can only specify 16 or 32, 16-bit is now generally do not)

- When using mkfs.xxx format a partition device, you need to perform the following update about partprobe disk partition, or can not find the partition you want to format may appear.

 

Third, mount the disk partitions: mount, umount

1, mount command

- Format: mount [options] device mount point name

Common command options

-a: load all configured fstab file system

Note: After modifying / etc / fstab file, you can use the command mount -a or reboot to re-add

Upload it to mount the file system, then if there is a new add swap partition, the mount may not succeed, then,

Need to restart, the district can mount a successful general, if there is an error, you need to modify the / etc / fatab

document content.

-t: Specifies the file system type

-o: Specifies the mount parameters

    ro / rw: read-only / read-write (read-write default)

    acl / noacl: Enable / disable ACL (disabled by default)

    exec / noexec: turn on / off executive power (turned on by default, if not, the program is right there x

                  Limit, this partition is also not allowed. )

    Then when a program has the suid permissions; enable / disable SUID (enabled by default: suid / nosuid

                  Designate, for example, mkdir, if this partition does not support suid, then build on this partition

                  Li directory does not belong to the owner of mkdir)

    guid / noguid: Enable / Disable GUID

    remount: remount (Usage: mount -o remount, exec / dev / sdb1 / data / tools)

    Mount default property of a partition: rw, suid, dev, exec, auto, nouser, async

-L: Use label loading apparatus (with e2label / dev / sdb1 "tools" label setting / dev / sdb1 for tools,

    Using mount -L tools / data / tools to mount / dev / sdb1 partition. )

 

Note:

Mounting a iso file with the mount when you need to specify its type with the -o parameter

Because the contents of the file ios end of which is impossible to see, so you need to mount a directory during viewing.

Such as:

mount -o loop linux.iso / tmp / isofs /: linux.iso will mount the file to the / tmp / isofs / directory

 

2. unmount the file system: umount

Format: umount the device name / mount point (recommended unmount the file system by way of a mount point)

Common command options:

-a: uninstall all non-pseudo file system is mounted

Note: The pseudo file system: not entered, a file system for storing data

E.g. headroom in the system, with a view to command df-hT tmpfs file system type that file / dev / shm is, a pseudo file system.

 

Example:

[root@localhost ~]# df -hT

File system type available capacity has been used with a mount point%

/dev/sda2     ext3    19G  2.7G   16G 15% /

/dev/sda1     ext3    99M   12M   82M 13% /boot

tmpfs        tmpfs  1005M     0 1005M   0% /dev/shm

/dev/sdb1     ext3    19G  173M   18G  1% /data/tools

/dev/sdb2     ext3    19G  173M   18G  1% /data/soft

/dev/sdb6     ext3   9.2G  150M  8.6G  2% /data/game

/dev/sda5     ext3    19G  173M   18G  1% /home

[Root @ localhost ~] # umount / data / game // unloaded from the mount point / dev / sdb6 file system

[Root @ localhost ~] # df -hT | grep sda6 // After uninstalling no information about sda6 of the

[root@localhost ~]#

 

Fourth, the file system management: e2abel, blkid, tun2fs, df

1, a volume label: e2label command

Format: e2label device name [ "label name"]

Note:

After setting the volume label, a file system may be mounted via mount -L label mount point name;

In the / etc / fstab file, the first field, you can also use the label name to indicate a disk partition.

 

Example:

[Root @ localhost ~] # e2label / dev / sda6 // View

// no content

[Root @ localhost ~] # e2label / dev / sda6 "disk6" // modify the label name

[Root @ localhost ~] # e2label / dev / sda6 // see what your edits

After disk6 // modify the label named disk6

[Root @ localhost ~] # e2label / dev / sda6 "" // delete label name

[Root @ localhost ~] # e2label / dev / sda6 // Check again, not a label name

 

[root@localhost~]#

 

2, view the device's UUID: blkid command

blkid command:

blkid device name ...

Example:

[Root @ localhost ~] # blkid / dev / sda3 / dev / sda6 // View sda3 and sda6 the UUID

/dev/sda3:LABEL="/data" UUID="85efcd90-d05a-45b3-9af6-ee151591c652"TYPE="ext3" SEC_TYPE="ext2"

/dev/sda6: UUID="88c52aff-337b-4775-9c77-8c19ffc2cd3c"SEC_TYPE="ext2" TYPE="ext3" LABEL="disk6"

[root@localhost ~]#

Note: If the windows partition, no UUID

Cut TYPE options: TYPE = "vfat" or as TYPE = "ntfs"

 

Example: The following / dev / sda5 ntfs file system format, a format directly when blkid view of ntfs

[root@localhostdata]# blkid /dev/sda5

/dev/sda5: TYPE="ntfs"

 

3, see ext partition properties: tune2fs

Format: tune2fs -l device name

Note: The device name using tune2fs -l command to see whether a file system when acl access control system can only be viewed when the partition is created, and the newly added partition or add a new partition on the hard drive, even with a acl access control You can not view.

For more information, please see: http://murongqingqqq.blog.51cto.com/2902694/1361506 in Supplement 1

 

Example:

[Root @ localhost ~] # tune2fs -l / dev / sda3 // view the partition of property sda3

tune2fs1.39 (29-May-2006)

Filesystemvolume name:   /data

Lastmounted on:          <notavailable>

FilesystemUUID:         85efcd90-d05a-45b3-9af6-ee151591c652

Filesystemmagic number:  0xEF53

Filesystemrevision #:    1 (dynamic)

Filesystemfeatures:      has_journal resize_inodedir_index filetype needs_recovery sparse_super large_file

Defaultmount options:    user_xattr acl        //支持acl

Filesystemstate:         clean

Errorsbehavior:          Continue

FilesystemOS type:       Linux

Inodecount:              2560864

Block Count: 2560359

Reservedblock count:     128017

Freeblocks:              2379760

Freeinodes:              2557126

Firstblock:              0

Blocksize:               4096

Fragmentsize:            4096

ReservedGDT blocks:      625

Blocksper group:         32768

Fragmentsper group:      32768

Inodesper group:         32416

Inodeblocks per group:   1013

Filesystemcreated:       Tue Feb 11 04:45:08 2014

Lastmount time:          Fri Feb 21 22:11:462014

Lastwrite time: Fri Feb 21 22: 11: 462 014

Mountcount:              9

Maximummount count:      -1

Lastchecked:             Tue Feb 11 04:45:08 2014

Checkinterval:           0 (<none>)

Reservedblocks uid:      0 (user root)

Reservedblocks gid:      0 (group root)

Firstinode: 11

Inodesize:               128

Journalinode:            8

Defaultdirectory hash:   tea

DirectoryHash Seed:     63658a00-6d9c-480e-8c30-330a6318036d

Journalbackup:           inode blocks

[root@localhost ~]#

 

4, view disk usage: df command

Common command options:

-h: using easy to read capacity units

-T: lists the file system types

 

[root@localhost ~]# df -Th

File system type available capacity has been used with a mount point%

/dev/sda2     ext3     19G 2.3G   16G  13% /

/dev/sda1    ext3    190M   12M 169M   7% /boot

tmpfs       tmpfs    248M     0 248M   0% /dev/shm

/dev/sda3    ext3    9.5G  393M 8.6G   5% /data

[root@localhost ~]#

 

5, switched automatically mount: / etc / fstab

Configure boot automatically mount: / etc / fstab file

Configuration file / etc / fstab, the contents of which can be divided by a space or tab stop 6, each column represents the contents as follows:

 

[root@localhost ~]# cat /etc/fstab

LABEL=/               /                        ext3   defaults         1 1

LABEL=/boot          /boot                     ext3   defaults         1 2

tmpfs               /dev/shm                   tmpfs  defaults         0 0

devpts              /dev/pts                   devpts gid=5,mode=620   0 0

sysfs               /sys                       sysfs  defaults         0 0

proc                /proc                      proc   defaults         0 0

LABEL=SWAP-sda3     swap                       swap   defaults         0 0

 

Paragraph 123,456

 

The contents of each section represented:

The first paragraph: means that the device file (also can UUID, device name and volume label)

The second paragraph: that mount point

Third paragraph: Indicates the file system type

The fourth paragraph: Mounting parameters

Fifth paragraph: backup flag (0 means no backup)

Sixth paragraph: detection order (0 to not detected)

 

Example: set the boot automatic loading (including swap)

Step 1: Check the mount case and size of the swap partition;

If a new hanging in point, uninstall; if there is a new swap partition, uninstall the device name with swapoff swap partition.

[Root @ localhost ~] # df -Th // First look at the situation to mount a file system

File system type available capacity has been used with a mount point%

/dev/sda2     ext3    19G  2.7G   16G 15% /

/dev/sda1     ext3    99M   12M   82M 13% /boot

tmpfs        tmpfs  1005M     0 1005M   0% /dev/shm

[Root @ localhost ~] # free -m // original size swap partition is a partition on my disk is sda 2G

            total       used       free    shared    buffers     cached

Mem:          2008        911       1096          0         85        649

-/+buffers/cache:        176       1831

Swap:         2047         0      2047

[root@localhost ~]#

 

Step two: Modify the contents of fstab file, add the boot mount entries;

Note:

- where most of the use of UUID, need to use to query the device's UUID blkid

- / dev / sdb5 as swap, swap mount point to swap second paragraph, third paragraph or swap file system type, mount a swap partition when the need to take note!

[root@localhost ~]# vim /etc/fstab

LABEL=/                 /                       ext3    defaults        1 1

LABEL=/boot             /boot                   ext3    defaults        1 2

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

LABEL=SWAP-sda3         swap                    swap    defaults        0 0

UUID="59b355ba-5f83-4016-b5bc-4257ae948359"     /data/tools ext3 defaults 0 0

UUID="1497b080-ffaf-4fe1-95c7-c63d349550a9"     /data/soft  ext3 defaults 0 0

UUID="58fbc6d5-e597-42bf-9ee7-096f62dd41cc"     /data/game  ext3 defaults 0 0

UUID="a463550a-9d03-4934-81a4-e6f8be920f9a"     /home  ext3 defaults 0 0

/dev/sdb5               swap                    swap    defaults        0 0

 

The third step: Use mount -a command to reload it again

And then view the file system and swap partitions mount case with df -Th and free -m.

[root@localhost ~]# mount -a

[Root @ localhost ~] # df -Th // Here you can see the file system has been loaded successfully

File system type available capacity has been used with a mount point%

/dev/sda2     ext3    19G  2.7G   16G 15% /

/dev/sda1     ext3    99M   12M   82M 13% /boot

tmpfs        tmpfs  1005M     0 1005M   0% /dev/shm

/dev/sda5     ext3    19G  173M   18G  1% /home

/dev/sdb1     ext3    19G  173M   18G  1% /data/tools

/dev/sdb2     ext3    19G  173M   18G  1% /data/soft

/dev/sdb6     ext3   9.2G  150M  8.6G  2% /data/game

[root@localhost ~]# free -m

// see if the swap partition is mounted, and the results can be seen on top of the first step of the query is the same, then the explanation that is not mounted, then restart is required to mount.

            total       used       free    shared    buffers     cached

Mem:          2008        910       1097          0        86        649

-/+buffers/cache:        175       1832

Swap:         2047         0      2047

 

Summary: You can use mount-a to reload the file system in the fstab, but you can see through the free -m, swap partition is not loaded successfully, if you want to load successfully, you need to reboot.

 

------

Comprehensive Example: Migration / home directory: http://murongqingqqq.blog.51cto.com/2902694/1361937

 

Six: Extended

1, swap partition plan, and Automatic Mounting

If the split when installing the system swap area is too small, or there is no swap partition division, then add the new partition can be divided into a disk or disk space in an existing, formatted and swap partition mounted use.

swap partition View:

The first: cat / proc / meminfo

The second: swapon -s

Third: free -m

[root@localhost ~]# free -m

           total       used       free    shared    buffers     cached

Mem:         2008        893       1115          0         73        648

-/+ buffers/cache:       170       1837

Swap: 2047 0 2047 // can see the size of the swap partition is 2G

 

The establishment of swap partition way:

A partition dividing the fdisk command, and specifies the format (Note: with t option) 82, Save (w) can be.

Note: After the new disk partition dividing need partprobe command to re-load the system partition information! ! !

 

swap partition of format:

The new swap partition using mkswap swap partition to format a newly established

 

Manually enable / disable swap partitions:

swapon / off new swap partition

 

Example: The new swap plan, mount, mounted automatically check out: http://murongqingqqq.blog.51cto.com/2902694/1361934

 

 

2, mount folder

Uses: mainly hide the source directory path, such as the / usr / src / directory is mounted to be shared under / media / tools / src / directory, then other users (such as user1) in access / usr / src / directory when resources can go directly to

/ Media / tools / src / direct access to resources to ensure the safety of the / usr / src / directory.

 

Note: When there is need to mount the folder / media / tools / src, if there is no need to create; and ensure that the destination folder is not the folder or files occupy other file systems mounted. If so, you need to uninstall.

The time required to mount the folder mount command - -bind parameters:

 

Example: / usr / src / mount the folder / data / tools / src / directory:

Ideas:

Step 1: Create a directory / data / tools / src / directory

Step two: / usr / src / folder to mount under / data / tools / src / directory

The third step: Verify mount successful

Step four: Use the user1 user login system, enter / data / tools / src / directory access resources.

 

To do:

[root@localhost ~]# mkdir -p /data/tools/src

[root@localhost ~]# ls /usr/src/

debug  kernels

[root@localhost ~]# mount --bind /usr/src/ /data/tools/src/

[root@localhost ~]# mount | grep src

/usr/src on/data/tools/src type none (rw,bind)

[root@localhost ~]# ls /data/tools/src/

debug  kernels

[root@localhost ~]# su - user1

[user1@localhost ~]$cd /data/tools/src/    

[User1 @ localhostsrc] $ ls // successful visit

debug  kernels

[user1@localhostsrc]$

 

3, autofs trigger mount

Mount trigger, like / misc / cd directory is the trigger mount directory;

Trigger mount: the misc directory, use ls command can not view there are any files or directories, but can switch to this directory with cd cd command to go, when switching cd cd to the directory, then, on CD-ROM directory will automatically mount / misc / cd directory, which is the trigger mounted.

 

A trigger mounted configuration file: /etc/auto.master and / etc / xxx (this file to write the contents of a file inside /etc/auto.master)

/etc/auto.master contents of the file:

The first paragraph: represents the mount point parent directory

The second paragraph: Mounting profile xxx

/ Etc / xxx (second paragraph of this document is defined /etc/auto.master file inside mount configuration file) file content:

The first paragraph: mount point directory

The second paragraph: Mounting parameters

Third paragraph:: Device name (note: Before the device name plus ":")

 

Example: / dev / sdb1 mount the file system trigger / abc / tools directory

Step 1: Create / abc folder: mkdir / abc

Step two: add a line of content /etc/auto.master

vim /etc/auto.master

Add the line: / abc /etc/auto.abc

Step 3: /etc/auto.master contents of the file, edit the configuration file /etc/auto.abc file (New)

vim /etc/auto.abc

Add Content: tools -fstype = ext3: / dev / sdb1

Step four: Reload Service: server autofs reload

Step 5: cd / abc / tools command to see if you can enter the directory, nothing else can enter.

 

4, NTFS partitions to create, mount, use

Note: linux system default does not support NTFS formatted partition and want to support NTFS formatted partition, you need to install NTFS-3G software.

 

Download NTFS-3G package source way

1,http://www.ntfs-3g.org

2,wget http://www.ntfs-3g.org/ntfs-3g-1.1120.tgz

 

Example:

Installation Source Package ntfs-3g

The / dev / sda5 partition formatted as NTFS partition, and to load with ntfs-3g NTFS partitions.

step:

The first step: extract the source package

tar zxvfntfs-3g_ntfsprogs-2013.1.13.tgz  -C/usr/src/

Step two: compile and install (Note: you need to install the gcc compiler tool before installing)

cd /usr/src/ntfs-3g_ntfsprogs-2013.1.13/

./configure--prefix=/opt/ntfs

make

make install

The third step: the partition type using fdisk / dev / sda5 was changed to 7, i.e. HPFS / NTFS format and formatted

[root@localhost /]# fdisk /dev/sda  

 

The number ofcylinders for this disk is set to 10443.

There is nothingwrong with that, but this is larger than 1024,

and could in certainsetups cause problems with:

1) software thatruns at boot time (e.g., old versions of LILO)

2) booting andpartitioning software from other OSs

  (Eg, DOS FDISK, OS / 2 FDISK)

 

Command (m forhelp): t // t to modify the partition type

Partition number (1-5): 5 // sda5 is the fifth partition

Hex code (type L tolist codes): 7 // designated as 7, if you do not know can enter L view details

 

Command (m forhelp): w // w to save and exit

The partition tablehas been altered!

 

Calling ioctl() tore-read partition table.

 

WARNING: Re-readingthe partition table failed with error 16: Device or resource busy.

The kernel stilluses the old table.

The new table willbe used at the next reboot.

Syncing disks.

[Root @ localhost /] # mkfs.ntfs / dev / sda5 // a / dev / sda5 partition as ntfs format

[Root @ localhost /] # fdisk -l / dev / sda | grep NTFS // View NTFS Partition

/dev/sda5            2825        5257   19543041    7  HPFS/NTFS

Step four: Temporary loading NTFS partition

[Root @ localhost /] # ntfs-3g / dev / sda5 / data / ntfs / // load ntfs district

[root@localhost /]# mount | grep sda5

/dev/sda5on /data/ntfs type fuseblk(rw,allow_other,blksize=4096)

[root@localhost /]#

 

Note: The temporary mount successfully, so far this step has been completed temporary mount NTFS-formatted partitions.

 

Step five: If you need to set the boot automatically mount the NTFS partition, the need to increase the content in / etc / fstab file inside

The format is:

[root@localhost /]# cat /etc/fstab | grep sda5

/dev/sda5               /data/ntfs              ntfs-3g defaults        0 0

[root@localhost /]#

Step Six: Verify

[Root @ localhost /] # umount / data / ntfs / // unload mount point

[Root @ localhost /] # mount | grep sda5 // see if the uninstallation was successful

[Root @ localhost /] # mount -a // load all configured fstab file system

Note: If you use mount -a able to load / dea / sda5, then restart certainly loaded.

[Root @ localhost /] # mount | grep sda5 // you can see, mount a success!

/dev/sda5on /data/ntfs type fuseblk (rw,allow_other,blksize=4096)

[root@localhost /]#

 

Note: Mounting NTFS format u disk, because of the system does not recognize the default NTFS file system format, even ntfs-3g software is installed, it does not recognize, then, can only be mounted by hand, usually u disk in linux system identified in the file system / dev / sdh * device, or it may be / dev / sd *, using ntfs-3g / dev / sd * can mount the directory is mounted.

Guess you like

Origin www.cnblogs.com/Ph-one/p/11084992.html