日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux磁盘管理练习题(习题+演示)

發布時間:2023/12/20 linux 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux磁盘管理练习题(习题+演示) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

可以先看看這里Linux磁盤管理(概念+演示)

小試牛刀

1、新建兩個分區,它們的大小分別為1G,分別將它們掛載在/apple和/orange目錄下。

2、添加一塊10G的硬盤,如果我想將該硬盤暫時分為4個分區,同時還有其他的剩余容量可以讓我在未來的時候進行規劃,我應該如何分區?

3、我要將大小為5G的/dev/sdc劃分為6個分區,我應該如何分區?

?

實戰練習

1.添加一塊10G大小的磁盤,將該磁盤分為兩個主分區,大小為1G、2G。將剩余的空間全部劃分為擴展分區。劃分一個邏輯分區,大小為3G。(主分區文件系統類型為ext4,邏輯分區文件系統類型為xfs)

2. 將三個分區分別掛載到/haha、/wuwu、/hehe。

3.在第一個主分區中創建一個文件為file1,內容為this is partition1。在第二個分區中創建一個文件為file2,內容為this is partition2。在第三個分區中創建一個文件為file3,內容為this is partition3。


?

小試牛刀

第一題

思路:

首先創建一個擴展分區,然后在其下創建兩個邏輯分區大小分別為1G,保存退出,內核更新,格式化,然后在指定目錄進行掛載

演示:

1.創建擴展分區,并在其下創建邏輯分區

Sda4擴展分區,sda5 sda6是邏輯分區

1048576/1024/1024 = 1

2.保存退出,內核識別,格式化分區

這里提示的是光盤的只讀權限,與新創建的兩個分區無關

3.手動掛載

第二題:

思路:

?????? 使用擴展分區,可以將前三個或第一個作為主分區,最后一個配置成擴展分區,后期想要使用剩余的容量時,直接創建邏輯分區即可

演示:

首先添加一個10G大小的擴展分區,然后在其下創建三個主分區和一個擴展分區,前三個主分區大小都是1G,如果后期還想要使用剩余容量時,直接創建邏輯分區即可

?

?

?

創建完成后打開虛擬機,可以看到有一個名為/dev/sdb的新磁盤

前三個分區是主分區,第四個分區是擴展分區,目前10G磁盤還有7G沒有使用,想要用的話,就創建邏輯分區即可

第三題

思路:

?????? 與第二題相同,即使用擴展分區,基于擴展分區來創建邏輯分區,進而實現需求,注意這里時sdc 意思時第三塊磁盤,具體參考這篇文章的磁盤命名介紹即可

?

實戰練習

首先,添加一個10G的磁盤,用的是小試牛刀中的磁盤(先將磁盤中原本的分區刪除),然后添加主分區與擴展分區即可,sdb1 2是主分區大小分別為1G、2G sdb5是邏輯分區,大小是3G

[root@localhost ~]# fdisk /dev/sdb Command (m for help): pDisk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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: 0xbd290ff9Device Boot Start End Blocks Id SystemCommand (m for help): n Partition type:p primary (0 primary, 0 extended, 4 free)e extended Select (default p): Using default response p Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1G Partition 1 of type Linux and of size 1 GiB is setCommand (m for help): n Partition type:p primary (1 primary, 0 extended, 3 free)e extended Select (default p): Using default response p Partition number (2-4, default 2): First sector (2099200-20971519, default 2099200): Using default value 2099200 Last sector, +sectors or +size{K,M,G} (2099200-20971519, default 20971519): +2G Partition 2 of type Linux and of size 2 GiB is setCommand (m for help): n Partition type:p primary (2 primary, 0 extended, 2 free)e extended Select (default p): e Partition number (3,4, default 3): First sector (6293504-20971519, default 6293504): Using default value 6293504 Last sector, +sectors or +size{K,M,G} (6293504-20971519, default 20971519): Using default value 20971519 Partition 3 of type Extended and of size 7 GiB is setCommand (m for help): pDisk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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: 0xbd290ff9Device Boot Start End Blocks Id System /dev/sdb1 2048 2099199 1048576 83 Linux /dev/sdb2 2099200 6293503 2097152 83 Linux /dev/sdb3 6293504 20971519 7339008 5 ExtendedCommand (m for help): n Partition type:p primary (2 primary, 1 extended, 1 free)l logical (numbered from 5) Select (default p): l Adding logical partition 5 First sector (6295552-20971519, default 6295552): Using default value 6295552 Last sector, +sectors or +size{K,M,G} (6295552-20971519, default 20971519): +3G Partition 5 of type Linux and of size 3 GiB is setCommand (m for help): pDisk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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: 0xbd290ff9Device Boot Start End Blocks Id System /dev/sdb1 2048 2099199 1048576 83 Linux /dev/sdb2 2099200 6293503 2097152 83 Linux /dev/sdb3 6293504 20971519 7339008 5 Extended /dev/sdb5 6295552 12587007 3145728 83 Linux

?

接下來保存退出,是內核識別,然后格式化分區

[root@localhost ~]# mkfs.ext4 /dev/sdb1 [root@localhost ~]# mkfs.ext4 /dev/sdb2 [root@localhost ~]# mkfs.xfs /dev/sdb5

查看:

根據題中要求,創建掛載點目錄,進行掛載

[root@localhost /]# mkdir /haha [root@localhost /]# mkdir /wuwu [root@localhost /]# mkdir /hehe [root@localhost /]# mount /dev/sdb1 /haha [root@localhost /]# mount /dev/sdb2 /wuwu [root@localhost /]# mount /dev/sdb5 /hehe [root@localhost /]# mount | grep /dev/sdb

在分區內創建文件

[root@localhost ~]# echo this is partition1 > /haha/file1 [root@localhost ~]# echo this is partition2 > /wuwu/file2 [root@localhost ~]# echo this is partition3 > /hehe/file3


?

總結

以上是生活随笔為你收集整理的Linux磁盘管理练习题(习题+演示)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。