Linux系统第二次作业

Xshell 8 (Build 0065)
Copyright (c) 2024 NetSarang Computer, Inc. All rights reserved.

Type `help' to learn how to use Xshell prompt.
[C:~]$

Connecting to 192.168.109.129:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: rhc connect

Example:

rhc connect --activation-key <key> --organization <org>

The rhc client and Red Hat Insights will enable analytics and additional
management capabilities on your system.
View your connected systems at https://console.redhat.com/insights

You can learn more about how to register your system
using rhc at https://red.ht/registration
Last login: Thu Jan 16 22:27:09 2025 from 192.168.109.1
1、第一块硬盘,虚拟磁盘类型选择SCSI。大小选择为5g。按mbr格式分区。分两个主分区,大小分别为2g和3g,第一个主分区创建ext2类型的文件系统。第一个主分区挂载在/guazai1目录,并在其中存入1.txt的文件。其文件内容是this is 1.txt。第二个主分区创建ext3的类型的文件系统。第二个主分区挂载在/guazai2目录,并在其中存入2.txt的文件。其文件内容是this is 2.txt。
[root@hyc ~]# lsblk -p
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
/dev/sda 8:0 0 10G 0 disk
/dev/sdb 8:16 0 5G 0 disk
├─/dev/sdb1 8:17 0 2G 0 part
├─/dev/sdb2 8:18 0 2G 0 part
└─/dev/sdb3 8:19 0 1023M 0 part
/dev/sr0 11:0 1 11G 0 rom
/dev/nvme0n1 259:0 0 20G 0 disk
├─/dev/nvme0n1p1 259:1 0 600M 0 part /boot/efi
├─/dev/nvme0n1p2 259:2 0 1G 0 part /boot
└─/dev/nvme0n1p3 259:3 0 18.4G 0 part
├─/dev/mapper/rhel-root 253:0 0 16.4G 0 lvm /
└─/dev/mapper/rhel-swap 253:1 0 2G 0 lvm [SWAP]
/dev/nvme0n2 259:4 0 10G 0 disk
└─/dev/nvme0n2p1 259:5 0 2G 0 part /root/guazai
/guazai
[root@hyc ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): n
All space for primary partitions is in use.

Command (m for help):

Command (m for help):

Command (m for help): p

Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1b5debd1

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 4196351 4194304 2G 83 Linux
/dev/sdb2 4196352 8390655 4194304 2G 83 Linux
/dev/sdb3 8390656 10485759 2095104 1023M 83 Linux

Command (m for help): d
Partition number (1-3, default 3):

Partition 3 has been deleted.

Command (m for help): d
Partition number (1,2, default 2):

Partition 2 has been deleted.

Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p):

Using default response p.
Partition number (2-4, default 2):
First sector (4196352-10485759, default 4196352):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4196352-10485759, default 10485759): +3G
Value out of range.
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4196352-10485759, default 10485759): +2G

Created a new partition 2 of type 'Linux' and of size 2 GiB.
Partition #2 contains a ext3 signature.

Do you want to remove the signature? [Y]es/[N]o: N

Command (m for help): p

Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1b5debd1

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 4196351 4194304 2G 83 Linux
/dev/sdb2 4196352 8390655 4194304 2G 83 Linux

Command (m for help): mkfs.ext2 /dev/sdb1

Help:

DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag

Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition

Misc
m print this menu
u change display/entry units
x extra functionality (experts only)

Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file

Save & Exit
w write table to disk and exit
q quit without saving changes

Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[root@hyc ~]# mkdir /guazai1
mkdir: cannot create directory ‘/guazai1’: File exists
[root@hyc ~]# rm -rf /guazai1
[root@hyc ~]# mkdir /guazai1
[root@hyc ~]# echo this is 1.txt > /guazai1/1.txt
[root@hyc ~]# mkfs.ext3 /dev/sdb2
mke2fs 1.46.5 (30-Dec-2021)
/dev/sdb2 contains a ext3 file system
last mounted on /guazai2 on Wed Jan 15 15:44:53 2025
Proceed anyway? (y,N) mkdi^H N

[root@hyc ~]# mkdir /guazai2
mkdir: cannot create directory ‘/guazai2’: File exists
[root@hyc ~]# rm -rf /guazai2
[root@hyc ~]# mkdir /guazai2
[root@hyc ~]# echo this is 2.txt > /guazai2/2.txt
[root@hyc ~]# reboot
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(192.168.109.129) at 22:50:55.

Type `help' to learn how to use Xshell prompt.
[C:~]$ ssh root@192.168.109.129

Connecting to 192.168.109.129:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: rhc connect

Example:

rhc connect --activation-key <key> --organization <org>

The rhc client and Red Hat Insights will enable analytics and additional
management capabilities on your system.
View your connected systems at https://console.redhat.com/insights

You can learn more about how to register your system
using rhc at https://red.ht/registration
Last login: Thu Jan 16 22:52:00 2025
2、第二块硬盘,虚拟磁盘类型选择STAT。大小选择10G。按mbr格式分区。分-个主分区,大小1G分一个扩展分区。大小为6G。分一个逻辑分区,大小为4G。将主分区创建为ext4类型的文件系统。挂载到/guazai3目录。在其中存入3.txt的文件,文件内容是this is 3.txt。将逻辑分区创建xfs类型的文件系 统。挂载到/guazai4目录。在其中存入4.txt的文件, 文件内容是this is 4.txt。
[root@hyc ~]# lsblk -p
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
/dev/sda 8:0 0 10G 0 disk
/dev/sdb 8:16 0 5G 0 disk
├─/dev/sdb1 8:17 0 2G 0 part
└─/dev/sdb2 8:18 0 2G 0 part
/dev/sr0 11:0 1 11G 0 rom /run/media/root/RHEL-9-5-0-BaseOS-x86_64
/dev/nvme0n1 259:0 0 20G 0 disk
├─/dev/nvme0n1p1 259:1 0 600M 0 part /boot/efi
├─/dev/nvme0n1p2 259:2 0 1G 0 part /boot
└─/dev/nvme0n1p3 259:3 0 18.4G 0 part
├─/dev/mapper/rhel-root 253:0 0 16.4G 0 lvm /
└─/dev/mapper/rhel-swap 253:1 0 2G 0 lvm [SWAP]
/dev/nvme0n2 259:4 0 10G 0 disk
└─/dev/nvme0n2p1 259:5 0 2G 0 part /root/guazai
/guazai
[root@hyc ~]# fdisk /dev/sda

Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x0097ef0d.

Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):

