DAY22课堂笔记

磁盘分区

dd if=/dev/sda of=/dev/sdc    bs=512    count=10240

来源      生成文件系统   block大小  块个数

[root@oldboyedu ~]# dd if=/dev/sda of=/dev/sdc    bs=512    count=10240

10240+0 records in

10240+0 records out

5242880 bytes (5.2 MB) copied, 0.0810606 s, 64.7 MB/s

[root@oldboyedu ~]# ls -l /dev/sdc

-rw-r--r-- 1 root root 5242880 Mar 29 09:55 /dev/sdc

[root@oldboyedu ~]# file /dev/sdc

/dev/sdc: x86 boot sector; partition 1: ID=0x83, active, starthead 32, startsector 2048, 524288 sectors; partition 2: ID=0x82, starthead 194, startsector 526336, 1572864 sectors; partition 3: ID=0x83, starthead 170, startsector 2099200, 39843840 sectors, code offset 0x63

[root@oldboyedu ~]# cat /proc/partitions

major minor  #blocks  name

8       16    1048576 sdb

8       17     153600 sdb1

8       18     153600 sdb2

8       19     153600 sdb3

8       20          1 sdb4

8       21     153600 sdb5

8       22     153600 sdb6

8       23     153600 sdb7

8        0   20971520 sda

8        1     262144 sda1

8        2     786432 sda2

8        3   19921920 sda3

11        0    1048575 sr0

parted :

[root@shizhenghao ~]# partprobe /dev/sdb

[root@shizhenghao ~]# ll /dev/sdb*

brw-rw---- 1 root disk 8, 16 Mar 29 10:12 /dev/sdb

[root@shizhenghao ~]# part /dev//sdb

-bash: part: command not found

[root@shizhenghao ~]# parted /dev//sdb

GNU Parted 3.1

Using /dev/sdb

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) p

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdb: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: sun

Disk Flags:

Number  Start  End  Size  File system  Flags

(parted) mklabel gpt                                                     

Warning: The existing disk label on /dev/sdb will be destroyed and all data on this

disk will be lost. Do you want to continue?

Yes/No? yes                                                             

(parted) p                                                               

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdb: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart primary 0 4800000

Error: The location 4800000 is outside of the device /dev/sdb.

(parted) p                                                               

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdb: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart primary 0 480000

Error: The location 480000 is outside of the device /dev/sdb.

(parted) p                                                               

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdb: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart primary 0 480

Warning: The resulting partition is not properly aligned for best performance.

Ignore/Cancel? ignore                                                   

(parted) p                                                               

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdb: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End    Size  File system  Name    Flags

1      17.4kB  480MB  480MB              primary

(parted) mkpart primary 480 481

(parted) p                                                               

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdb: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End    Size    File system  Name    Flags

1      17.4kB  480MB  480MB                primary

2      480MB  481MB  1049kB              primary

(parted) mkpart primary 481 581

(parted) p                                                               

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdb: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End    Size    File system  Name    Flags

1      17.4kB  480MB  480MB                primary

2      480MB  481MB  1049kB              primary

3      481MB  581MB  99.6MB              primary

(parted) mkpart primary 481 581

Warning: You requested a partition from 481MB to 581MB (sectors 939453..1134765).

The closest location we can manage is 581MB to 581MB (sectors 1134592..1134592).

Is this still acceptable to you?

Yes/No? no

(parted) mkpart primary 581 581                                         

(parted) p                                                               

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdb: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End    Size    File system  Name    Flags

1      17.4kB  480MB  480MB                primary

2      480MB  481MB  1049kB              primary

3      481MB  581MB  99.6MB              primary

4      581MB  581MB  89.1kB              primary

(parted) rm 2

(parted) p                                                               

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdb: 1074MB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start  End    Size    File system  Name    Flags

1      17.4kB  480MB  480MB                primary

3      481MB  581MB  99.6MB              primary

4      581MB  581MB  89.1kB              primary

