课程第7次
删除/dev/sdb上的所有分区:
# 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
# clear
# man fsck
# cat /proc/partitions
major minor#blocksname
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
# 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 IdSystem
/dev/sdb1 2048 1026047 512000 8eLinux LVM
/dev/sdb4 1026048 2097151 535552 5Extended
/dev/sdb5 1028096 2097151 534528 8eLinux LVM
Command (m for help): q
# df -Th
Filesystem Type SizeUsed Avail Use% Mounted on
/dev/mapper/rhel-rootxfs 17G3.7G 14G22% /
devtmpfs devtmpfs894M 0894M 0% /dev
tmpfs tmpfs 910M 0910M 0% /dev/shm
tmpfs tmpfs 910M 11M900M 2% /run
tmpfs tmpfs 910M 0910M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M178M837M18% /boot
tmpfs tmpfs 182M 12K182M 1% /run/user/42
tmpfs tmpfs 182M 0182M 0% /run/user/0
/dev/mapper/vol0-test2 xfs 61M3.4M 58M 6% /b
/dev/mapper/vol0-testext4 43M 44K 40M 1% /a
# pvs
PV VG FmtAttr PSize PFree
/dev/sda2rhel lvm2 a--<19.00g 0
/dev/sdb1vol0 lvm2 a--496.00m 496.00m
/dev/sdb5vol0 lvm2 a--512.00m 336.00m
# 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
# lvremove /dev/vol0/testsnaprw
Do you really want to remove active logical volume vol0/testsnaprw? : y
Logical volume "testsnaprw" successfully removed
# lvremove /dev/vol0/testsnap
Do you really want to remove active logical volume vol0/testsnap? : y
Logical volume "testsnap" successfully removed
# lvremove /dev/vol0/test
Logical volume vol0/test contains a filesystem in use.
# umount/a/
# umount/b
# lvremove /dev/vol0/test
Do you really want to remove active logical volume vol0/test? : y
Logical volume "test" successfully removed
# lvremove /dev/vol0/test2
Do you really want to remove active logical volume vol0/test2? : y
Logical volume "test2" successfully removed
# 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
# vgremove vol0
Volume group "vol0" successfully removed
# pvremove /dev/sdb1
Labels on physical volume "/dev/sdb1" successfully wiped.
# pvremove /dev/sdb2
Device /dev/sdb2 not found.
# 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 IdSystem
/dev/sdb1 2048 1026047 512000 8eLinux LVM
/dev/sdb4 1026048 2097151 535552 5Extended
/dev/sdb5 1028096 2097151 534528 8eLinux 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 IdSystem
/dev/sdb1 2048 1026047 512000 8eLinux 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 IdSystem
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 IdSystem
/dev/sdb1 2048 18431 8192 83Linux
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 IdSystem
/dev/sdb1 2048 18431 8192 83Linux
/dev/sdb2 18432 2097151 1039360 5Extended
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
#
# 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 IdSystem
/dev/sdb1 2048 18431 8192 83Linux
/dev/sdb2 18432 2097151 1039360 5Extended
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 IdSystem
/dev/sdb1 2048 18431 8192 83Linux
/dev/sdb2 18432 2097151 1039360 5Extended
/dev/sdb5 20480 366932 173226+83Linux
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 IdSystem
/dev/sdb1 2048 18431 8192 83Linux
/dev/sdb2 18432 2097151 1039360 5Extended
/dev/sdb5 20480 366932 173226+83Linux
/dev/sdb6 370688 717140 173226+83Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#
硬链接:# mkdir labs3
# cd labs
# cd ..
# cd labs3
# ls
# vim a.txt
# ls -i a.txt
51627289 a.txt
# ln a.txtb.txt
# ls -i
51627289 a.txt51627289 b.txt
# df -h
Filesystem SizeUsed Avail Use% Mounted on
/dev/mapper/rhel-root 17G3.8G 14G23% /
devtmpfs 894M 0894M 0% /dev
tmpfs 910M 0910M 0% /dev/shm
tmpfs 910M 11M900M 2% /run
tmpfs 910M 0910M 0% /sys/fs/cgroup
/dev/sda1 1014M178M837M18% /boot
tmpfs 182M 12K182M 1% /run/user/42
tmpfs 182M 0182M 0% /run/user/0
# cd /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
# ln /root/labs3/a.txtc.txt
ln: failed to create hard link ‘c.txt’ => ‘/root/labs3/a.txt’: Invalid cross-device link
# cd
# ls
anaconda-ks.cfgDownloads labs Music Templates
Desktop file1.swp labs2PicturesVideos
Documents initial-setup-ks.cfglabs3Public
# cd labs3/
# ls
a.txtb.txt
# mkdir aa
# ln aa bb
ln: ‘aa’: hard link not allowed for directory
# ls
aaa.txtb.txt
# mkdir bb
# ls -id
51620827 .
# ls -id*
81223 aa51627289 a.txt16783678 bb51627289 b.txt
# mount --bind aabb
# ls -id *
81223 aa51627289 a.txt 81223 bb51627289 b.txt
# 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
# 81223 ln a.txt/usr/c.txt
bash: 81223: command not found...
#ln a.txt/usr/c.txt
# ls -i a.txt /usr/c.txt
51627289 a.txt51627289 /usr/c.txt
# 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
#
页:
[1]