Linux開發_ Linux命令復習與文件目錄復習
907
2025-03-31
=================================
/*
* @平臺:華為云
* @描述:擴容空間
*/
=================================
一、在華為云平臺購買云硬盤EVS
步驟略....
注意:
1. 在購買數據盤時注意可用區需要和linux云服務器在同一可用區;
2. 購買完磁盤后,需要在控制臺進行一次掛載,將該硬盤掛載到相應服務器下。
二、掛載磁盤
1. 查看磁盤信息
# fdisk -l Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000aa138 Device Boot Start End Blocks Id System /dev/vda1 * 2048 83886079 41942016 83 Linux Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0xe5161fba Device Boot Start End Blocks Id System /dev/vdb1 2048 41938943 20968448 7 HPFS/NTFS/exFAT
可以看出上述的服務器擁有兩塊磁盤,其中Disk /dev/vda為原有磁盤,Disk /dev/vdb為新增磁盤
2. 對數據盤進行分區
進入fdisk分區工具,根據提示開始對新增數據盤進行分區操作。 # fdisk /dev/vdb 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 # 輸入“n”,按“Enter”,開始新建分區。 以創建一個主要分區為例,輸入“p”,按“Enter”,開始創建一個主分區。 以分區編號選擇“2”為例,輸入主分區編號“2”,按“Enter”。 Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): 2 “First sector”表示初始磁柱區域,可以選擇41938944-41943039,默認為41938944。 以選擇默認初始磁柱編號41938944為例,按“Enter”。 First sector (41938944-41943039, default 41938944): Using default value 41938944 “Last sector”表示截止磁柱區域,可以選擇41938944-41943039,默認為41943039。 以選擇默認截止磁柱編號41943039為例,按“Enter”。 Last sector, +sectors or +size{K,M,G} (41938944-41943039, default 41943039): Using default value 41943039 Partition 2 of type Linux and of size 2 MiB is set 表示分區完成,即為20GB的數據盤新建了1個分區。 輸入“p”,按“Enter”,查看新建分區的詳細信息。 Command (m for help): p Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0xe5161fba Device Boot Start End Blocks Id System /dev/vdb1 2048 41938943 20968448 7 HPFS/NTFS/exFAT /dev/vdb2 41938944 41943039 2048 83 Linux 表示新建分區“/dev/vdb1”的詳細信息。 輸入“w”,按“Enter”,將分區結果寫入分區表中。 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. 注:如果之前分區操作有誤,請輸入“q”,則會退出fdisk分區工具,之前的分區結果將不會被保留。 執行以下命令,將新的分區表變更同步至操作系統。 # partprobe
3. 格式化(設置文件系統為ext4)
#格式化需要等待一段時間,不要退出,等待任務狀態為done。 # mkfs -t ext4 /dev/vdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1310720 inodes, 5242112 blocks 262105 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2153775104 160 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
4. 掛載
創建掛載點,或者指定的文件位置
# mkdir /mnt/nfsdata
將新建分區掛載到上步中新建(或指定)的掛載點下
# mount /dev/vdb1 /mnt/nfsdata
查看掛載結果
# df -TH Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 509M 0 509M 0% /dev tmpfs tmpfs 520M 0 520M 0% /dev/shm tmpfs tmpfs 520M 7.2M 513M 2% /run tmpfs tmpfs 520M 0 520M 0% /sys/fs/cgroup /dev/vda1 ext4 43G 2.3G 38G 6% / tmpfs tmpfs 104M 0 104M 0% /run/user/0 /dev/vdb1 ext4 22G 47M 20G 1% /mnt/nfsdata 表示新建分區“/dev/vdb1”已掛載至“/mnt/nfsdata”。
設置自動掛載
查詢磁盤分區的UUID
# blkid /dev/vdb1 /dev/vdb1: UUID="ef050532-2183-4873-980e-d4f7da9dbbd4" TYPE="ext4"
編輯fstab文件(以下UUID換成自己查詢所得的ID)
# vim /etc/fstab ====content==== UUID=ef050532-2183-4873-980e-d4f7da9dbbd4 /mnt/sdc ext4 defaults 0 2 ====end====
重載
# mount -a
查看掛載信息
# mount |grep /mnt/nfsdata /dev/vdb1 on /mnt/nfsdata type ext4 (rw,relatime,data=ordered)
三、卸載磁盤
卸載已掛載的分區 # umount /dev/vdb1 將“/etc/fstab”文件所有內容重新加載。 # mount -a 查詢掛載信息 # mount |grep /mnt/nfsdata 取消自動掛載(注釋或者刪除隨意) # vim /etc/fstab ====content==== # UUID=ef050532-2183-4873-980e-d4f7da9dbbd4 /mnt/sdc ext4 defaults 0 2 ====end====
Linux 云硬盤 EVS
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。