文件系统:

[root@oldboyedu ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Command (m for help): n

Partition type:

p   primary (0 primary, 0 extended, 4 free)

e   extended

Select (default p): p

Partition number (1-4, default 1):

First sector (2048-2097151, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +100M

Partition 1 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x000006b6

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      206847      102400   83  Linux

Command (m for help): n

Partition type:

p   primary (1 primary, 0 extended, 3 free)

e   extended

Select (default p): p

Partition number (2-4, default 2):

First sector (206848-2097151, default 206848):

Using default value 206848

Last sector, +sectors or +size{K,M,G} (206848-2097151, default 2097151): +100M

Partition 2 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x000006b6

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      206847      102400   83  Linux

/dev/sdb2          206848      411647      102400   83  Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@oldboyedu ~]# ls -l /dev/sdb*

brw-rw---- 1 root disk 8, 16 Mar 29 11:31 /dev/sdb

brw-rw---- 1 root disk 8, 17 Mar 29 11:31 /dev/sdb1

brw-rw---- 1 root disk 8, 18 Mar 29 11:31 /dev/sdb2

1、什么是文件系统?

计算机存储和组织数据的方法或者机制。落地是一个软件

2、为什么需要文件系统?

磁盘、物理介质、磁粒子物理元素。硬件需要软件驱动使用,磁盘需要文件系统驱动。

文件系统实现通过磁盘管理规划、存取数据。

3、文件系统有哪些种类?

windows:NTFS、fat32、mados

linux:ext2、ext3(c5)、ext4(c6)、xfs(c7)、btrfs

4、创建文件系统实践:

5、文件系统原理(ext4文件系统)

6、企业中如何选择文件系统。

7、如何优化文件系统?


格式化/dev/sdb1,指定格式-t ext4

[root@oldboyedu ~]# mkfs -t ext4 /dev/sdb1

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

25688 inodes, 102400 blocks

5120 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=33685504

13 block groups

8192 blocks per group, 8192 fragments per group

1976 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729

Allocating group tables: done

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

把 /dev/sdb1 挂载到/mnt

[root@oldboyedu ~]# mount -t ext4 /dev/sdb1 /mnt #挂载到/mnt

[root@oldboyedu ~]# df -h #查看挂载结果

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        19G  1.9G  18G  10% /

devtmpfs        980M  5.0M  975M  1% /dev

tmpfs          991M    0  991M  0% /dev/shm

tmpfs          991M  18M  973M  2% /run

tmpfs          991M    0  991M  0% /sys/fs/cgroup

/dev/sda1      253M  136M  118M  54% /boot

tmpfs          199M    0  199M  0% /run/user/0

tmpfs          199M    0  199M  0% /run/user/1000

/dev/sdb1        93M  1.6M  85M  2% /mnt #<====已挂载。

[root@oldboyedu ~]# cat /proc/mounts  #查看挂载结果

rootfs / rootfs rw 0 0

sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0

proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0

configfs /sys/kernel/config configfs rw,relatime 0 0

/dev/sda3 / xfs rw,relatime,attr2,inode64,noquota 0 0

systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=32,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=19277 0 0

hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0

debugfs /sys/kernel/debug debugfs rw,relatime 0 0

mqueue /dev/mqueue mqueue rw,relatime 0 0

/dev/sda1 /boot xfs rw,relatime,attr2,inode64,noquota 0 0

tmpfs /run/user/0 tmpfs rw,nosuid,nodev,relatime,size=202812k,mode=700 0 0

tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=202812k,mode=700,uid=1000,gid=1000 0 0

/dev/sdb1 /mnt ext4 rw,relatime,data=ordered 0 0 #<====已挂载。

[root@oldboyedu ~]# touch /mnt/oldboy

[root@oldboyedu ~]# ls /mnt

lost+found  oldboy

你可能感兴趣的:(DAY22课堂笔记)