Bo's Oracle Station

查看: 1819|回复: 0

课程第7次

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2019-4-18 21:16:32 | 显示全部楼层 |阅读模式

删除/dev/sdb上的所有分区:
  1. [root@station60 ~]# tune2fs -l /dev/mapper/vol0-test
  2. tune2fs 1.42.9 (28-Dec-2013)
  3. Filesystem volume name:   <none>
  4. Last mounted on:          <not available>
  5. Filesystem UUID:          04631ed5-4009-42fe-a483-68d41bd8ba1e
  6. Filesystem magic number:  0xEF53
  7. Filesystem revision #:    1 (dynamic)
  8. Filesystem features:      has_journal ext_attr resize_inode dir_index filetype ng dir_nlink extra_isize
  9. Filesystem flags:         signed_directory_hash
  10. Default mount options:    user_xattr acl
  11. Filesystem state:         clean
  12. Errors behavior:          Continue
  13. Filesystem OS type:       Linux
  14. Inode count:              12288
  15. Block count:              12288
  16. Reserved block count:     614
  17. Free blocks:              10865
  18. Free inodes:              12277
  19. First block:              0
  20. Block size:               4096
  21. Fragment size:            4096
  22. Group descriptor size:    64
  23. Reserved GDT blocks:      5
  24. Blocks per group:         32768
  25. Fragments per group:      32768
  26. Inodes per group:         12288
  27. Inode blocks per group:   384
  28. Flex block group size:    16
  29. Filesystem created:       Thu Apr 18 08:38:47 2019
  30. Last mount time:          Thu Apr 18 08:39:54 2019
  31. Last write time:          Thu Apr 18 08:39:54 2019
  32. Mount count:              1
  33. Maximum mount count:      -1
  34. Last checked:             Thu Apr 18 08:38:47 2019
  35. Check interval:           0 (<none>)
  36. Lifetime writes:          4221 kB
  37. Reserved blocks uid:      0 (user root)
  38. Reserved blocks gid:      0 (group root)
  39. First inode:              11
  40. Inode size:               128
  41. Journal inode:            8
  42. Default directory hash:   half_md4
  43. Directory Hash Seed:      cabd7b01-f8f7-453d-b349-4935e9eebd53
  44. Journal backup:           inode blocks
  45. [root@station60 ~]# clear
  46. [root@station60 ~]# man fsck
  47. [root@station60 ~]# cat /proc/partitions
  48. major minor  #blocks  name

  49.    8        0   20971520 sda
  50.    8        1    1048576 sda1
  51.    8        2   19921920 sda2
  52.    8       16    1048576 sdb
  53.    8       17     512000 sdb1
  54.    8       20          1 sdb4
  55.    8       21     534528 sdb5
  56.   11        0    4391936 sr0
  57. 253        0   17821696 dm-0
  58. 253        1    2097152 dm-1
  59. 253        2      49152 dm-2
  60. 253        3      49152 dm-3
  61. 253        4      32768 dm-4
  62. 253        5      49152 dm-5
  63. 253        6      32768 dm-6
  64. 253        7      49152 dm-7
  65. 253        8      65536 dm-8
  66. [root@station60 ~]# fdisk /dev/sdb
  67. Welcome to fdisk (util-linux 2.23.2).

  68. Changes will remain in memory only, until you decide to write them.
  69. Be careful before using the write command.


  70. Command (m for help): p

  71. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  72. Units = sectors of 1 * 512 = 512 bytes
  73. Sector size (logical/physical): 512 bytes / 512 bytes
  74. I/O size (minimum/optimal): 512 bytes / 512 bytes
  75. Disk label type: dos
  76. Disk identifier: 0x7380aaa7

  77.    Device Boot      Start         End      Blocks   Id  System
  78. /dev/sdb1            2048     1026047      512000   8e  Linux LVM
  79. /dev/sdb4         1026048     2097151      535552    5  Extended
  80. /dev/sdb5         1028096     2097151      534528   8e  Linux LVM

  81. Command (m for help): q

  82. [root@station60 ~]# df -Th
  83. Filesystem             Type      Size  Used Avail Use% Mounted on
  84. /dev/mapper/rhel-root  xfs        17G  3.7G   14G  22% /
  85. devtmpfs               devtmpfs  894M     0  894M   0% /dev
  86. tmpfs                  tmpfs     910M     0  910M   0% /dev/shm
  87. tmpfs                  tmpfs     910M   11M  900M   2% /run
  88. tmpfs                  tmpfs     910M     0  910M   0% /sys/fs/cgroup
  89. /dev/sda1              xfs      1014M  178M  837M  18% /boot
  90. tmpfs                  tmpfs     182M   12K  182M   1% /run/user/42
  91. tmpfs                  tmpfs     182M     0  182M   0% /run/user/0
  92. /dev/mapper/vol0-test2 xfs        61M  3.4M   58M   6% /b
  93. /dev/mapper/vol0-test  ext4       43M   44K   40M   1% /a
  94. [root@station60 ~]# pvs
  95.   PV         VG   Fmt  Attr PSize   PFree
  96.   /dev/sda2  rhel lvm2 a--  <19.00g      0
  97.   /dev/sdb1  vol0 lvm2 a--  496.00m 496.00m
  98.   /dev/sdb5  vol0 lvm2 a--  512.00m 336.00m
  99. [root@station60 ~]# lvs
  100.   LV         VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  101.   root       rhel -wi-ao---- <17.00g                                            
  102.   swap       rhel -wi-ao----   2.00g                                            
  103.   test       vol0 owi-aos---  48.00m                                            
  104.   test2      vol0 -wi-ao----  64.00m                                            
  105.   testsnap   vol0 sri-a-s---  32.00m      test   17.70                          
  106.   testsnaprw vol0 swi-a-s---  32.00m      test   17.71                          
  107. [root@station60 ~]# lvremove /dev/vol0/testsnaprw
  108. Do you really want to remove active logical volume vol0/testsnaprw? [y/n]: y
  109.   Logical volume "testsnaprw" successfully removed
  110. [root@station60 ~]# lvremove /dev/vol0/testsnap
  111. Do you really want to remove active logical volume vol0/testsnap? [y/n]: y
  112.   Logical volume "testsnap" successfully removed
  113. [root@station60 ~]# lvremove /dev/vol0/test
  114.   Logical volume vol0/test contains a filesystem in use.
  115. [root@station60 ~]# umount  /a/
  116. [root@station60 ~]# umount  /b
  117. [root@station60 ~]# lvremove /dev/vol0/test
  118. Do you really want to remove active logical volume vol0/test? [y/n]: y
  119.   Logical volume "test" successfully removed
  120. [root@station60 ~]# lvremove /dev/vol0/test2
  121. Do you really want to remove active logical volume vol0/test2? [y/n]: y
  122.   Logical volume "test2" successfully removed
  123. [root@station60 ~]# lvs
  124.   LV   VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  125.   root rhel -wi-ao---- <17.00g                                                  
  126.   swap rhel -wi-ao----   2.00g                                                  
  127. [root@station60 ~]# vgremove vol0
  128.   Volume group "vol0" successfully removed
  129. [root@station60 ~]# pvremove /dev/sdb1
  130.   Labels on physical volume "/dev/sdb1" successfully wiped.
  131. [root@station60 ~]# pvremove /dev/sdb2
  132.   Device /dev/sdb2 not found.
  133. [root@station60 ~]# fdisk /dev/sdb
  134. Welcome to fdisk (util-linux 2.23.2).

  135. Changes will remain in memory only, until you decide to write them.
  136. Be careful before using the write command.


  137. Command (m for help): p

  138. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  139. Units = sectors of 1 * 512 = 512 bytes
  140. Sector size (logical/physical): 512 bytes / 512 bytes
  141. I/O size (minimum/optimal): 512 bytes / 512 bytes
  142. Disk label type: dos
  143. Disk identifier: 0x7380aaa7

  144.    Device Boot      Start         End      Blocks   Id  System
  145. /dev/sdb1            2048     1026047      512000   8e  Linux LVM
  146. /dev/sdb4         1026048     2097151      535552    5  Extended
  147. /dev/sdb5         1028096     2097151      534528   8e  Linux LVM

  148. Command (m for help): d
  149. Partition number (1,4,5, default 5): 4
  150. Partition 4 is deleted

  151. Command (m for help): p

  152. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  153. Units = sectors of 1 * 512 = 512 bytes
  154. Sector size (logical/physical): 512 bytes / 512 bytes
  155. I/O size (minimum/optimal): 512 bytes / 512 bytes
  156. Disk label type: dos
  157. Disk identifier: 0x7380aaa7

  158.    Device Boot      Start         End      Blocks   Id  System
  159. /dev/sdb1            2048     1026047      512000   8e  Linux LVM

  160. Command (m for help): d
  161. Selected partition 1
  162. Partition 1 is deleted

  163. Command (m for help): p

  164. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  165. Units = sectors of 1 * 512 = 512 bytes
  166. Sector size (logical/physical): 512 bytes / 512 bytes
  167. I/O size (minimum/optimal): 512 bytes / 512 bytes
  168. Disk label type: dos
  169. Disk identifier: 0x7380aaa7

  170.    Device Boot      Start         End      Blocks   Id  System

  171. Command (m for help):