Using default response p.
Partition number (1-4, default 1):
First sector (2048-20971519, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519): +1G

Created a new partition 1 of type 'Linux' and of size 1 GiB.

Command (m for help): p
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0097ef0d

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2099199 2097152 1G 83 Linux

Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): e
Partition number (2-4, default 2):
First sector (2099200-20971519, default 2099200):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-20971519, default 20971519): +6G

Created a new partition 2 of type 'Extended' and of size 6 GiB.

Command (m for help): p
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0097ef0d

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 14682111 12582912 6G 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 (2101248-14682111, default 2101248):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2101248-14682111, default 14682111): +4G

Created a new partition 5 of type 'Linux' and of size 4 GiB.

Command (m for help): p
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0097ef0d

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 14682111 12582912 6G 5 Extended
/dev/sda5 2101248 10489855 8388608 4G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[root@hyc ~]# mkfs.ext4 /dev/sda1
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: fab926b0-9d61-4f9b-988d-3e9311a1a505
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

[root@hyc ~]# mkdir /guazai3
[root@hyc ~]# echo this is 3.txt > /guazai3/3.txt
[root@hyc ~]# mkfs.xfs /dev/sda5
meta-data=/dev/sda5 isize=512 agcount=4, agsize=262144 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1 nrext64=0
data = bsize=4096 blocks=1048576, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@hyc ~]# mkdir /guazai4
[root@hyc ~]# echo this is 4.txt > /guazai4/4.txt
[root@hyc ~]# reboot
[root@hyc ~]# Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(192.168.109.129:22) at 22:57:49.

Type `help' to learn how to use Xshell prompt.
[C:~]$ ssh root@192.168.109.129

Connecting to 192.168.109.129:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: rhc connect

Example:

rhc connect --activation-key <key> --organization <org>

The rhc client and Red Hat Insights will enable analytics and additional
management capabilities on your system.
View your connected systems at https://console.redhat.com/insights

You can learn more about how to register your system
using rhc at https://red.ht/registration
Last login: Thu Jan 16 23:00:03 2025
3、第三块硬盘,虛拟磁盘类型选择NVME。大小选择15G。按gpt格式分区。分一个主分区。 大小为5G。主分区创建xfs类型的文件系统,挂载到/guazai5目录,在其中存入5.txt的文件,其文件内容是this is 5.txt。
[root@hyc ~]# lsblk -p
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
/dev/sda 8:0 0 10G 0 disk
├─/dev/sda1 8:1 0 1G 0 part
├─/dev/sda2 8:2 0 1K 0 part
└─/dev/sda5 8:5 0 4G 0 part
/dev/sdb 8:16 0 5G 0 disk
├─/dev/sdb1 8:17 0 2G 0 part
└─/dev/sdb2 8:18 0 2G 0 part
/dev/sr0 11:0 1 11G 0 rom /run/media/root/RHEL-9-5-0-BaseOS-x86_64
/dev/nvme0n1 259:0 0 20G 0 disk
├─/dev/nvme0n1p1 259:1 0 600M 0 part /boot/efi
├─/dev/nvme0n1p2 259:2 0 1G 0 part /boot
└─/dev/nvme0n1p3 259:3 0 18.4G 0 part
├─/dev/mapper/rhel-root 253:0 0 16.4G 0 lvm /
└─/dev/mapper/rhel-swap 253:1 0 2G 0 lvm [SWAP]
/dev/nvme0n2 259:4 0 10G 0 disk
└─/dev/nvme0n2p1 259:5 0 2G 0 part /root/guazai
/guazai
/dev/nvme0n3 259:6 0 15G 0 disk
[root@hyc ~]# fdisk /dev/nvme0n3

Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xfa15a757.

Command (m for help): g
Created a new GPT disklabel (GUID: 3E64CBCC-7DEB-294E-80E0-A09473DC3D51).

Command (m for help): p
Disk /dev/nvme0n3: 15 GiB, 16106127360 bytes, 31457280 sectors
Disk model: VMware Virtual NVMe Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3E64CBCC-7DEB-294E-80E0-A09473DC3D51

Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-31457246, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-31457246, default 31457246): +5G

Created a new partition 1 of type 'Linux filesystem' and of size 5 GiB.

Command (m for help): p
Disk /dev/nvme0n3: 15 GiB, 16106127360 bytes, 31457280 sectors
Disk model: VMware Virtual NVMe Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3E64CBCC-7DEB-294E-80E0-A09473DC3D51

Device Start End Sectors Size Type
/dev/nvme0n3p1 2048 10487807 10485760 5G Linux filesystem

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[root@hyc ~]# mkfs.xfs /dev/nvme0n3
mkfs.xfs: /dev/nvme0n3 appears to contain a partition table (gpt).
mkfs.xfs: Use the -f option to force overwrite.
[root@hyc ~]# mkdir /guazai5
[root@hyc ~]# echo this is 5.txt > /guazai5/5.txt
[root@hyc ~]#

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容