Learning from linux-disk management and learning from linux

Source: Internet
Author: User

Learning from linux-disk management and learning from linux

1: df is used to view the capacity information of mounted disks.

-I. View inodes usage -H is displayed in proper units -K-m is displayed in k M units. 2: view the space occupied by a file or directory by du [-abckmsh] [file name and directory name] The du + directory only lists the sizes of directories and Their subdirectories. The du-a + directory lists the subdirectories and file sizes. Commonly used du-sh + directory representation to list the sum in an appropriate unit 2: disk partition Fdisk-l list all current partitions Disk/dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065*512 = 8225280 bytes Sector size (logical/physical): 512 bytes/512 bytes I/O size (minimum/optimal): 512 bytes/512 bytes Disk identifier: 0x00000000 You can see that/dev/sdb is a new disk and has not been partitioned. Enter fdisk/dev/sdb If fdisk is not added with l, you can enter another mode to start partitioning. Input p to print the current partition: Command (m for help): p  Disk/dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065*512 = 8225280 bytes Sector size (logical/physical): 512 bytes/512 bytes I/O size (minimum/optimal): 512 bytes/512 bytes Disk identifier: 0x2543f3b6  Device Boot Start End Blocks Id System As you can see, there is no partition. Enter n to create the partition: Disk/dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065*512 = 8225280 bytes Sector size (logical/physical): 512 bytes/512 bytes I/O size (minimum/optimal): 512 bytes/512 bytes Disk identifier: 0x2543f3b6  Device Boot Start End Blocks Id System  Command (m for help): n Command action E extended P primary partition (1-4) Input p (primary partition ): Partition number (1-4): 1 First cylinder (1-1044, default 1): 1 Last cylinder, + cylinders or + size {K, M, G} (1-1044, default 1044): + 1000 M Enter the number of partitions in sequence, the actual location of the partition, And the ending location is the size. Enter p to view: Disk/dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065*512 = 8225280 bytes Sector size (logical/physical): 512 bytes/512 bytes I/O size (minimum/optimal): 512 bytes/512 bytes Disk identifier: 0x2543f3b6  Device Boot Start End Blocks Id System /Dev/sdb1 1 128 1028128 + 83 Linux The first partition is created. Linux supports creating up to four primary partitions. If you want to create more partitions, you need to use the command to delete 4th partitions and select extended partitions when entering n to create partitions. As shown below Disk/dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065*512 = 8225280 bytes Sector size (logical/physical): 512 bytes/512 bytes I/O size (minimum/optimal): 512 bytes/512 bytes Disk identifier: 0x2543f3b6  Device Boot Start End Blocks Id System /Dev/sdb1 1 128 1028128 + 83 Linux /Dev/sdb2 129 256 1028160 83 Linux /Dev/sdb3 257 384 1028160 83 Linux /Dev/sdb4 385 1044 5301450 5 Extended /Dev/sdb4 is an extended partition. It is best to allocate the remaining space to the extended partition. The extended partition cannot be formatted. The primary partition created later is a logical partition allocated from the extended partition. When you use the d command to delete a partition, if you delete the extended partition, the sub-partition under it, that is, the logical partition, will be deleted. After the partition is completed, enter w to save and exit. 3. format the partition. Mke2fs -T specifies the file system type Mke2fs-t ext4/dev/sdb5 specifies that the default block size of the file system in ext4 format is 4 kb. Linux writes a file into one block. For example, if one 5k file is written, two blocks exist. -L specify the tag-p to specify an integer multiple of the block size of 1024, for example: Mke2fs-t ext4-l test-B 8192-c/dev/sdb5 4. Attach a disk After partitioning and formatting a disk, you must create a mount point, that is, a directory, to write data to the disk. Mount/dev/sdb5 newdir/mount the partition Df-h: View mounted directory information Filesystem Size Used Avail Use % Mounted on /Dev/mapper/vg_flex-lv_root 18G 3.5G 13G 22%/ Tmpfs 932 M 0 932 M 0%/dev/shm /Dev/sda1 477 M 37 M 415 M 9%/boot /Dev/sdb5 973 M 1.3 M 921 M 1%/home/flex/newdir The sdb5 partition is successfully mounted. 5: add a line to the/etc/fstab file. /Dev/sdb5/home/flex/newdir ext4 defaults 0 0 This file lists the partitions to be mounted when the system starts. Umount/dev/sdb5 unmount the sdb5 Mount Partition Mount-a will execute the specified mount file in this file

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.