复制代码
创建/dev/sdb上的分区:
  1. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  2. Units = sectors of 1 * 512 = 512 bytes
  3. Sector size (logical/physical): 512 bytes / 512 bytes
  4. I/O size (minimum/optimal): 512 bytes / 512 bytes
  5. Disk label type: dos
  6. Disk identifier: 0x7380aaa7

  7.    Device Boot      Start         End      Blocks   Id  System
  8. /dev/sdb1            2048       18431        8192   83  Linux

  9. Command (m for help): n
  10. Partition type:
  11.    p   primary (1 primary, 0 extended, 3 free)
  12.    e   extended
  13. Select (default p): e
  14. Partition number (2-4, default 2):
  15. First sector (18432-2097151, default 18432):
  16. Using default value 18432
  17. Last sector, +sectors or +size{K,M,G} (18432-2097151, default 2097151):
  18. Using default value 2097151
  19. Partition 2 of type Extended and of size 1015 MiB is set

  20. Command (m for help): p

  21. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  22. Units = sectors of 1 * 512 = 512 bytes
  23. Sector size (logical/physical): 512 bytes / 512 bytes
  24. I/O size (minimum/optimal): 512 bytes / 512 bytes
  25. Disk label type: dos
  26. Disk identifier: 0x7380aaa7

  27.    Device Boot      Start         End      Blocks   Id  System
  28. /dev/sdb1            2048       18431        8192   83  Linux
  29. /dev/sdb2           18432     2097151     1039360    5  Extended

  30. Command (m for help): n
  31. Partition type:
  32.    p   primary (1 primary, 1 extended, 2 free)
  33.    l   logical (numbered from 5)
  34. Select (default p): l
  35. Adding logical partition 5
  36. First sector (20480-2097151, default 20480): 366932
  37. Last sector, +sectors or +size{K,M,G} (366932-2097151, default 2097151): ^C
  38. [root@station60 ~]#
  39. [root@station60 ~]# fdisk /dev/sdb
  40. Welcome to fdisk (util-linux 2.23.2).

  41. Changes will remain in memory only, until you decide to write them.
  42. Be careful before using the write command.


  43. Command (m for help): n
  44. Partition type:
  45.    p   primary (0 primary, 0 extended, 4 free)
  46.    e   extended
  47. Select (default p): p
  48. Partition number (1-4, default 1):
  49. First sector (2048-2097151, default 2048):
  50. Using default value 2048
  51. Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +8M
  52. Partition 1 of type Linux and of size 8 MiB is set

  53. Command (m for help): n
  54. Partition type:
  55.    p   primary (1 primary, 0 extended, 3 free)
  56.    e   extended
  57. Select (default p): e
  58. Partition number (2-4, default 2):
  59. First sector (18432-2097151, default 18432):
  60. Using default value 18432
  61. Last sector, +sectors or +size{K,M,G} (18432-2097151, default 2097151):
  62. Using default value 2097151
  63. Partition 2 of type Extended and of size 1015 MiB is set

  64. Command (m for help): p

  65. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  66. Units = sectors of 1 * 512 = 512 bytes
  67. Sector size (logical/physical): 512 bytes / 512 bytes
  68. I/O size (minimum/optimal): 512 bytes / 512 bytes
  69. Disk label type: dos
  70. Disk identifier: 0x7380aaa7

  71.    Device Boot      Start         End      Blocks   Id  System
  72. /dev/sdb1            2048       18431        8192   83  Linux
  73. /dev/sdb2           18432     2097151     1039360    5  Extended

  74. Command (m for help): n
  75. Partition type:
  76.    p   primary (1 primary, 1 extended, 2 free)
  77.    l   logical (numbered from 5)
  78. Select (default p): l
  79. Adding logical partition 5
  80. First sector (20480-2097151, default 20480):
  81. Using default value 20480
  82. Last sector, +sectors or +size{K,M,G} (20480-2097151, default 2097151): 366932
  83. Partition 5 of type Linux and of size 169.2 MiB is set

  84. Command (m for help): p

  85. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  86. Units = sectors of 1 * 512 = 512 bytes
  87. Sector size (logical/physical): 512 bytes / 512 bytes
  88. I/O size (minimum/optimal): 512 bytes / 512 bytes
  89. Disk label type: dos
  90. Disk identifier: 0x7380aaa7

  91.    Device Boot      Start         End      Blocks   Id  System
  92. /dev/sdb1            2048       18431        8192   83  Linux
  93. /dev/sdb2           18432     2097151     1039360    5  Extended
  94. /dev/sdb5           20480      366932      173226+  83  Linux

  95. Command (m for help): n
  96. Partition type:
  97.    p   primary (1 primary, 1 extended, 2 free)
  98.    l   logical (numbered from 5)
  99. Select (default p): l
  100. Adding logical partition 6
  101. First sector (368981-2097151, default 370688):
  102. Using default value 370688
  103. Last sector, +sectors or +size{K,M,G} (370688-2097151, default 2097151): 717140
  104. Partition 6 of type Linux and of size 169.2 MiB is set

  105. Command (m for help): p

  106. Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
  107. Units = sectors of 1 * 512 = 512 bytes
  108. Sector size (logical/physical): 512 bytes / 512 bytes
  109. I/O size (minimum/optimal): 512 bytes / 512 bytes
  110. Disk label type: dos
  111. Disk identifier: 0x7380aaa7

  112.    Device Boot      Start         End      Blocks   Id  System
  113. /dev/sdb1            2048       18431        8192   83  Linux
  114. /dev/sdb2           18432     2097151     1039360    5  Extended
  115. /dev/sdb5           20480      366932      173226+  83  Linux
  116. /dev/sdb6          370688      717140      173226+  83  Linux

  117. Command (m for help): w
  118. The partition table has been altered!

  119. Calling ioctl() to re-read partition table.
  120. Syncing disks.
  121. [root@station60 ~]#
