|
删除/dev/sdb上的所有分区:
- [root@station60 ~]# tune2fs -l /dev/mapper/vol0-test
- tune2fs 1.42.9 (28-Dec-2013)
- Filesystem volume name: <none>
- Last mounted on: <not available>
- Filesystem UUID: 04631ed5-4009-42fe-a483-68d41bd8ba1e
- Filesystem magic number: 0xEF53
- Filesystem revision #: 1 (dynamic)
- Filesystem features: has_journal ext_attr resize_inode dir_index filetype ng dir_nlink extra_isize
- Filesystem flags: signed_directory_hash
- Default mount options: user_xattr acl
- Filesystem state: clean
- Errors behavior: Continue
- Filesystem OS type: Linux
- Inode count: 12288
- Block count: 12288
- Reserved block count: 614
- Free blocks: 10865
- Free inodes: 12277
- First block: 0
- Block size: 4096
- Fragment size: 4096
- Group descriptor size: 64
- Reserved GDT blocks: 5
- Blocks per group: 32768
- Fragments per group: 32768
- Inodes per group: 12288
- Inode blocks per group: 384
- Flex block group size: 16
- Filesystem created: Thu Apr 18 08:38:47 2019
- Last mount time: Thu Apr 18 08:39:54 2019
- Last write time: Thu Apr 18 08:39:54 2019
- Mount count: 1
- Maximum mount count: -1
- Last checked: Thu Apr 18 08:38:47 2019
- Check interval: 0 (<none>)
- Lifetime writes: 4221 kB
- Reserved blocks uid: 0 (user root)
- Reserved blocks gid: 0 (group root)
- First inode: 11
- Inode size: 128
- Journal inode: 8
- Default directory hash: half_md4
- Directory Hash Seed: cabd7b01-f8f7-453d-b349-4935e9eebd53
- Journal backup: inode blocks
- [root@station60 ~]# clear
- [root@station60 ~]# man fsck
- [root@station60 ~]# cat /proc/partitions
- major minor #blocks name
- 8 0 20971520 sda
- 8 1 1048576 sda1
- 8 2 19921920 sda2
- 8 16 1048576 sdb
- 8 17 512000 sdb1
- 8 20 1 sdb4
- 8 21 534528 sdb5
- 11 0 4391936 sr0
- 253 0 17821696 dm-0
- 253 1 2097152 dm-1
- 253 2 49152 dm-2
- 253 3 49152 dm-3
- 253 4 32768 dm-4
- 253 5 49152 dm-5
- 253 6 32768 dm-6
- 253 7 49152 dm-7
- 253 8 65536 dm-8
- [root@station60 ~]# 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): 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: 0x7380aaa7
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 1026047 512000 8e Linux LVM
- /dev/sdb4 1026048 2097151 535552 5 Extended
- /dev/sdb5 1028096 2097151 534528 8e Linux LVM
- Command (m for help): q
- [root@station60 ~]# df -Th
- Filesystem Type Size Used Avail Use% Mounted on
- /dev/mapper/rhel-root xfs 17G 3.7G 14G 22% /
- devtmpfs devtmpfs 894M 0 894M 0% /dev
- tmpfs tmpfs 910M 0 910M 0% /dev/shm
- tmpfs tmpfs 910M 11M 900M 2% /run
- tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
- /dev/sda1 xfs 1014M 178M 837M 18% /boot
- tmpfs tmpfs 182M 12K 182M 1% /run/user/42
- tmpfs tmpfs 182M 0 182M 0% /run/user/0
- /dev/mapper/vol0-test2 xfs 61M 3.4M 58M 6% /b
- /dev/mapper/vol0-test ext4 43M 44K 40M 1% /a
- [root@station60 ~]# pvs
- PV VG Fmt Attr PSize PFree
- /dev/sda2 rhel lvm2 a-- <19.00g 0
- /dev/sdb1 vol0 lvm2 a-- 496.00m 496.00m
- /dev/sdb5 vol0 lvm2 a-- 512.00m 336.00m
- [root@station60 ~]# lvs
- LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
- root rhel -wi-ao---- <17.00g
- swap rhel -wi-ao---- 2.00g
- test vol0 owi-aos--- 48.00m
- test2 vol0 -wi-ao---- 64.00m
- testsnap vol0 sri-a-s--- 32.00m test 17.70
- testsnaprw vol0 swi-a-s--- 32.00m test 17.71
- [root@station60 ~]# lvremove /dev/vol0/testsnaprw
- Do you really want to remove active logical volume vol0/testsnaprw? [y/n]: y
- Logical volume "testsnaprw" successfully removed
- [root@station60 ~]# lvremove /dev/vol0/testsnap
- Do you really want to remove active logical volume vol0/testsnap? [y/n]: y
- Logical volume "testsnap" successfully removed
- [root@station60 ~]# lvremove /dev/vol0/test
- Logical volume vol0/test contains a filesystem in use.
- [root@station60 ~]# umount /a/
- [root@station60 ~]# umount /b
- [root@station60 ~]# lvremove /dev/vol0/test
- Do you really want to remove active logical volume vol0/test? [y/n]: y
- Logical volume "test" successfully removed
- [root@station60 ~]# lvremove /dev/vol0/test2
- Do you really want to remove active logical volume vol0/test2? [y/n]: y
- Logical volume "test2" successfully removed
- [root@station60 ~]# lvs
- LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
- root rhel -wi-ao---- <17.00g
- swap rhel -wi-ao---- 2.00g
- [root@station60 ~]# vgremove vol0
- Volume group "vol0" successfully removed
- [root@station60 ~]# pvremove /dev/sdb1
- Labels on physical volume "/dev/sdb1" successfully wiped.
- [root@station60 ~]# pvremove /dev/sdb2
- Device /dev/sdb2 not found.
- [root@station60 ~]# 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): 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: 0x7380aaa7
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 1026047 512000 8e Linux LVM
- /dev/sdb4 1026048 2097151 535552 5 Extended
- /dev/sdb5 1028096 2097151 534528 8e Linux LVM
- Command (m for help): d
- Partition number (1,4,5, default 5): 4
- Partition 4 is deleted
- 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: 0x7380aaa7
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 1026047 512000 8e Linux LVM
- Command (m for help): d
- Selected partition 1
- Partition 1 is deleted
- 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: 0x7380aaa7
- Device Boot Start End Blocks Id System
- Command (m for help):
复制代码 创建/dev/sdb上的分区:
- 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: 0x7380aaa7
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 18431 8192 83 Linux
- Command (m for help): n
- Partition type:
- p primary (1 primary, 0 extended, 3 free)
- e extended
- Select (default p): e
- Partition number (2-4, default 2):
- First sector (18432-2097151, default 18432):
- Using default value 18432
- Last sector, +sectors or +size{K,M,G} (18432-2097151, default 2097151):
- Using default value 2097151
- Partition 2 of type Extended and of size 1015 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: 0x7380aaa7
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 18431 8192 83 Linux
- /dev/sdb2 18432 2097151 1039360 5 Extended
- Command (m for help): n
- Partition type:
- p primary (1 primary, 1 extended, 2 free)
- l logical (numbered from 5)
- Select (default p): l
- Adding logical partition 5
- First sector (20480-2097151, default 20480): 366932
- Last sector, +sectors or +size{K,M,G} (366932-2097151, default 2097151): ^C
- [root@station60 ~]#
- [root@station60 ~]# 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): +8M
- Partition 1 of type Linux and of size 8 MiB is set
- Command (m for help): n
- Partition type:
- p primary (1 primary, 0 extended, 3 free)
- e extended
- Select (default p): e
- Partition number (2-4, default 2):
- First sector (18432-2097151, default 18432):
- Using default value 18432
- Last sector, +sectors or +size{K,M,G} (18432-2097151, default 2097151):
- Using default value 2097151
- Partition 2 of type Extended and of size 1015 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: 0x7380aaa7
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 18431 8192 83 Linux
- /dev/sdb2 18432 2097151 1039360 5 Extended
- Command (m for help): n
- Partition type:
- p primary (1 primary, 1 extended, 2 free)
- l logical (numbered from 5)
- Select (default p): l
- Adding logical partition 5
- First sector (20480-2097151, default 20480):
- Using default value 20480
- Last sector, +sectors or +size{K,M,G} (20480-2097151, default 2097151): 366932
- Partition 5 of type Linux and of size 169.2 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: 0x7380aaa7
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 18431 8192 83 Linux
- /dev/sdb2 18432 2097151 1039360 5 Extended
- /dev/sdb5 20480 366932 173226+ 83 Linux
- Command (m for help): n
- Partition type:
- p primary (1 primary, 1 extended, 2 free)
- l logical (numbered from 5)
- Select (default p): l
- Adding logical partition 6
- First sector (368981-2097151, default 370688):
- Using default value 370688
- Last sector, +sectors or +size{K,M,G} (370688-2097151, default 2097151): 717140
- Partition 6 of type Linux and of size 169.2 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: 0x7380aaa7
- Device Boot Start End Blocks Id System
- /dev/sdb1 2048 18431 8192 83 Linux
- /dev/sdb2 18432 2097151 1039360 5 Extended
- /dev/sdb5 20480 366932 173226+ 83 Linux
- /dev/sdb6 370688 717140 173226+ 83 Linux
- Command (m for help): w
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- Syncing disks.
- [root@station60 ~]#
复制代码 硬链接:- [root@station60 ~]# mkdir labs3
- [root@station60 ~]# cd labs
- [root@station60 labs]# cd ..
- [root@station60 ~]# cd labs3
- [root@station60 labs3]# ls
- [root@station60 labs3]# vim a.txt
- [root@station60 labs3]# ls -i a.txt
- 51627289 a.txt
- [root@station60 labs3]# ln a.txt b.txt
- [root@station60 labs3]# ls -i
- 51627289 a.txt 51627289 b.txt
- [root@station60 labs3]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/rhel-root 17G 3.8G 14G 23% /
- devtmpfs 894M 0 894M 0% /dev
- tmpfs 910M 0 910M 0% /dev/shm
- tmpfs 910M 11M 900M 2% /run
- tmpfs 910M 0 910M 0% /sys/fs/cgroup
- /dev/sda1 1014M 178M 837M 18% /boot
- tmpfs 182M 12K 182M 1% /run/user/42
- tmpfs 182M 0 182M 0% /run/user/0
- [root@station60 labs3]# cd /boot
- [root@station60 boot]# ls
- config-3.10.0-957.el7.x86_64
- efi
- grub2
- initramfs-0-rescue-2037a776203544ad8108492fccf583eb.img
- initramfs-3.10.0-957.el7.x86_64.img
- initramfs-3.10.0-957.el7.x86_64kdump.img
- symvers-3.10.0-957.el7.x86_64.gz
- System.map-3.10.0-957.el7.x86_64
- vmlinuz-0-rescue-2037a776203544ad8108492fccf583eb
- vmlinuz-3.10.0-957.el7.x86_64
- [root@station60 boot]# ln /root/labs3/a.txt c.txt
- ln: failed to create hard link ‘c.txt’ => ‘/root/labs3/a.txt’: Invalid cross-device link
- [root@station60 boot]# cd
- [root@station60 ~]# ls
- anaconda-ks.cfg Downloads labs Music Templates
- Desktop file1.swp labs2 Pictures Videos
- Documents initial-setup-ks.cfg labs3 Public
- [root@station60 ~]# cd labs3/
- [root@station60 labs3]# ls
- a.txt b.txt
- [root@station60 labs3]# mkdir aa
- [root@station60 labs3]# ln aa bb
- ln: ‘aa’: hard link not allowed for directory
- [root@station60 labs3]# ls
- aa a.txt b.txt
- [root@station60 labs3]# mkdir bb
- [root@station60 labs3]# ls -id
- 51620827 .
- [root@station60 labs3]# ls -id *
- 81223 aa 51627289 a.txt 16783678 bb 51627289 b.txt
- [root@station60 labs3]# mount --bind aa bb
- [root@station60 labs3]# ls -id *
- 81223 aa 51627289 a.txt 81223 bb 51627289 b.txt
- [root@station60 labs3]# ls -l
- total 8
- drwxr-xr-x. 2 root root 6 Apr 18 09:21 aa
- -rw-r--r--. 2 root root 9 Apr 18 09:19 a.txt
- drwxr-xr-x. 2 root root 6 Apr 18 09:21 bb
- -rw-r--r--. 2 root root 9 Apr 18 09:19 b.txt
- [root@station60 labs3]# 81223 ln a.txt /usr/c.txt
- bash: 81223: command not found...
- [root@station60 labs3]# ln a.txt /usr/c.txt
- [root@station60 labs3]# ls -i a.txt /usr/c.txt
- 51627289 a.txt 51627289 /usr/c.txt
- [root@station60 labs3]# ls -l
- total 8
- drwxr-xr-x. 2 root root 6 Apr 18 09:21 aa
- -rw-r--r--. 3 root root 9 Apr 18 09:19 a.txt
- drwxr-xr-x. 2 root root 6 Apr 18 09:21 bb
- -rw-r--r--. 3 root root 9 Apr 18 09:19 b.txt
- [root@station60 labs3]#
复制代码
|
|