复制代码
硬链接:
  1. [root@station60 ~]# mkdir labs3
  2. [root@station60 ~]# cd labs
  3. [root@station60 labs]# cd ..
  4. [root@station60 ~]# cd labs3
  5. [root@station60 labs3]# ls
  6. [root@station60 labs3]# vim a.txt
  7. [root@station60 labs3]# ls -i a.txt
  8. 51627289 a.txt
  9. [root@station60 labs3]# ln a.txt  b.txt
  10. [root@station60 labs3]# ls -i
  11. 51627289 a.txt  51627289 b.txt
  12. [root@station60 labs3]# df -h
  13. Filesystem             Size  Used Avail Use% Mounted on
  14. /dev/mapper/rhel-root   17G  3.8G   14G  23% /
  15. devtmpfs               894M     0  894M   0% /dev
  16. tmpfs                  910M     0  910M   0% /dev/shm
  17. tmpfs                  910M   11M  900M   2% /run
  18. tmpfs                  910M     0  910M   0% /sys/fs/cgroup
  19. /dev/sda1             1014M  178M  837M  18% /boot
  20. tmpfs                  182M   12K  182M   1% /run/user/42
  21. tmpfs                  182M     0  182M   0% /run/user/0
  22. [root@station60 labs3]# cd /boot
  23. [root@station60 boot]# ls
  24. config-3.10.0-957.el7.x86_64
  25. efi
  26. grub2
  27. initramfs-0-rescue-2037a776203544ad8108492fccf583eb.img
  28. initramfs-3.10.0-957.el7.x86_64.img
  29. initramfs-3.10.0-957.el7.x86_64kdump.img
  30. symvers-3.10.0-957.el7.x86_64.gz
  31. System.map-3.10.0-957.el7.x86_64
  32. vmlinuz-0-rescue-2037a776203544ad8108492fccf583eb
  33. vmlinuz-3.10.0-957.el7.x86_64
  34. [root@station60 boot]# ln /root/labs3/a.txt  c.txt
  35. ln: failed to create hard link ‘c.txt’ => ‘/root/labs3/a.txt’: Invalid cross-device link
  36. [root@station60 boot]# cd
  37. [root@station60 ~]# ls
  38. anaconda-ks.cfg  Downloads             labs   Music     Templates
  39. Desktop          file1.swp             labs2  Pictures  Videos
  40. Documents        initial-setup-ks.cfg  labs3  Public
  41. [root@station60 ~]# cd labs3/
  42. [root@station60 labs3]# ls
  43. a.txt  b.txt
  44. [root@station60 labs3]# mkdir aa
  45. [root@station60 labs3]# ln aa bb
  46. ln: ‘aa’: hard link not allowed for directory
  47. [root@station60 labs3]# ls
  48. aa  a.txt  b.txt
  49. [root@station60 labs3]# mkdir bb
  50. [root@station60 labs3]# ls -id
  51. 51620827 .
  52. [root@station60 labs3]# ls -id  *
  53.    81223 aa  51627289 a.txt  16783678 bb  51627289 b.txt
  54. [root@station60 labs3]# mount --bind aa  bb
  55. [root@station60 labs3]# ls -id *
  56.    81223 aa  51627289 a.txt     81223 bb  51627289 b.txt
  57. [root@station60 labs3]# ls -l
  58. total 8
  59. drwxr-xr-x. 2 root root 6 Apr 18 09:21 aa
  60. -rw-r--r--. 2 root root 9 Apr 18 09:19 a.txt
  61. drwxr-xr-x. 2 root root 6 Apr 18 09:21 bb
  62. -rw-r--r--. 2 root root 9 Apr 18 09:19 b.txt
  63. [root@station60 labs3]# 81223 ln a.txt  /usr/c.txt
  64. bash: 81223: command not found...
  65. [root@station60 labs3]#  ln a.txt  /usr/c.txt
  66. [root@station60 labs3]# ls -i a.txt /usr/c.txt
  67. 51627289 a.txt  51627289 /usr/c.txt
  68. [root@station60 labs3]# ls -l
  69. total 8
  70. drwxr-xr-x. 2 root root 6 Apr 18 09:21 aa
  71. -rw-r--r--. 3 root root 9 Apr 18 09:19 a.txt
  72. drwxr-xr-x. 2 root root 6 Apr 18 09:21 bb
  73. -rw-r--r--. 3 root root 9 Apr 18 09:19 b.txt
  74. [root@station60 labs3]#
复制代码




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-4-26 08:46 , Processed in 0.049445 second(s), 24 queries .

快速回复 返回顶部 返回列表